Repository navigation
60 lines (57 loc) · 2.06 KB
/
Copy pathrelease.yml
File metadata and controls
60 lines (57 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Release
on:
push:
tags: ['v*']
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
# Required for PyPI trusted publishing, which exchanges this OIDC token for
# a short-lived upload token. No API token in a repository secret.
id-token: write
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: '3.13'
cache: pip
cache-dependency-path: pyproject.toml
# The tag only TRIGGERS this; PyPI publishes whatever the built artifact
# says. Without this check, tagging v1.0.1 against a 1.0.0 package silently
# republishes 1.0.0, or fails as "already exists" with a confusing message.
- name: Tag must match the package version
run: |
tag="${GITHUB_REF_NAME#v}"
pkg="$(sed -n 's/^__version__ = "\(.*\)"$/\1/p' src/internetdata/__init__.py)"
if [ "$tag" != "$pkg" ] ; then
echo "tag $tag does not match __version__ $pkg" >&2
exit 1
fi
- run: pip install -e ".[dev]" build
- run: pytest
- run: python -m build
- uses: pypa/gh-action-pypi-publish@release/v1
github-release:
needs: publish
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v7
- name: GitHub Release from CHANGELOG.md
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
version="${GITHUB_REF_NAME#v}"
awk -v v="$version" '/^## /{ if (found) exit; found = ($2 == v); next } found' CHANGELOG.md > notes.md
if ! grep -q '^### ' notes.md ; then
echo "CHANGELOG.md has no section for ${version}" >&2
exit 1
fi
if gh release view "$GITHUB_REF_NAME" > /dev/null 2>&1 ; then
gh release edit "$GITHUB_REF_NAME" --notes-file notes.md
else
gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --notes-file notes.md --verify-tag
fi