Repository navigation
197 lines (189 loc) · 6.02 KB
/
Copy pathrelease.yml
File metadata and controls
197 lines (189 loc) · 6.02 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
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
---
name: Release
# yamllint disable-line rule:truthy
on:
push:
branches:
- main
permissions: {}
jobs:
version-check:
runs-on: ubuntu-slim
timeout-minutes: 5
permissions:
contents: read
outputs:
CHANGED: ${{ steps.check.outputs.CHANGED }}
VERSION: ${{ steps.check.outputs.VERSION }}
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Setup UV
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
- name: Detect version change
id: check
run: |
VERSION="$(uv version --short)"
if git rev-parse "refs/tags/v${VERSION}" > /dev/null 2>&1 ; then
CHANGED=false
else
CHANGED=true
fi
{
echo "VERSION=${VERSION}"
echo "CHANGED=${CHANGED}"
} >> "$GITHUB_OUTPUT"
build:
runs-on: ubuntu-slim
timeout-minutes: 5
permissions:
contents: read
needs:
- version-check
if: needs.version-check.outputs.CHANGED == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup UV
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
- name: Build wheel and source package
run: uv build
- name: Build documentation
run: uv run mkdocs build
- name: Create release notes
run: |
awk -v "VER=${VERSION}" -v "DATE=$(date '+%Y-%m-%d')" '
BEGIN {
gsub(/\./, "\\.", VER);
pattern = "^## " VER " - " DATE "$";
}
{
if ($0 ~ pattern) {
flag = 1;
next;
}
if (flag == 1) {
if (/^#[#] /) exit;
print;
}
}
' CHANGELOG.md > RELEASE_NOTES.md
if [ -z "$(tr -d '[:space:]' < RELEASE_NOTES.md)" ]; then
echo "::error::Empty release notes for version ${VERSION} in CHANGELOG.md" 1>&2
exit 1
fi
env:
VERSION: ${{ needs.version-check.outputs.VERSION }}
- name: Build RPM spec file
run: uv run python rpmbuild/generate_spec.py
- name: Store build artifacts
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: build-outputs
path: |
dist/
site/
rpmbuild/python-arcticsecurity.spec
RELEASE_NOTES.md
if-no-files-found: error
retention-days: 1
rpmbuild:
needs:
- version-check
- build
if: needs.version-check.outputs.CHANGED == 'true'
uses: $/.github/workflows/rpmbuild.yml
with:
build-artifact-name: build-outputs
github-release:
runs-on: ubuntu-slim
timeout-minutes: 5
permissions:
contents: write
needs:
- version-check
- build
- rpmbuild
if: needs.version-check.outputs.CHANGED == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Download build artifacts
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: build-outputs
path: .
- name: Download source RPM artifact
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: python-arcticsecurity-${{ needs.version-check.outputs.VERSION }}-1.el10.src.rpm
path: dist/
- name: Download binary RPM artifact
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: python3-arcticsecurity-${{ needs.version-check.outputs.VERSION }}-1.el10.noarch.rpm
path: dist/
- name: Create GitHub release
run: gh release create "$TAG" dist/* --notes-file RELEASE_NOTES.md --title "$TAG"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: v${{ needs.version-check.outputs.VERSION }}
publish-pypi:
runs-on: ubuntu-slim
timeout-minutes: 5
environment: release
permissions:
id-token: write
needs:
- version-check
- build
- github-release
if: needs.version-check.outputs.CHANGED == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup UV
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
- name: Download build artifacts
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: build-outputs
path: .
- name: Publish to PyPI
run: uv publish
publish-docs:
runs-on: ubuntu-slim
timeout-minutes: 5
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
pages: write
id-token: write
needs:
- version-check
- build
- github-release
if: needs.version-check.outputs.CHANGED == 'true'
steps:
- name: Download build artifacts
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: build-outputs
path: .
- name: Upload artifact
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: ./site
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1