Release #12
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: Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Enter the version name to release (e.g., 1.0.0).' | |
| required: true | |
| default: '1.0.0' | |
| jobs: | |
| release: | |
| name: "Release v${{ github.event.inputs.version }}" | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/tailestim | |
| permissions: | |
| id-token: write | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| cache: pip | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install hatch build | |
| - name: Update version | |
| run: | | |
| # Use the manually provided version. Remove "v" and "spaces" if there is any included in the input. | |
| VERSION=$(echo "${{ github.event.inputs.version }}" | sed -r "s/(^v| *)//g" ) | |
| echo "Updating version to $VERSION" | |
| # Update version in __about__.py | |
| sed -i "s/__version__ = \".*\"/__version__ = \"$VERSION\"/" src/tailestim/__about__.py | |
| - name: Commit version bump | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add src/tailestim/__about__.py | |
| git commit -m "chore: bump version to ${{ github.event.inputs.version }} [skip ci]" | |
| git push origin HEAD | |
| - name: Create Tag for Version Bump | |
| run: | | |
| VERSION="${{ github.event.inputs.version }}" | |
| git tag "v$VERSION" | |
| git push origin "v$VERSION" | |
| - name: Get previous tag | |
| id: prev_tag | |
| run: | | |
| # Sort tags in descending order and pick the second one as the previous version | |
| PREV_TAG=$(git tag --sort=-v:refname | sed -n '2p') | |
| echo "Previous tag is $PREV_TAG" | |
| echo "::set-output name=PREV_TAG::$PREV_TAG" | |
| - name: Create GitHub Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: "v${{ github.event.inputs.version }}" | |
| release_name: "v${{ github.event.inputs.version }}" | |
| body: | | |
| Automated release of version v${{ github.event.inputs.version }}. | |
| **Full Changelog**: https://github.com/mu373/tailestim/compare/${{ steps.prev_tag.outputs.PREV_TAG }}...v${{ github.event.inputs.version }} | |
| - name: Build package | |
| run: | | |
| python -m build | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |