|
| 1 | +name: Deploy a new version |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version_tag: |
| 7 | + description: 'Version tag' |
| 8 | + required: true |
| 9 | + default: v0.1.0 |
| 10 | + dry_run: |
| 11 | + type: boolean |
| 12 | + description: 'Dry run' |
| 13 | + default: false |
| 14 | + |
| 15 | +jobs: |
| 16 | + deploy: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + environment: deploy |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + - name: Push new version tag temporarily for changelog generation |
| 23 | + run: | |
| 24 | + git config user.name github-actions[bot] |
| 25 | + git config user.email github-actions[bot]@users.noreply.github.com |
| 26 | + git tag -a ${{ github.event.inputs.version_tag }} -m ${{ github.event.inputs.version_tag }} |
| 27 | + git push --tags |
| 28 | +
|
| 29 | + - name: (dry-run) Get CHANGELOG |
| 30 | + if: ${{ github.event.inputs.dry_run }} |
| 31 | + id: changelog-dry-run |
| 32 | + |
| 33 | + with: |
| 34 | + includeInvalidCommits: true |
| 35 | + excludeTypes: build,docs,style,other |
| 36 | + token: ${{ github.token }} |
| 37 | + tag: ${{ github.event.inputs.version_tag }} |
| 38 | + |
| 39 | + - name: (dry-run) Display CHANGELOG |
| 40 | + if: ${{ github.event.inputs.dry_run }} |
| 41 | + run: | |
| 42 | + echo '${{ steps.changelog-dry-run.outputs.changes }}' |
| 43 | + echo '${{ steps.changelog-dry-run.outputs.changes }}' > "$GITHUB_STEP_SUMMARY" |
| 44 | +
|
| 45 | + - name: (dry-run) Remove temporary version tag |
| 46 | + if: ${{ github.event.inputs.dry_run }} |
| 47 | + run: | |
| 48 | + git tag -d ${{ github.event.inputs.version_tag }} |
| 49 | + git push origin --delete ${{ github.event.inputs.version_tag }} |
| 50 | +
|
| 51 | + - name: Update CHANGELOG |
| 52 | + if: ${{ !github.event.inputs.dry_run }} |
| 53 | + id: changelog |
| 54 | + |
| 55 | + with: |
| 56 | + includeInvalidCommits: true |
| 57 | + excludeTypes: build,docs,style,other |
| 58 | + token: ${{ github.token }} |
| 59 | + tag: ${{ github.event.inputs.version_tag }} |
| 60 | + changelogFilePath: docs/CHANGELOG.md |
| 61 | + |
| 62 | + - name: Commit docs/CHANGELOG.md and update tag |
| 63 | + if: ${{ !github.event.inputs.dry_run }} |
| 64 | + run: | |
| 65 | + git tag -d ${{ github.event.inputs.version_tag }} |
| 66 | + git push origin --delete ${{ github.event.inputs.version_tag }} |
| 67 | + git add docs/CHANGELOG.md |
| 68 | + git commit -m "docs: update docs/CHANGELOG.md for ${{ github.event.inputs.version_tag }} [skip ci]" |
| 69 | + git tag -a ${{ github.event.inputs.version_tag }} -m ${{ github.event.inputs.version_tag }} |
| 70 | + git push |
| 71 | + git push --tags |
| 72 | +
|
| 73 | + - name: Create Release |
| 74 | + if: ${{ !github.event.inputs.dry_run }} |
| 75 | + |
| 76 | + with: |
| 77 | + allowUpdates: true |
| 78 | + draft: false |
| 79 | + makeLatest: true |
| 80 | + name: ${{ github.event.inputs.version_tag }} |
| 81 | + tag: ${{ github.event.inputs.version_tag }} |
| 82 | + body: ${{ steps.changelog.outputs.changes }} |
| 83 | + |
| 84 | + - name: Set up Python 3.11 |
| 85 | + if: ${{ !github.event.inputs.dry_run }} |
| 86 | + uses: actions/setup-python@v4 |
| 87 | + with: |
| 88 | + python-version: 3.11 |
| 89 | + |
| 90 | + - name: Build and upload to PyPI |
| 91 | + if: ${{ !github.event.inputs.dry_run }} |
| 92 | + run: | |
| 93 | + python -m pip install --upgrade pip |
| 94 | + pip3 install build twine |
| 95 | + python -m build . --sdist |
| 96 | + python3 -m twine upload dist/* -u __token__ -p ${{ secrets.PYPI_TOKEN }} --non-interactive |
0 commit comments