Create Github and trigger PyPI release #3
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: Create Github and trigger PyPI release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| bump_version: | |
| description: Version | |
| required: false | |
| default: patch | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| jobs: | |
| create_release: | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: create-github-release | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v2 | |
| with: | |
| python-version: "3.9" | |
| - name: Create Github release | |
| env: | |
| BUMP_VERSION: ${{ github.event.inputs.bump_version }} | |
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
| run: | | |
| set -xeo pipefail | |
| last_tag=$(git describe --tags --abbrev=0 --match "v*") | |
| regex="^v([0-9]*).([0-9]*).([0-9]*)$" | |
| [[ $last_tag =~ $regex ]] || $(echo "failed to parse last tag '$last_tag'" && exit 1) | |
| major=${BASH_REMATCH[1]} | |
| minor=${BASH_REMATCH[2]} | |
| patch=${BASH_REMATCH[3]} | |
| if [ $BUMP_VERSION == "major" ]; then version="$((major + 1)).0.0"; fi | |
| if [ $BUMP_VERSION == "minor" ]; then version="$major.$((minor + 1)).0"; fi | |
| if [ $BUMP_VERSION == "patch" ]; then version="$major.$minor.$((patch + 1))"; fi | |
| git log $last_tag...HEAD --pretty=format:'* %s' --reverse > /tmp/notes.txt | |
| gh release create v$version --title v$version --notes-file /tmp/notes.txt |