-
-
Notifications
You must be signed in to change notification settings - Fork 164
164 lines (158 loc) · 4.91 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
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@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install poetry
poetry install
brew install nvm
poetry run install-dashboard
brew install [email protected]
- name: Build executables
run: |
poetry run python -m openadapt.build
cd dist
zip -r ../OpenAdapt.app.zip OpenAdapt.app
cd ..
- name: Upload executables
uses: actions/upload-artifact@v4
with:
name: OpenAdapt.app
path: OpenAdapt.app.zip
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@v4
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 ../../../
- name: Build executables
run: |
poetry run python -m openadapt.build
cd dist
7z a -tzip ../OpenAdapt.zip OpenAdapt
cd ..
- name: Upload executables
uses: actions/upload-artifact@v4
with:
name: OpenAdapt
path: OpenAdapt.zip
release:
runs-on: ubuntu-latest
needs: [check_last_commit_author, build-macos-executables, build-windows-executables]
if: ${{ needs.check_last_commit_author.outputs.skip_ci != 'true' }}
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@v4
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: 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: [check_last_commit_author, release]
if: ${{ needs.check_last_commit_author.outputs.skip_ci != 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
- name: Set up Python
uses: actions/setup-python@v4
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