-
Notifications
You must be signed in to change notification settings - Fork 9
224 lines (187 loc) · 6.09 KB
/
release.yaml
File metadata and controls
224 lines (187 loc) · 6.09 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
name: Release
on:
push:
tags:
- v*.*.*
env:
PYTHON_VERSION: "3.11"
PREPARATION_COMMIT: '[ci] prepare release ${{ github.ref_name }}'
jobs:
check-preparation:
name: Check if release is prepared
runs-on: ubuntu-24.04
outputs:
prepared: ${{ steps.validate.outputs.prepared }}
steps:
- uses: actions/checkout@v5
- name: Validate commit message
id: validate
run: |
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
echo "Expected: '${{ env.PREPARATION_COMMIT }}'"
echo "Received: '$COMMIT_MESSAGE'"
prepared="false"
if [[ "$COMMIT_MESSAGE" == "${{ env.PREPARATION_COMMIT }}" ]]; then
prepared="true"
fi
echo "prepared=$prepared" >> $GITHUB_OUTPUT
prepare-release:
name: Prepare release
needs: [check-preparation]
if: needs.check-preparation.outputs.prepared == 'false'
runs-on: ubuntu-24.04
steps:
- name: Generate token for Release Bot
id: generate-token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ vars.RELEASE_BOT_APP_ID }}
private-key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }}
- uses: actions/checkout@v5
with:
fetch-depth: 0
ref: main
token: ${{ steps.generate-token.outputs.token }}
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Update CITATION.cff
run: |
VERSION=${GITHUB_REF#refs/tags/v}
DATE=$(date +%Y-%m-%d)
sed -i "s/^version: .*/version: $VERSION/" CITATION.cff
sed -i "s/^date-released: .*/date-released: $DATE/" CITATION.cff
- name: Remove previous tag
run: |
git tag -d ${{ github.ref_name }}
git push origin --delete ${{ github.ref_name }}
- name: Commit and re-tag
run: |
git add CITATION.cff
git commit -m "${{ env.PREPARATION_COMMIT }}"
git push origin main
git tag -a ${{ github.ref_name }} -m "${{ github.ref_name }}"
git push origin ${{ github.ref_name }}
test:
name: Run tests
needs: [check-preparation]
if: needs.check-preparation.outputs.prepared == 'true'
uses: ./.github/workflows/tests.yaml
build:
name: Build package
needs: [check-preparation, test]
if: needs.check-preparation.outputs.prepared == 'true'
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
- uses: astral-sh/setup-uv@v6
with:
version: "0.9.10"
enable-cache: true
- uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Build package
run: uv build
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
retention-days: 7
publish-pypi:
name: Publish to PyPI
needs: [build]
runs-on: ubuntu-24.04
environment:
name: pypi
url: https://pypi.org/p/flixopt
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
with:
skip-existing: true
verify-pypi:
name: Verify PyPI installation
needs: [publish-pypi]
runs-on: ubuntu-24.04
steps:
- uses: astral-sh/setup-uv@v6
with:
version: "0.9.10"
- uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Verify installation
run: |
VERSION=${GITHUB_REF#refs/tags/v}
for delay in 10 20 40 60 90 120 180 300; do
sleep $delay
echo "Attempting installation (waited ${delay}s)..."
if uv pip install --system --index-url https://pypi.org/simple/ "flixopt==$VERSION" && \
python -c "from importlib.metadata import version; assert version('flixopt') == '$VERSION'"; then
echo "PyPI installation successful!"
exit 0
fi
done
echo "Failed to verify PyPI installation"
exit 1
create-release:
name: Create GitHub release
needs: [verify-pypi]
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Extract release notes
run: |
VERSION=${GITHUB_REF#refs/tags/v}
python scripts/extract_release_notes.py $VERSION > current_release_notes.md
- uses: softprops/action-gh-release@v2
with:
body_path: current_release_notes.md
draft: false
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
generate_release_notes: true
deploy-docs:
name: Deploy documentation
needs: [create-release]
if: "!contains(github.ref, 'alpha') && !contains(github.ref, 'beta') && !contains(github.ref, 'rc')"
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@v6
with:
version: "0.9.10"
- uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Extract changelog
run: |
uv pip install --system packaging
python scripts/extract_changelog.py
- name: Install docs dependencies
run: uv pip install --system ".[docs]"
- name: Configure Git
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- name: Deploy docs
run: |
VERSION=${GITHUB_REF#refs/tags/v}
mike deploy --push --update-aliases $VERSION latest
mike set-default --push latest