-
-
Notifications
You must be signed in to change notification settings - Fork 139
249 lines (240 loc) · 7.38 KB
/
release-and-publish.yml
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
name: Release and PyPI Publish
on:
push:
branches:
- main
jobs:
check_last_commit_author:
runs-on: ubuntu-latest
outputs:
skip_ci: ${{ steps.check_last_commit_author.outputs.skip_ci }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check last commit author
id: check_last_commit_author
run: |
LAST_COMMIT_AUTHOR=$(git log -1 --pretty=format:'%an')
if [ "$LAST_COMMIT_AUTHOR" = "OpenAdapt Bot" ]; then
echo "skip_ci=true" >> $GITHUB_OUTPUT
fi
build-macos-executables:
name: Build macOS app
runs-on: macos-latest
needs: check_last_commit_author
if: ${{ needs.check_last_commit_author.outputs.skip_ci != 'true' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install poetry
poetry install
brew install nvm
poetry run postinstall
brew install [email protected]
- name: Build MacOS executable
run: |
poetry run python -m openadapt.build
cd dist
zip -r ../OpenAdapt.app.zip OpenAdapt.app
mv OpenAdapt.dmg ..
cd ..
- name: Upload MacOS executable
uses: actions/upload-artifact@v4
with:
name: OpenAdapt.app
path: OpenAdapt.app.zip
- name: Upload MacOS installer
uses: actions/upload-artifact@v4
with:
name: OpenAdapt.dmg
path: OpenAdapt.dmg
build-windows-executables:
name: Build Windows app
runs-on: windows-latest
needs: check_last_commit_author
if: ${{ needs.check_last_commit_author.outputs.skip_ci != 'true' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 21
- name: Install dependencies
run: |
pip install poetry
poetry install
cd openadapt/app/dashboard
npm install
cd ../../../
pip install wheel
poetry run postinstall
- name: Build Windows executable
run: |
poetry run python -m openadapt.build
cd dist
7z a -tzip ../OpenAdapt.zip OpenAdapt
move OpenAdapt_Installer.exe ..
cd ..
- name: Upload Windows executable
uses: actions/upload-artifact@v4
with:
name: OpenAdapt
path: OpenAdapt.zip
- name: Upload Windows installer
uses: actions/upload-artifact@v4
with:
name: OpenAdapt_Installer
path: OpenAdapt_Installer.exe
test_on_macos:
name: Test on macOS
runs-on: macos-latest
needs: [build-macos-executables]
outputs:
macos_build_status: ${{ steps.test_on_macos.outputs.status }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download macOS executable
uses: actions/download-artifact@v4
with:
name: OpenAdapt.app
path: dist/
- name: Run app
id: test_on_macos
run: |
./build_scripts/test_app_run_macos.sh
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
echo "macos_build_status=failed" >> $GITHUB_OUTPUT
fi
test_on_windows:
name: Test on Windows
runs-on: windows-latest
needs: [build-windows-executables]
outputs:
windows_build_status: ${{ steps.test_on_windows.outputs.windows_build_status }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download Windows executable
uses: actions/download-artifact@v4
with:
name: OpenAdapt
path: dist/
- name: Run app
id: test_on_windows
shell: powershell
run: |
cmd.exe /c .\build_scripts\test_app_run_windows.bat
if ($LastExitCode -ne 0) {
"windows_build_status=failed" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
}
consolidate_tests:
name: Consolidate test results
runs-on: ubuntu-latest
needs: [test_on_windows, test_on_macos]
steps:
- name: Consolidate test results
id: consolidate_test_results
run: |
if [ "${{ needs.test_on_windows.outputs.windows_build_status }}" = "failed" ] || [ "${{ needs.test_on_macos.outputs.macos_build_status }}" = "failed" ]; then
echo "Error: Tests failed"
exit 1
fi
release:
runs-on: ubuntu-latest
needs: [consolidate_tests]
concurrency: release
permissions:
id-token: write
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.ADMIN_TOKEN }} # Use the new token for authentication
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install the latest version of the project
run: |
git pull
pip install poetry
poetry install
- name: Download macOS executable
uses: actions/download-artifact@v4
with:
name: OpenAdapt.app
path: dist/
- name: Download Windows executable
uses: actions/download-artifact@v4
with:
name: OpenAdapt
path: dist/
- name: Download macOS installer
uses: actions/download-artifact@v4
with:
name: OpenAdapt.dmg
path: dist/
- name: Download Windows installer
uses: actions/download-artifact@v4
with:
name: OpenAdapt_Installer
path: dist/
- name: Python Semantic Release
id: semantic_release
uses: python-semantic-release/[email protected]
with:
github_token: ${{ secrets.ADMIN_TOKEN }} # Use the new token for authentication
git_committer_name: "OpenAdapt Bot"
git_committer_email: "[email protected]"
- name: Upload release assets
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./build_scripts/upload_release_artifacts.sh
publish:
name: Publish to PyPI
needs: [release]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Publish to PyPI
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
pip install poetry
poetry install
poetry config pypi-token.pypi $PYPI_TOKEN
poetry build
poetry publish --no-interaction --skip-existing