release autowrap #22
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 autowrap | |
| ########################################################################### | |
| # please make sure that autowrap version numbers have been properly updated | |
| ########################################################################### | |
| on: | |
| workflow_dispatch: # manual trigger | |
| inputs: | |
| next_version: | |
| description: 'Next version (empty = minor bump)' | |
| default: '' | |
| jobs: | |
| build_publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install -U pip build | |
| - name: Build wheel and source distribution | |
| run: | | |
| python -m build | |
| - name: Publish package to PyPI | |
| uses: pypa/gh-action-pypi-publish@master | |
| with: | |
| user: __token__ | |
| password: ${{ secrets.PYPI_RELEASE_AUTOWRAP }} | |
| packages_dir: ${{ github.workspace }}/dist | |
| - name: Parse version | |
| run: echo "version=$(python3 -c 'from autowrap.version import __version__; print(__version__)')" >> $GITHUB_OUTPUT | |
| id: version | |
| - name: Create github release | |
| uses: softprops/action-gh-release@v2 | |
| id: create_release | |
| with: | |
| draft: false | |
| prerelease: false | |
| name: ${{ steps.version.outputs.version }} | |
| tag_name: release/${{ steps.version.outputs.version }} | |
| body_path: CHANGELOG.md | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| - name: Setup things for new cycle | |
| id: setup_new | |
| run: | | |
| NEXT_VER=${{ github.event.inputs.next_version }} | |
| OLD_VER=${{ steps.version.outputs.version }} | |
| [ -z "$NEXT_VER" ] && NEXT_VER=$(echo $OLD_VER | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g') || true | |
| echo >> HISTORY.md | |
| cat CHANGELOG.md >> HISTORY.md | |
| echo >> HISTORY.md | |
| rm CHANGELOG.md && echo "autowrap $NEXT_VER" > CHANGELOG.md | |
| # Update string version | |
| sed -i -e "s/^__version__ = \".*\"/__version__ = \"$NEXT_VER\"/g" autowrap/version.py | |
| # Update tuple version for backward compatibility | |
| TUPLE_VER=$(echo $NEXT_VER | sed 's/\./, /g') | |
| sed -i -e "s/^__version_tuple__ = (.*)/__version_tuple__ = ($TUPLE_VER)/g" autowrap/version.py | |
| - uses: stefanzweifel/git-auto-commit-action@v4.15.2 | |
| with: | |
| commit_message: New release cycle | |
| file_pattern: CHANGELOG.md HISTORY.md autowrap/version.py |