From bc5442821a099603d2e0b2520215fcbba81bd3e0 Mon Sep 17 00:00:00 2001 From: Guilhem Saurel Date: Sun, 17 Apr 2022 10:35:51 +0200 Subject: [PATCH] setup release process --- .github/workflows/release.yml | 18 ++++++++++++++++++ docs/release.md | 19 +++++++++++++++++++ docs/release.sh | 23 +++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 docs/release.md create mode 100755 docs/release.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a33d580 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,18 @@ +name: Release on GitHub & PyPI + +on: + push: + tags: + - 'v*' + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: python -m pip install -U poetry + - run: poetry publish -u __token__ -p ${{ secrets.PYPI_TOKEN }} --build + - run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + - run: gh release create -t "Release ${{ env.TAG}}" -n "$(awk '/## \[${{ env.TAG }}] - /{flag=1;next}/## \[/{flag=0}flag' CHANGELOG.md)" ${{ env.TAG }} dist/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/docs/release.md b/docs/release.md new file mode 100644 index 0000000..2669291 --- /dev/null +++ b/docs/release.md @@ -0,0 +1,19 @@ +# Publish a new release + +A github actions handle the build of the release archives, and push them to PyPI and Github Releases. +To trigger it, we just need to: + +1. use poetry to update the version number +2. update `__version__` in `cmw.py` +3. update the changelog +3. `git commit` +4. `git tag` +5. `git push` +6. `git push --tags` + + +For this, an helper script is provided: + +```bash +./docs/release.sh [patch|minor|major|x.y.z] +``` diff --git a/docs/release.sh b/docs/release.sh new file mode 100755 index 0000000..5ba1d46 --- /dev/null +++ b/docs/release.sh @@ -0,0 +1,23 @@ +#!/bin/bash -eux +# ./docs/release.sh [patch|minor|major|x.y.z] + +[[ $(basename "$PWD") == docs ]] && cd .. + + +OLD=$(poetry version -s) + +poetry version "$1" + +NEW=$(poetry version -s) +DATE=$(date +%Y-%m-%d) + +sed -ri "/__version__ /s/[0-9.]+/$NEW/" cmw.py +sed -i "/^## \[Unreleased\]/a \\\n## [v$NEW] - $DATE" CHANGELOG.md +sed -i "/^\[Unreleased\]/s/$OLD/$NEW/" CHANGELOG.md +sed -i "/^\[Unreleased\]/a [v$NEW]: https://github.com/nim65s/cmw/compare/v$OLD...v$NEW" CHANGELOG.md + +git add cmw.py pyproject.toml CHANGELOG.md +git commit -m "Release v$NEW" +git tag -s "v$NEW" -m "Release v$NEW" +git push +git push --tags