-
Notifications
You must be signed in to change notification settings - Fork 0
199 lines (195 loc) · 7.39 KB
/
Copy pathcd.yml
File metadata and controls
199 lines (195 loc) · 7.39 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
on:
push:
branches: [main]
paths-ignore:
- '**.md'
- 'LICENSE*'
- '.git*'
- '.envrc'
- 'garnix.yaml'
- '.github/workflows/ci.yml'
tags: [v*]
workflow_dispatch:
jobs:
pwa:
if: github.ref == 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/v')
timeout-minutes: 15
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
contents: read
pages: write
id-token: write
steps:
- uses: actions/checkout@v6
with:
lfs: true
- uses: cachix/install-nix-action@v31
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
extra_nix_config: |
extra-substituters = https://cache.garnix.io
extra-trusted-public-keys = cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=
- uses: DeterminateSystems/magic-nix-cache-action@v13
- run: sleep 5 # Sleep hoping Garnix evaluation will start after
- uses: lewagon/wait-on-check-action@v1.5.0
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
check-regexp: 'Evaluate flake.nix'
repo-token: ${{ secrets.GITHUB_TOKEN }}
fail-on-no-checks: false
allowed-conclusions: success,failure,cancelled,skipped,timed_out,neutral
- uses: lewagon/wait-on-check-action@v1.5.0
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
check-regexp: 'package web.*'
repo-token: ${{ secrets.GITHUB_TOKEN }}
fail-on-no-checks: false
allowed-conclusions: success,failure,cancelled,skipped,timed_out,neutral
- run: nix build .#web -o dist
- uses: actions/upload-pages-artifact@v4
with: { path: ./dist/LogOut }
- uses: actions/deploy-pages@v4
id: deployment
android-release:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: write # Required by 'gh release'
checks: read # Required by wait-on-check-action
statuses: read # Required by wait-on-check-action
steps:
- uses: actions/checkout@v6
with:
lfs: true
- uses: cachix/install-nix-action@v31
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
extra_nix_config: |
extra-substituters = https://cache.garnix.io
extra-trusted-public-keys = cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=
- uses: DeterminateSystems/magic-nix-cache-action@v13
- run: sleep 5 # Sleep hoping Garnix evaluation will start after
- uses: lewagon/wait-on-check-action@v1.5.0
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
check-regexp: 'Evaluate flake.nix'
repo-token: ${{ secrets.GITHUB_TOKEN }}
fail-on-no-checks: false
allowed-conclusions: success,failure,cancelled,skipped,timed_out,neutral
- uses: lewagon/wait-on-check-action@v1.5.0
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
check-regexp: 'devShell.*linux.*'
repo-token: ${{ secrets.GITHUB_TOKEN }}
fail-on-no-checks: false
allowed-conclusions: success,failure,cancelled,skipped,timed_out,neutral
- uses: timheuer/base64-to-file@v1.2.4
with:
fileName: 'logout.jks'
encodedString: ${{ secrets.ANDROID_KEYSTORE_B64 }}
id: keystore
- run: nix run .#androidBuild
env:
ANDROID_KEYSTORE_PATH: ${{ steps.keystore.outputs.filePath }}
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
- name: Publish Semantically Versionned Release
run: |
TAG=${GITHUB_REF#refs/tags/}
gh release create "$TAG" *.apk --title "$TAG" --notes "Release $TAG"
env:
GH_TOKEN: ${{ github.token }}
check-tag:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
outputs:
is_tagged: ${{ steps.check.outputs.is_tagged }}
steps:
- uses: actions/checkout@v6
- id: check
run: |
if git describe --tags --exact-match HEAD >/dev/null 2>&1; then
echo "is_tagged=true" >> $GITHUB_OUTPUT
else
echo "is_tagged=false" >> $GITHUB_OUTPUT
fi
android-prerelease:
needs: check-tag
if: github.ref == 'refs/heads/main' && needs.check-tag.outputs.is_tagged == 'false'
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: write # Required by 'gh release'
checks: read # Required by wait-on-check-action
statuses: read # Required by wait-on-check-action
steps:
- uses: actions/checkout@v6
with:
lfs: true
- uses: cachix/install-nix-action@v31
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
extra_nix_config: |
extra-substituters = https://cache.garnix.io
extra-trusted-public-keys = cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=
- uses: DeterminateSystems/magic-nix-cache-action@v13
- run: sleep 5 # Sleep hoping Garnix evaluation will start after
- uses: lewagon/wait-on-check-action@v1.5.0
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
check-regexp: 'Evaluate flake.nix'
repo-token: ${{ secrets.GITHUB_TOKEN }}
fail-on-no-checks: false
allowed-conclusions: success,failure,cancelled,skipped,timed_out,neutral
- uses: lewagon/wait-on-check-action@v1.5.0
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
check-regexp: 'devShell.*linux.*'
repo-token: ${{ secrets.GITHUB_TOKEN }}
fail-on-no-checks: false
allowed-conclusions: success,failure,cancelled,skipped,timed_out,neutral
- uses: timheuer/base64-to-file@v1.2.4
with:
fileName: 'logout.jks'
encodedString: ${{ secrets.ANDROID_KEYSTORE_B64 }}
id: keystore
- run: nix run .#androidBuild
env:
ANDROID_KEYSTORE_PATH: ${{ steps.keystore.outputs.filePath }}
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
- name: Publish Timestamped Pre-release # If no SemVer tag on last commit
run: |
NOW=$(date -u +"%Y-%m-%d")
read -r OLD_TAG CREATED_AT <<< "$(gh release list \
--json tagName,createdAt,isPrerelease --limit 1 \
--jq '.[]|select(.isPrerelease == true)|"\(.tagName) \(.createdAt)"')"
if [ -z "$CREATED_AT" ] ||
[ "$(date -d "$CREATED_AT" +%s)" -le "$(date -d '2 days ago' +%s)" ]
then
gh release create "pre-$NOW" *.apk --prerelease \
--title "$NOW" --notes "Automated pre-release for $NOW"
fi
env:
GH_TOKEN: ${{ github.token }}
cleanup:
if: github.ref == 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/v')
timeout-minutes: 5
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- run: | # Cleanup rolling releases > 7 days or < 12 hours
gh release list --json tagName,createdAt,isPrerelease --limit 100 \
--jq '.[]|select(.isPrerelease == true)|"\(.tagName) \(.createdAt)"' \
| while read -r OLD_TAG CREATED_AT; do
TIMESTAMP=$(date -d "$CREATED_AT" +%s)
if [ "$TIMESTAMP" -lt "$(date -d '14 days ago' +%s)" ]; then
gh release delete "$OLD_TAG" --yes --cleanup-tag
fi
done
env:
GH_TOKEN: ${{ github.token }}