name: PGXN
on:
  workflow_dispatch:
    inputs:
      version:
        description: 'Version to release'
        required: true
        type: string

permissions:
  contents: read

jobs:
  release:
    name: Release
    runs-on: ubuntu-22.04
    timeout-minutes: 10
    container: pgxn/pgxn-tools
    steps:
    - name: Validate version tag
      run: '[[ ${{ inputs.version }} =~ ^[0-9]+.[0-9]+.[0-9]+ ]]'
      shell: bash

    - name: Check out
      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
      with:
        ref: '${{ inputs.version }}'

    - name: Bundle
      id: bundle
      run: pgxn-bundle

    - name: Upload
      env:
        PGXN_USERNAME: percona
        PGXN_PASSWORD: ${{ secrets.PGXN_PERCONA }}
      run: pgxn-release
