Skip to content

Commit 50bcf12

Browse files
committed
Switch to actions/attest-build-provenance@v1
1 parent 85ef087 commit 50bcf12

File tree

2 files changed

+48
-18
lines changed

2 files changed

+48
-18
lines changed

.github/workflows/release.yml

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ jobs:
7171
uses: pypa/gh-action-pypi-publish@release/v1
7272
with:
7373
repository-url: "https://test.pypi.org/legacy/"
74-
attestations: true
7574

7675
github-release:
7776
name: Release on GitHub
@@ -82,36 +81,68 @@ jobs:
8281
name: GitHub
8382
url: "https://github.com/ei-grad/flask-shell-ipython/releases/"
8483
permissions:
85-
contents: write # IMPORTANT: mandatory for making GitHub Releases
86-
id-token: write # IMPORTANT: mandatory for sigstore
84+
attestations: write
85+
contents: write
86+
id-token: write
8787
steps:
88+
- uses: actions/checkout@v4
89+
- name: Extract Version from Tag
90+
run: echo "VERSION_FROM_GIT_REF=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
91+
- name: Extract Version from pyproject.toml
92+
run: |
93+
pip install toml
94+
VERSION_FROM_PYPROJECT=$(python << EOF
95+
import toml
96+
print(toml.load('pyproject.toml')['project']['version'])
97+
EOF
98+
)
99+
echo "VERSION_FROM_PYPROJECT=$VERSION_FROM_PYPROJECT" >> $GITHUB_ENV
100+
- name: Ensure version consistency
101+
run: |
102+
if [ "$VERSION_FROM_GIT_REF" != "$VERSION_FROM_PYPROJECT" ]; then
103+
echo "Error: Version from tag ($VERSION_FROM_GIT_REF) does not match version in pyproject.toml ($VERSION_FROM_PYPROJECT)"
104+
exit 1
105+
fi
106+
echo VERSION=$VERSION_FROM_GIT_REF >> $GITHUB_ENV
107+
- name: Extract changelog for release notes
108+
run: |
109+
(
110+
echo "CHANGELOG<<EOF"
111+
awk -v version="$VERSION" '{
112+
if ($0 ~ "^## \\[" version "\\]") inSection = 1;
113+
else if ($0 ~ "^## \\[" && inSection) inSection = 0;
114+
if (inSection) print $0;
115+
}' CHANGELOG.md
116+
echo "EOF"
117+
) >> $GITHUB_ENV
118+
- name: Validate changelog content
119+
run: |
120+
if [ -z "$CHANGELOG" ] ; then
121+
echo "Missing CHANGELOG.md section for release $VERSION"
122+
exit 1
123+
fi
88124
- name: Download artifacts
89125
uses: actions/download-artifact@v4
90-
- name: Sign the dists with Sigstore
91-
uses: sigstore/[email protected]
126+
- name: Attest build provenance
127+
uses: actions/attest-build-provenance@v1
92128
with:
93-
inputs: >-
94-
./dist/*.tar.gz
95-
./dist/*.whl
129+
subject-path: dist/*
96130
- name: Create GitHub Release
97131
env:
98132
GITHUB_TOKEN: ${{ github.token }}
99133
run: >-
100-
gh release create
101-
'${{ github.ref_name }}'
102-
--repo '${{ github.repository }}'
103-
--generate-notes
134+
gh release create "$VERSION"
135+
--draft
136+
--notes "$CHANGELOG"
104137
- name: Upload artifact signatures to GitHub Release
105138
env:
106139
GITHUB_TOKEN: ${{ github.token }}
107140
run: >-
108-
gh release upload
109-
'${{ github.ref_name }}' dist/**
110-
--repo '${{ github.repository }}'
141+
gh release upload "$VERSION" dist/**
111142
112143
pypi-publish:
113144
name: Release on PyPI
114-
needs: test
145+
needs: github-release
115146
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
116147
runs-on: ubuntu-latest
117148
environment:
@@ -124,5 +155,3 @@ jobs:
124155
uses: actions/download-artifact@v4
125156
- name: Publish package distributions to PyPI
126157
uses: pypa/gh-action-pypi-publish@release/v1
127-
with:
128-
attestations: true

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ dependencies = [
3333

3434
[project.urls]
3535
Homepage = "https://github.com/ei-grad/flask-shell-ipython"
36+
Changelog = "https://github.com/ei-grad/flask-shell-ipython/blob/main/CHANGELOG.md"
3637

3738
[project.entry-points."flask.commands"]
3839
shell = "flask_shell_ipython:shell"

0 commit comments

Comments
 (0)