Build Release #8
This file contains hidden or 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: Build Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Release version" | |
| required: true | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Ensure we have full history to manipulate tags. | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.10" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install towncrier | |
| - name: Generate draft release notes with Towncrier | |
| run: | | |
| towncrier build --draft --version "${{ inputs.version }}" > draft_release_notes.md | |
| - name: Generate release notes with Towncrier | |
| run: | | |
| towncrier build --version "${{ inputs.version }}" --yes | |
| - name: Update pyproject.toml with new version | |
| run: | | |
| sed -i '/^\[project\]/,/^version = / s/^version = ".*"$/version = "${{ inputs.version }}"/' pyproject.toml | |
| - name: Commit updated changelog | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git add CHANGES.md pyproject.toml | |
| git commit -m "Update version to ${{ inputs.version }} and generate release notes." | |
| git push origin main | |
| - name: Create tag | |
| run: | | |
| git tag -a "${{ inputs.version }}" -m "Release ${{ inputs.version }}." | |
| git push origin "${{ inputs.version }}" | |
| - name: Create GitHub release and upload artifacts | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ inputs.version }} | |
| name: ${{ inputs.version }} | |
| draft: true # Set to true to create a draft release. | |
| prerelease: false | |
| body_path: draft_release_notes.md |