Skip to content

Deploy a new version #4

Deploy a new version

Deploy a new version #4

Workflow file for this run

name: Deploy a new version
on:
workflow_dispatch:
inputs:
version_tag:
description: 'Version tag'
required: true
default: v0.1.0
dry_run:
type: boolean
description: 'Dry run'
default: false
jobs:
deploy:
runs-on: ubuntu-latest
environment: deploy
steps:
- uses: actions/checkout@v4
- name: Push new version tag temporarily for changelog generation
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git tag -a ${{ github.event.inputs.version_tag }} -m ${{ github.event.inputs.version_tag }}
git push --tags
- name: (dry-run) Get CHANGELOG
if: ${{ github.event.inputs.dry_run }}
id: changelog-dry-run
uses: requarks/[email protected]
with:
includeInvalidCommits: true
excludeTypes: build,docs,style,other
token: ${{ github.token }}
tag: ${{ github.event.inputs.version_tag }}
- name: (dry-run) Display CHANGELOG
if: ${{ github.event.inputs.dry_run }}
run: |
echo '${{ steps.changelog-dry-run.outputs.changes }}'
echo '${{ steps.changelog-dry-run.outputs.changes }}' > "$GITHUB_STEP_SUMMARY"
- name: (dry-run) Remove temporary version tag
if: ${{ github.event.inputs.dry_run }}
run: |
git tag -d ${{ github.event.inputs.version_tag }}
git push origin --delete ${{ github.event.inputs.version_tag }}
- name: Update CHANGELOG
if: ${{ !github.event.inputs.dry_run }}
id: changelog
uses: requarks/[email protected]
with:
includeInvalidCommits: true
excludeTypes: build,docs,style,other
token: ${{ github.token }}
tag: ${{ github.event.inputs.version_tag }}
changelogFilePath: docs/CHANGELOG.md
- name: Commit docs/CHANGELOG.md and update tag
if: ${{ !github.event.inputs.dry_run }}
run: |
git tag -d ${{ github.event.inputs.version_tag }}
git push origin --delete ${{ github.event.inputs.version_tag }}
git add docs/CHANGELOG.md
git commit -m "docs: update docs/CHANGELOG.md for ${{ github.event.inputs.version_tag }} [skip ci]"
git tag -a ${{ github.event.inputs.version_tag }} -m ${{ github.event.inputs.version_tag }}
git push
git push --tags
- name: Create Release
if: ${{ !github.event.inputs.dry_run }}
uses: ncipollo/[email protected]
with:
allowUpdates: true
draft: false
makeLatest: true
name: ${{ github.event.inputs.version_tag }}
tag: ${{ github.event.inputs.version_tag }}
body: ${{ steps.changelog.outputs.changes }}
- name: Set up Python 3.11
if: ${{ !github.event.inputs.dry_run }}
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Build and upload to PyPI
if: ${{ !github.event.inputs.dry_run }}
run: |
python -m pip install --upgrade pip
pip3 install build twine
python -m build . --sdist
python3 -m twine upload dist/* -u __token__ -p ${{ secrets.PYPI_TOKEN }} --non-interactive