-
Notifications
You must be signed in to change notification settings - Fork 23
258 lines (252 loc) · 8.36 KB
/
on_push.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
250
251
252
253
254
255
256
257
258
name: Release
on:
pull_request:
types: [opened, reopened, ready_for_review, synchronize]
push:
branches: [main, release]
tags-ignore: "**"
jobs:
test:
name: Tests and Build
runs-on: macos-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Install xcodegen via Homebrew for linting and building xcode project
run: brew install xcodegen
-
name: Generate project
run: xcodegen
-
name: Build app to run linters
run: xcodebuild -scheme WakaTime
version:
name: Version
concurrency: tagging
if: ${{ github.ref == 'refs/heads/release' || github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
needs: [test]
outputs:
semver: ${{ steps.format.outputs.semver }}
semver_tag: ${{ steps.semver-tag.outputs.semver_tag }}
ancestor_tag: ${{ steps.semver-tag.outputs.ancestor_tag }}
is_prerelease: ${{ steps.semver-tag.outputs.is_prerelease }}
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: Calculate semver tag
id: semver-tag
uses: wakatime/semver-action@master
with:
prefix: v
prerelease_id: alpha
develop_branch_name: main
main_branch_name: release
-
name: Format
id: format
run: |
echo "${{ steps.semver-tag.outputs.semver_tag }}"
ver=`echo "${{ steps.semver-tag.outputs.semver_tag }}" | sed 's/^v//'`
echo "$ver"
echo "semver=$ver" >> $GITHUB_OUTPUT
-
name: Create tag
uses: actions/github-script@v6
with:
github-token: ${{ github.token }}
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ steps.semver-tag.outputs.semver_tag }}",
sha: context.sha
})
sign:
name: Sign Apple app
needs: [version]
runs-on: macos-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Update project.yml
uses: fjogeleit/yaml-update-action@main
with:
valueFile: 'project.yml'
changes: |
{
"targets.WakaTime.settings.CURRENT_PROJECT_VERSION": "${{ needs.version.outputs.semver }}",
"targets.WakaTime.settings.MARKETING_VERSION": "${{ needs.version.outputs.semver }}"
}
commitChange: false
-
name: Install xcodegen via Homebrew for linting and building xcode project
run: brew install xcodegen
-
name: Generate project
run: xcodegen
-
name: Build app
id: build
run: |
xcodebuild -scheme WakaTime -configuration Release
app=`find /Users/runner/Library/Developer/Xcode/DerivedData/ -name WakaTime.app`
echo "$app"
directory=`dirname $app`
echo "$directory"
echo "directory=$directory" >> $GITHUB_OUTPUT
-
name: Import Code-Signing Certificates
uses: Apple-Actions/import-codesign-certs@v1
with:
# The certificates in a PKCS12 file encoded as a base64 string
p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }}
# The password used to import the PKCS12 file.
p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }}
-
name: Codesign
run: |
codesign -v --force --deep --timestamp -s "WakaTime" --options runtime ${{ steps.build.outputs.directory }}/WakaTime.app
-
name: Store Credentials
env:
NOTARIZATION_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
NOTARIZATION_APPLE_ID: ${{ secrets.AC_USERNAME }}
NOTARIZATION_PWD: ${{ secrets.AC_PASSWORD }}
run: xcrun notarytool store-credentials "notarytool-profile" --apple-id "$NOTARIZATION_APPLE_ID" --team-id "$NOTARIZATION_TEAM_ID" --password "$NOTARIZATION_PWD"
-
name: Notarize Helper
run: |
ditto -c -k --keepParent "${{ steps.build.outputs.directory }}/WakaTime.app/Contents/Library/LoginItems/WakaTime Helper.app" helper.zip
xcrun notarytool submit helper.zip --keychain-profile "notarytool-profile" --wait
xcrun stapler staple "${{ steps.build.outputs.directory }}/WakaTime.app/Contents/Library/LoginItems/WakaTime Helper.app"
-
name: Notarize App
run: |
ditto -c -k --keepParent ${{ steps.build.outputs.directory }}/WakaTime.app main.zip
xcrun notarytool submit main.zip --keychain-profile "notarytool-profile" --wait
xcrun stapler staple ${{ steps.build.outputs.directory }}/WakaTime.app
-
name: Zip
run: ditto -c -k --sequesterRsrc --keepParent ${{ steps.build.outputs.directory }}/WakaTime.app WakaTime.zip
-
name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: app
path: ./WakaTime.zip
-
name: Remove tag if failure
if: ${{ failure() }}
uses: actions/github-script@v6
with:
github-token: ${{ github.token }}
script: |
github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "tags/${{ needs.version.outputs.semver_tag }}"
})
changelog:
name: Changelog
runs-on: ubuntu-latest
needs: [version, sign]
outputs:
changelog: ${{ steps.changelog.outputs.changelog }}
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
-
if: ${{ github.ref == 'refs/heads/main' }}
name: Changelog for main
uses: gandarez/[email protected]
id: changelog-main
with:
current_tag: ${{ github.sha }}
previous_tag: ${{ needs.version.outputs.ancestor_tag }}
exclude: |
^Merge pull request .*
-
if: ${{ github.ref == 'refs/heads/release' }}
name: Get related pull request
uses: 8BitJonny/[email protected]
id: changelog-release
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
-
name: Prepare changelog
id: changelog
run: |
echo "${{ steps.changelog-main.outputs.changelog || steps.changelog-release.outputs.pr_body }}" > changelog.txt
./bin/prepare_changelog.sh $(echo ${GITHUB_REF#refs/heads/}) "$(cat changelog.txt)"
-
name: Remove tag if failure
if: ${{ failure() }}
uses: actions/github-script@v6
with:
github-token: ${{ github.token }}
script: |
github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "tags/${{ needs.version.outputs.semver_tag }}"
})
release:
name: Release
runs-on: macos-latest
needs: [version, sign, changelog]
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: Download artifacts
uses: actions/download-artifact@v3
with:
name: app
path: ./
-
name: Prepare release folder
id: prepare
run: |
mkdir release
mv ./WakaTime.zip release/macos-wakatime.zip
-
name: "Create release"
uses: softprops/action-gh-release@master
with:
name: ${{ needs.version.outputs.semver_tag }}
tag_name: ${{ needs.version.outputs.semver_tag }}
body: "## Changelog\n${{ needs.changelog.outputs.changelog }}"
prerelease: ${{ needs.version.outputs.is_prerelease }}
target_commitish: ${{ github.sha }}
draft: false
files: |
./release/macos-wakatime.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Remove tag if failure
if: ${{ failure() }}
uses: actions/github-script@v6
with:
github-token: ${{ github.token }}
script: |
github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "tags/${{ needs.version.outputs.semver_tag }}"
})