-
Notifications
You must be signed in to change notification settings - Fork 1.3k
228 lines (200 loc) · 8.57 KB
/
Copy pathnightly-release.yml
File metadata and controls
228 lines (200 loc) · 8.57 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
225
226
227
228
name: Nightly Release
on:
schedule:
# Fire every day at 7:00am UTC (Roughly before EU workday and after US workday)
- cron: "0 7 * * *"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
build:
if: ${{ github.repository_owner == 'Acode-Foundation' }}
uses: Acode-Foundation/acode/.github/workflows/nightly-build.yml@main
permissions:
contents: read
pull-requests: read
secrets:
KEYSTORE_CONTENT: ${{ secrets.KEYSTORE_CONTENT }}
BUILD_JSON_CONTENT: ${{ secrets.BUILD_JSON_CONTENT }}
with:
is_PR: false
is_trusted_pr: false
release:
needs: build
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'Acode-Foundation' && needs.build.result == 'success' }}
permissions:
contents: write
id-token: write
outputs:
should_publish: ${{ steps.publish_gate.outputs.should_publish }}
release_output_url: ${{ steps.gh_release.outputs.url }}
release_notes: ${{ env.RELEASE_NOTES }}
previous_tag_commit: ${{ steps.prev.outputs.tag_commit }}
nightly_tag_name: ${{ needs.build.outputs.updated_version }}
subjects_file: ${{ steps.subjects_file.outputs.handle }}
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0 # Required for tags
persist-credentials: true
- name: Install cosign
uses: sigstore/cosign-installer@v4.1.2
- name: Set Publish Metadata
shell: bash
run: |
set -euo pipefail
echo "ARTIFACTS_DIR=${{ env.ARTIFACTS_DIR}}" >> $GITHUB_ENV
echo "NORMAL_ARTIFACT_NAME=app-debug-${{ github.sha }}" >> $GITHUB_ENV
echo "FDROID_ARTIFACT_NAME=app-debug-fdroid-${{ github.sha }}" >> $GITHUB_ENV
echo "SUBJECTS_FILE=${{ env.SUBJECTS_FILE }}" >> $GITHUB_ENV
env:
ARTIFACTS_DIR: ${{ runner.temp }}/artifacts
SUBJECTS_FILE: ${{ runner.temp }}/slsa-subjects.txt
- name: Download normal APK artifact
uses: actions/download-artifact@v8
with:
name: ${{ needs.build.outputs.normal_artifact_name }}
path: ${{ env.ARTIFACTS_DIR }}/normal
- name: Download fdroid APK artifact
uses: actions/download-artifact@v8
with:
name: ${{ needs.build.outputs.fdroid_artifact_name }}
path: ${{ env.ARTIFACTS_DIR }}/fdroid
- name: Resolve previous nightly tag commit
id: prev
shell: bash
run: |
set -euo pipefail
VERSION_TAG="${{ needs.build.outputs.updated_version }}"
FALLBACK_TAG="nightly"
git fetch --tags --force
if git show-ref --quiet "refs/tags/${VERSION_TAG}"; then
echo "tag_exists=true" >> "$GITHUB_OUTPUT"
echo "tag_commit=$(git rev-parse "${VERSION_TAG}")" >> "$GITHUB_OUTPUT"
elif git show-ref --quiet "refs/tags/${FALLBACK_TAG}"; then
echo "tag_exists=true" >> "$GITHUB_OUTPUT"
echo "tag_commit=$(git rev-parse "${FALLBACK_TAG}")" >> "$GITHUB_OUTPUT"
else
echo "tag_exists=false" >> "$GITHUB_OUTPUT"
echo "tag_commit=" >> "$GITHUB_OUTPUT"
fi
- name: Decide whether to publish
id: publish_gate
shell: bash
run: |
set -euo pipefail
if [[ "${{ steps.prev.outputs.tag_exists }}" != "true" || "${{ steps.prev.outputs.tag_commit }}" != "${GITHUB_SHA}" ]]; then
echo "should_publish=true" >> "$GITHUB_OUTPUT"
else
echo "should_publish=false" >> "$GITHUB_OUTPUT"
fi
- name: Build SLSA subjects file
if: steps.publish_gate.outputs.should_publish == 'true'
shell: bash
run: |
set -euo pipefail
find ${{ env.ARTIFACTS_DIR }} -type f -name '*.apk' -print0 | sort -z | while IFS= read -r -d '' f; do
sha256sum "$f"
done | base64 -w0 > "${SUBJECTS_FILE}"
test -s "${SUBJECTS_FILE}" || { echo "No subjects found"; exit 1; }
env:
ARTIFACTS_DIR: ${{ env.ARTIFACTS_DIR }}
SUBJECTS_FILE: ${{ env.SUBJECTS_FILE }}
- name: Generate per-APK sha256 files
shell: bash
run: |
set -euo pipefail
find ${{ env.ARTIFACTS_DIR }} -type f -name '*.apk' -print0 | while IFS= read -r -d '' f; do
sha256sum "$f" > "${f}.sha256"
done
- name: Create subjects file handle
id: subjects_file
if: steps.publish_gate.outputs.should_publish == 'true'
uses: slsa-framework/slsa-github-generator/actions/generator/generic/create-base64-subjects-from-file@v2.1.0
with:
path: ${{ env.SUBJECTS_FILE }}
- name: Move nightly tag
if: steps.publish_gate.outputs.should_publish == 'true'
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email 'github-actions@github.com'
git tag -f nightly "${GITHUB_SHA}"
git push origin refs/tags/nightly --force
- name: Generate release notes
if: steps.publish_gate.outputs.should_publish == 'true'
id: notes
continue-on-error: true
run: |
RELEASE_NOTES="$(node utils/scripts/generate-release-notes.js \
${{ github.repository_owner }} Acode ${{ github.sha }} \
--format md --from-tag ${{ steps.prev.outputs.tag_commit }} --important-only --quiet --changelog-only || true)"
{
echo "RELEASE_NOTES<<EOF"
echo "$RELEASE_NOTES"
echo "EOF"
} >> "$GITHUB_ENV"
env:
GITHUB_TOKEN: ${{ secrets.NIGHTLY_RELEASE_NOTES_GH_TOKEN }}
- name: Create nightly prerelease
if: steps.publish_gate.outputs.should_publish == 'true'
id: gh_release
uses: softprops/action-gh-release@v3
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
with:
prerelease: true
tag_name: ${{ needs.build.outputs.updated_version }}
name: ${{ needs.build.outputs.updated_version }}
files: |
${{ env.ARTIFACTS_DIR }}/normal/*.apk
${{ env.ARTIFACTS_DIR }}/normal/*.apk.sha256
${{ env.ARTIFACTS_DIR }}/fdroid/*.apk
${{ env.ARTIFACTS_DIR }}/fdroid/*.apk.sha256
body: |
Automated Nightly pre-release
[Compare Changes](https://github.com/${{ github.repository }}/compare/${{ steps.prev.outputs.tag_commit }}...${{ github.sha }})
${{ env.RELEASE_NOTES }}
- name: Post Job summary
if: always()
run: |
echo "| Variable | Value |" >> "$GITHUB_STEP_SUMMARY"
echo "| --- | --- |" >> "$GITHUB_STEP_SUMMARY"
echo "| should_publish | ${{ steps.publish_gate.outputs.should_publish == 'true' && 'true' || 'false' }} |" >> "$GITHUB_STEP_SUMMARY"
echo "| (pre-release versioned/nightly tag) tag_exists | ${{ steps.prev.outputs.tag_exists }} |" >> "$GITHUB_STEP_SUMMARY"
echo "| (pre-release versioned/nightly tag) tag_commit | ${{ steps.prev.outputs.tag_commit }} |" >> "$GITHUB_STEP_SUMMARY"
echo "| release_output_url | ${{ steps.gh_release.outputs.url || 'N/A' }} |" >> "$GITHUB_STEP_SUMMARY"
provenance:
name: Generate SLSA provenance
needs: [release]
if: needs.release.outputs.should_publish == 'true'
permissions:
actions: read
id-token: write
contents: write
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.1.0
with:
base64-subjects-as-file: "${{ needs.release.outputs.subjects_file }}"
upload-assets: true
upload-tag-name: "${{ needs.release.outputs.nightly_tag_name }}"
draft-release: false
community-release-notifier:
name: Notify community of nightly release
needs: [release]
if: ${{ needs.release.outputs.should_publish == 'true' && needs.release.outputs.release_output_url }}
permissions:
contents: read
uses: Acode-Foundation/acode/.github/workflows/community-release-notifier.yml@main
with:
url: ${{ needs.release.outputs.release_output_url }}
tag_name: ${{ needs.release.outputs.nightly_tag_name }}
body: ${{ needs.release.outputs.release_notes }}
secrets:
DISCORD_WEBHOOK_RELEASE_NOTES: ${{ secrets.DISCORD_WEBHOOK_RELEASE_NOTES }}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
TELEGRAM_MESSAGE_THREAD_ID: ${{ secrets.TELEGRAM_MESSAGE_THREAD_ID }}