71
71
uses : pypa/gh-action-pypi-publish@release/v1
72
72
with :
73
73
repository-url : " https://test.pypi.org/legacy/"
74
- attestations : true
75
74
76
75
github-release :
77
76
name : Release on GitHub
@@ -82,36 +81,68 @@ jobs:
82
81
name : GitHub
83
82
url : " https://github.com/ei-grad/flask-shell-ipython/releases/"
84
83
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
87
87
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
88
124
- name : Download artifacts
89
125
uses : actions/download-artifact@v4
90
- - name : Sign the dists with Sigstore
91
-
126
+ - name : Attest build provenance
127
+ uses : actions/attest-build-provenance@v1
92
128
with :
93
- inputs : >-
94
- ./dist/*.tar.gz
95
- ./dist/*.whl
129
+ subject-path : dist/*
96
130
- name : Create GitHub Release
97
131
env :
98
132
GITHUB_TOKEN : ${{ github.token }}
99
133
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"
104
137
- name : Upload artifact signatures to GitHub Release
105
138
env :
106
139
GITHUB_TOKEN : ${{ github.token }}
107
140
run : >-
108
- gh release upload
109
- '${{ github.ref_name }}' dist/**
110
- --repo '${{ github.repository }}'
141
+ gh release upload "$VERSION" dist/**
111
142
112
143
pypi-publish :
113
144
name : Release on PyPI
114
- needs : test
145
+ needs : github-release
115
146
if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
116
147
runs-on : ubuntu-latest
117
148
environment :
@@ -124,5 +155,3 @@ jobs:
124
155
uses : actions/download-artifact@v4
125
156
- name : Publish package distributions to PyPI
126
157
uses : pypa/gh-action-pypi-publish@release/v1
127
- with :
128
- attestations : true
0 commit comments