Release #40
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
release-type: | |
type: choice | |
description: 'Release type' | |
required: true | |
options: | |
- patch | |
- minor | |
- major | |
deployment-env: | |
type: choice | |
description: 'Deployment environment' | |
required: true | |
options: | |
- test.pypi.org | |
- pypi.org | |
default: 'test.pypi.org' | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing to pypi.org and test.pypi.org | |
contents: write # needed for the softprops/action-gh-release GitHub release step | |
steps: | |
- uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ vars.DISY_RELEASE_APP_ID }} | |
private-key: ${{ secrets.DISY_RELEASE_APP_SECRET }} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ steps.app-token.outputs.token }} | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ vars.PYTHON_VERSION }} | |
# poetry is needed for building and for poetry-bumpversion for version management | |
- name: Install poetry | |
run: | | |
pipx install poetry | |
poetry self add poetry-bumpversion | |
# install dependencies early in case there are problems, do not build yet, or we will have a dist with wrong version | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install . | |
# Needed for creating the tag | |
- name: Configure Git | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
- name: Bump package version | |
run: | | |
echo "NEW_VERSION=$(poetry version ${{ github.event.inputs.release-type }} -s | head -n 1)" >> $GITHUB_ENV | |
echo "RELEASE_TAG=latest" >> $GITHUB_ENV | |
# Update changelog unreleased section with new version | |
- name: Update changelog | |
uses: superfaceai/release-changelog-action@v2 | |
with: | |
path-to-changelog: CHANGELOG.md | |
version: ${{ env.NEW_VERSION }} | |
operation: release | |
- name: Commit and tag changes | |
run: | | |
git add "pyproject.toml" | |
git add "CHANGELOG.md" | |
git commit -m "chore: release ${{ env.NEW_VERSION }}" | |
git tag ${{ env.NEW_VERSION }} | |
- name: Push changes | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: git push origin && git push --tags | |
- id: get-changelog | |
name: Get version changelog | |
uses: superfaceai/release-changelog-action@v2 | |
with: | |
path-to-changelog: CHANGELOG.md | |
version: ${{ env.NEW_VERSION }} | |
operation: read | |
- name: Update GitHub release documentation | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ env.NEW_VERSION }} | |
body: ${{ steps.get-changelog.outputs.changelog }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Create a dist/wheel for the bumped version now after "poetry version" has run | |
- name: Build | |
run: | | |
poetry build | |
# either push to test.pypi.org or pypi.org depending on user input | |
- name: Publish package distributions to Test (!) PyPI | |
if: "${{ github.event.inputs.deployment-env == 'test.pypi.org' }}" | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
- name: Publish package distributions to PyPI | |
if: "${{ github.event.inputs.deployment-env == 'pypi.org' }}" | |
uses: pypa/gh-action-pypi-publish@release/v1 |