Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workflows: automatically publish releases to PyPI and GitHub #246

Merged
merged 2 commits into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .github/ISSUE_TEMPLATE/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

- [ ] Update `CHANGELOG.md` and version in `openslide/_version.py`
- [ ] Create and push signed tag
- [ ] `git clean -dxf && mkdir dist`
- [ ] Find the [workflow run](https://github.com/openslide/openslide-python/actions/workflows/python.yml) for the tag; download its dist and docs artifacts
- [ ] `unzip /path/to/downloaded/openslide-python-dist.zip && mv openslide-python-dist-*/* dist/`
- [ ] `twine upload dist/*`
- [ ] Recompress tarball with `xz`
- [ ] Attach release notes to [GitHub release](https://github.com/openslide/openslide-python/releases/new); upload tarballs and wheels
- [ ] Find the [workflow run](https://github.com/openslide/openslide-python/actions/workflows/python.yml) for the tag
- [ ] Once the build finishes, approve deployment to PyPI
- [ ] Download the docs artifact
- [ ] Verify that the workflow created a [PyPI release](https://pypi.org/p/openslide-python) with a description, source tarball, and wheels
- [ ] Verify that the workflow created a [GitHub release](https://github.com/openslide/openslide-python/releases) with release notes, a source tarball, and wheels
- [ ] `cd` into website checkout; `rm -r api/python && unzip /path/to/downloaded/openslide-python-docs.zip && mv openslide-python-docs-* api/python`
- [ ] Update website: `_data/releases.yaml`, `_includes/news.md`
- [ ] Update Ubuntu PPA
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,45 @@ jobs:
with:
name: ${{ needs.pre-commit.outputs.docs-base }}
path: artifact

release:
name: Release
if: github.ref_type == 'tag'
environment:
name: pypi
url: https://pypi.org/p/openslide-python
needs: [pre-commit, tests, windows]
runs-on: ubuntu-latest
concurrency: release-${{ github.ref }}
permissions:
contents: write
id-token: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: ${{ needs.pre-commit.outputs.dist-base }}
- name: Release to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: ${{ needs.pre-commit.outputs.dist-base }}
- name: Release to GitHub
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
version=$(echo "${{ github.ref_name }}" | sed "s/^v//")
# recompress tarball with xz
gunzip -k "${{ needs.pre-commit.outputs.dist-base }}/openslide-python-${version}.tar.gz"
tar xf "${{ needs.pre-commit.outputs.dist-base }}/openslide-python-${version}.tar"
xz -9 "${{ needs.pre-commit.outputs.dist-base }}/openslide-python-${version}.tar"
# extract changelog
awk -e '/^## / && ok {exit}' \
-e '/^## / {ok=1; next}' \
-e 'ok {print}' \
"openslide-python-$version/CHANGELOG.md" > changes
gh release create --latest --verify-tag \
--repo "${{ github.repository }}" \
--title "OpenSlide Python $version" \
--notes-file changes \
"${{ github.ref_name }}" \
"${{ needs.pre-commit.outputs.dist-base }}/"*