Skip to content

Commit

Permalink
setup release process
Browse files Browse the repository at this point in the history
  • Loading branch information
nim65s committed Apr 17, 2022
1 parent b3ac316 commit bc54428
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
19 changes: 19 additions & 0 deletions docs/release.md
Original file line number Diff line number Diff line change
@@ -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]
```
23 changes: 23 additions & 0 deletions docs/release.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit bc54428

Please sign in to comment.