Release #11
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: | |
version_bump: | |
description: 'Version part to bump (major, minor, patch)' | |
required: true | |
default: 'patch' | |
jobs: | |
publish-release: | |
runs-on: ubuntu-latest | |
permissions: | |
# Give the default GITHUB_TOKEN write permission to commit and push the | |
# added or changed files to the repository. | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ssh-key: ${{ secrets.RELEASE_KEY }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: pip install bump-my-version | |
- name: Fetch Draft Release Notes | |
id: fetch_release_notes | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
DRAFT_RELEASE=$(gh api repos/${{ github.repository }}/releases -q '[.[] | select(.draft==true)] | first') | |
DRAFT_NOTES=$(echo $DRAFT_RELEASE | jq -r '.body') | |
DRAFT_ID=$(echo $DRAFT_RELEASE | jq -r '.id' | jq -Rs .) | |
echo "notes=$DRAFT_NOTES" >> $GITHUB_OUTPUT | |
gh api repos/${{ github.repository }}/releases/$DRAFT_ID -X DELETE | |
- name: Update Changelog | |
uses: stefanzweifel/changelog-updater-action@v1 | |
with: | |
latest-version: $(bump-my-version show --increment ${{ github.event.inputs.version_bump }} new_version) | |
release-notes: ${{ steps.fetch_release_notes.outputs.notes }} | |
- name: Bump version | |
run: bump-my-version bump ${{ github.event.inputs.version_bump }} -v | |
- name: Create GitHub Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
TAG_NAME=$(bump-my-version show current_version) | |
gh release create v$TAG_NAME --title "Release v$TAG_NAME" --notes "${{ steps.fetch_release_notes.outputs.notes }}" | |
- name: Set up PDM | |
uses: pdm-project/setup-pdm@v4 | |
- name: Build and publish to pypi | |
run: pdm publish -r testpypi | |
env: | |
PDM_PUBLISH_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }} | |
- name: Upload the wheel to the Github release | |
run: | | |
TAG_NAME=$(bump-my-version show current_version) | |
pdm build | |
gh release upload -R ${{ github.repository }} v$TAG_NAME dist/* |