name: Update Version on PGXN Config Files

env:
  PROJECT_VERSION: ${{ github.event.inputs.project_version }}
  GH_TOKEN: ${{ secrets.GH_TOKEN }}

on:
  workflow_dispatch:
    inputs:
      project_version:
        description: "Version number to be released e.g 10.0.3"
        required: true

jobs:
  update_pgxn:
    name: Update pgxn configuration
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Install dependencies
        run: sudo apt install libcurl4-openssl-dev libssl-dev

      - name: Clone Tools branch
        run: git clone --depth 1 --branch v0.8.1 https://github.com/citusdata/tools.git

      - name: Install Python requirements
        run: python -m pip install -r tools/packaging_automation/requirements.txt

      - name: Update pgxn files
        run: |
          python -m packaging_automation.update_pgxn \
          --prj_ver ${PROJECT_VERSION} \
          --gh_token ${GH_TOKEN} \
          --pipeline \
          --exec_path "$(pwd)"
