|
| 1 | +name: Release |
| 2 | +on: |
| 3 | + release: |
| 4 | + types: [published] |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - stable |
| 8 | + |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + candidate: |
| 12 | + description: 'Release candidate.' |
| 13 | + required: true |
| 14 | + type: boolean |
| 15 | + default: true |
| 16 | + test_pypi: |
| 17 | + description: 'Test PyPI.' |
| 18 | + type: boolean |
| 19 | + default: false |
| 20 | +jobs: |
| 21 | + release: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + permissions: |
| 24 | + id-token: write |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + ref: ${{ inputs.candidate && 'main' || 'stable' }} |
| 29 | + |
| 30 | + - name: Set up latest Python |
| 31 | + uses: actions/setup-python@v5 |
| 32 | + with: |
| 33 | + python-version-file: 'pyproject.toml' |
| 34 | + |
| 35 | + - name: Install dependencies |
| 36 | + run: | |
| 37 | + python -m pip install --upgrade pip |
| 38 | + python -m pip install .[dev] |
| 39 | +
|
| 40 | + - name: Create wheel |
| 41 | + run: | |
| 42 | + make dist |
| 43 | +
|
| 44 | + - name: Publish a Python distribution to PyPI |
| 45 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 46 | + with: |
| 47 | + repository-url: ${{ inputs.test_pypi && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }} |
| 48 | + |
| 49 | + - name: Bump version to next candidate |
| 50 | + if: ${{ inputs.candidate && !inputs.test_pypi }} |
| 51 | + run: | |
| 52 | + git config user.name "github-actions[bot]" |
| 53 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 54 | + bump-my-version bump candidate --no-tag --no-commit |
| 55 | +
|
| 56 | + - name: Create pull request |
| 57 | + if: ${{ inputs.candidate && !inputs.test_pypi }} |
| 58 | + id: cpr |
| 59 | + uses: peter-evans/create-pull-request@v4 |
| 60 | + with: |
| 61 | + token: ${{ secrets.GH_ACCESS_TOKEN }} |
| 62 | + commit-message: bumpversion-candidate |
| 63 | + committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
| 64 | + author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> |
| 65 | + signoff: false |
| 66 | + delete-branch: true |
| 67 | + title: Automated Bump Version Candidate |
| 68 | + body: "This is an auto-generated PR that bumps the version to the next candidate." |
| 69 | + branch: bumpversion-candidate-update |
| 70 | + branch-suffix: short-commit-hash |
| 71 | + add-paths: | |
| 72 | + ctgan/__init__.py |
| 73 | + pyproject.toml |
| 74 | + draft: false |
| 75 | + base: main |
| 76 | + |
| 77 | + - name: Enable Pull Request Automerge |
| 78 | + if: ${{ steps.cpr.outputs.pull-request-operation == 'created' }} |
| 79 | + run: gh pr merge "${{ steps.cpr.outputs.pull-request-number }}" --squash --admin |
| 80 | + env: |
| 81 | + GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} |
0 commit comments