Skip to content

Commit f4f2f20

Browse files
authored
Backfill GitHub releases and emit release on tag publish
- Add scripts/backfill-releases.sh to create GH releases for v0.1.0 and v0.2.0 with PyPI artifacts - Update publish workflow to create a GitHub release on each tag push, attaching wheel and sdist - Upgrade contents permission to write so the release step can create releases Closes #6
1 parent 1e3145f commit f4f2f20

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

.github/workflows/publish.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
environment: pypi
1616
permissions:
1717
id-token: write
18-
contents: read
18+
contents: write
1919
steps:
2020
- uses: actions/checkout@v6
2121
- uses: actions/setup-python@v6
@@ -27,3 +27,6 @@ jobs:
2727
with:
2828
packages-dir: sdk/dist/
2929
print-hash: true
30+
- run: gh release create "${{ github.ref_name }}" --generate-notes sdk/dist/*.whl sdk/dist/*.tar.gz
31+
env:
32+
GH_TOKEN: ${{ github.token }}

scripts/backfill-releases.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
PYPI_PACKAGE="decree"
5+
VERSIONS=("0.1.0" "0.2.0")
6+
7+
for version in "${VERSIONS[@]}"; do
8+
tag="v${version}"
9+
tmpdir=$(mktemp -d)
10+
trap 'rm -rf "$tmpdir"' EXIT
11+
12+
echo "Fetching PyPI metadata for ${PYPI_PACKAGE} ${version}..."
13+
metadata=$(curl -fsSL "https://pypi.org/pypi/${PYPI_PACKAGE}/${version}/json")
14+
15+
mapfile -t urls < <(echo "$metadata" | python3 -c "
16+
import json, sys
17+
data = json.load(sys.stdin)
18+
for f in data['urls']:
19+
if f['packagetype'] in ('bdist_wheel', 'sdist'):
20+
print(f['url'])
21+
")
22+
23+
for url in "${urls[@]}"; do
24+
filename=$(basename "$url")
25+
echo "Downloading ${filename}..."
26+
curl -fsSL -o "${tmpdir}/${filename}" "$url"
27+
done
28+
29+
echo "Creating GitHub release for ${tag}..."
30+
gh release create "$tag" \
31+
--repo opendecree/decree-python \
32+
--generate-notes \
33+
"${tmpdir}"/*.whl \
34+
"${tmpdir}"/*.tar.gz
35+
36+
trap - EXIT
37+
rm -rf "$tmpdir"
38+
done

0 commit comments

Comments
 (0)