FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
HydroModPy/.github/workflows/publish.yml at main · HydroModPy/HydroModPy · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
HydroModPy
/
HydroModPy
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
11
Code
Issues
18
Pull requests
1
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
HydroModPy
/
.github
/
workflows
/
publish.yml
Copy path
View runs
More file actions
More file actions
Latest commit
History
History
History
204 lines (178 loc) · 5.49 KB
Breadcrumbs
HydroModPy
/
.github
/
workflows
/
publish.yml
Copy path
File metadata and controls
204 lines (178 loc) · 5.49 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#
Publish HydroModPy to PyPI on tag push.
#
#
Trigger: a git tag matching v*.*.* is pushed.
#
Steps:
#
1. Build wheel + sdist with `python -m build`.
#
2. Generate a CycloneDX SBOM (`cyclonedx-bom`) from a fresh wheel install.
#
3. Upload to PyPI via Trusted Publishers (OIDC, no API token).
#
4. Create a GitHub release with the matching CHANGELOG section as body,
#
mark PEP 440 a/b/rc tags as pre-releases, and attach both the
#
distribution files and the SBOM as release assets.
#
#
Trusted Publisher prerequisite (one-time, on PyPI):
#
project = hydromodpy
#
owner = (org/user)
#
repository = HydroModPy
#
workflow = publish.yml
#
environment = pypi
name
:
Release / PyPI
on
:
push
:
tags
:
-
"
v*.*.*
"
workflow_dispatch
:
inputs
:
tag
:
description
:
"
Existing tag to publish (e.g. v0.5.0)
"
required
:
true
type
:
string
concurrency
:
group
:
${{ github.workflow }}-${{ github.ref }}
cancel-in-progress
:
false
permissions
:
contents
:
read
jobs
:
build
:
name
:
Release / build sdist and wheel
runs-on
:
ubuntu-latest
timeout-minutes
:
10
steps
:
-
uses
:
actions/checkout@v4
with
:
ref
:
${{ inputs.tag || github.ref }}
fetch-depth
:
0
-
uses
:
actions/setup-python@v5
with
:
python-version
:
"
3.12
"
cache
:
pip
-
name
:
Install build tooling
run
:
pip install "build>=1.2"
-
name
:
Build distributions
run
:
python -m build
-
name
:
Verify version matches tag
run
:
|
tag="${{ inputs.tag || github.ref_name }}"
expected="${tag#v}"
actual=$(python -c "import tomllib, pathlib; print(tomllib.loads(pathlib.Path('pyproject.toml').read_text())['project']['version'])")
if [ "$expected" != "$actual" ]; then
echo "Tag $tag does not match pyproject version $actual" >&2
exit 1
fi
-
uses
:
actions/upload-artifact@v4
with
:
name
:
dist
path
:
dist/
if-no-files-found
:
error
sbom
:
name
:
Release / generate CycloneDX SBOM
needs
:
build
runs-on
:
ubuntu-latest
timeout-minutes
:
10
steps
:
-
uses
:
actions/checkout@v4
with
:
ref
:
${{ inputs.tag || github.ref }}
fetch-depth
:
0
-
uses
:
actions/setup-python@v5
with
:
python-version
:
"
3.12
"
cache
:
pip
-
uses
:
actions/download-artifact@v4
with
:
name
:
dist
path
:
dist/
-
name
:
Install SBOM tooling
run
:
|
pip install --upgrade pip
pip install "cyclonedx-bom>=4.6"
-
name
:
Install built wheel into fresh venv
run
:
|
python -m venv /tmp/hmp-sbom
/tmp/hmp-sbom/bin/pip install --upgrade pip
/tmp/hmp-sbom/bin/pip install dist/*.whl
-
name
:
Generate CycloneDX SBOM (JSON)
run
:
|
mkdir -p sbom
cyclonedx-py environment /tmp/hmp-sbom \
--output-format JSON \
--outfile sbom/hydromodpy-sbom.cdx.json
-
uses
:
actions/upload-artifact@v4
with
:
name
:
sbom
path
:
sbom/
if-no-files-found
:
error
publish
:
name
:
Release / upload to PyPI
needs
:
build
runs-on
:
ubuntu-latest
timeout-minutes
:
10
environment
:
name
:
pypi
url
:
https://pypi.org/p/hydromodpy
permissions
:
id-token
:
write
steps
:
-
uses
:
actions/download-artifact@v4
with
:
name
:
dist
path
:
dist/
-
name
:
Publish to PyPI
uses
:
pypa/gh-action-pypi-publish@release/v1
release
:
name
:
Release / create GitHub release
needs
:
[publish, sbom]
runs-on
:
ubuntu-latest
timeout-minutes
:
5
permissions
:
contents
:
write
steps
:
-
uses
:
actions/checkout@v4
with
:
ref
:
${{ inputs.tag || github.ref }}
fetch-depth
:
0
-
uses
:
actions/download-artifact@v4
with
:
name
:
dist
path
:
dist/
-
uses
:
actions/download-artifact@v4
with
:
name
:
sbom
path
:
sbom/
-
name
:
Extract CHANGELOG section for tag
id
:
notes
run
:
|
tag="${{ inputs.tag || github.ref_name }}"
python - "$tag" <<'PY' > release_notes.md
import pathlib
import re
import sys
tag = sys.argv[1]
changelog = pathlib.Path("CHANGELOG.md").read_text(encoding="utf-8")
pattern = rf"^## \[{re.escape(tag)}\][^\n]*\n(.*?)(?=^## \[)"
match = re.search(pattern, changelog, re.DOTALL | re.MULTILINE)
if not match:
sys.stderr.write(f"No CHANGELOG section for {tag}\n")
sys.exit(1)
sys.stdout.write(match.group(1).strip() + "\n")
PY
-
name
:
Classify release tag
id
:
release-kind
run
:
|
tag="${{ inputs.tag || github.ref_name }}"
if [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(a|b|rc)[0-9]+$ ]]; then
echo "prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "prerelease=false" >> "$GITHUB_OUTPUT"
fi
-
name
:
Create release
uses
:
softprops/action-gh-release@v2
with
:
tag_name
:
${{ inputs.tag || github.ref_name }}
name
:
${{ inputs.tag || github.ref_name }}
body_path
:
release_notes.md
files
:
|
dist/*
sbom/*
fail_on_unmatched_files
:
true
draft
:
false
prerelease
:
${{ steps.release-kind.outputs.prerelease }}
Back
|
FazBrowse Home
|
New Git URL