Skip to content

Commit 6ac708e

Browse files
committed
workflows: automatically create GitHub release from tag
Signed-off-by: Benjamin Gilbert <[email protected]>
1 parent d123249 commit 6ac708e

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

.github/ISSUE_TEMPLATE/release.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
- [ ] Find the [workflow run](https://github.com/openslide/openslide-python/actions/workflows/python.yml) for the tag; download its dist and docs artifacts
77
- [ ] `unzip /path/to/downloaded/openslide-python-dist.zip && mv openslide-python-dist-*/* dist/`
88
- [ ] `twine upload dist/*`
9-
- [ ] Recompress tarball with `xz`
10-
- [ ] Attach release notes to [GitHub release](https://github.com/openslide/openslide-python/releases/new); upload tarballs and wheels
9+
- [ ] Verify that the workflow created a [GitHub release](https://github.com/openslide/openslide-python/releases) with release notes, a source tarball, and wheels
1110
- [ ] `cd` into website checkout; `rm -r api/python && unzip /path/to/downloaded/openslide-python-docs.zip && mv openslide-python-docs-* api/python`
1211
- [ ] Update website: `_data/releases.yaml`, `_includes/news.md`
1312
- [ ] Update Ubuntu PPA

.github/workflows/python.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,37 @@ jobs:
218218
with:
219219
name: ${{ needs.pre-commit.outputs.docs-base }}
220220
path: artifact
221+
222+
release:
223+
name: Release
224+
if: github.ref_type == 'tag'
225+
needs: [pre-commit, tests, windows]
226+
runs-on: ubuntu-latest
227+
concurrency: release-${{ github.ref }}
228+
permissions:
229+
contents: write
230+
steps:
231+
- name: Download artifacts
232+
uses: actions/download-artifact@v3
233+
with:
234+
name: ${{ needs.pre-commit.outputs.dist-base }}
235+
- name: Release to GitHub
236+
env:
237+
GITHUB_TOKEN: ${{ github.token }}
238+
run: |
239+
version=$(echo "${{ github.ref_name }}" | sed "s/^v//")
240+
# recompress tarball with xz
241+
gunzip -k "${{ needs.pre-commit.outputs.dist-base }}/openslide-python-${version}.tar.gz"
242+
tar xf "${{ needs.pre-commit.outputs.dist-base }}/openslide-python-${version}.tar"
243+
xz -9 "${{ needs.pre-commit.outputs.dist-base }}/openslide-python-${version}.tar"
244+
# extract changelog
245+
awk -e '/^## / && ok {exit}' \
246+
-e '/^## / {ok=1; next}' \
247+
-e 'ok {print}' \
248+
"openslide-python-$version/CHANGELOG.md" > changes
249+
gh release create --latest --verify-tag \
250+
--repo "${{ github.repository }}" \
251+
--title "OpenSlide Python $version" \
252+
--notes-file changes \
253+
"${{ github.ref_name }}" \
254+
"${{ needs.pre-commit.outputs.dist-base }}/"*

0 commit comments

Comments
 (0)