|
15 | 15 | default: false |
16 | 16 | type: boolean |
17 | 17 | description: If a Pull Request has triggered it. |
| 18 | + is_trusted_pr: |
| 19 | + default: false |
| 20 | + type: boolean |
| 21 | + description: If a Pull Request is from the same repository, and not a forked one. |
18 | 22 | PR_NUMBER: |
19 | 23 | required: true |
20 | 24 | type: number |
|
24 | 28 | default: true |
25 | 29 | type: boolean |
26 | 30 | description: Skips Tagging & releases, since workflow_call isn't available for github.event_name, default is true |
| 31 | + secrets: |
| 32 | + KEYSTORE_CONTENT: |
| 33 | + required: true |
| 34 | + description: Base64 encoded keystore file content |
| 35 | + BUILD_JSON_CONTENT: |
| 36 | + required: true |
| 37 | + description: Base64 encoded build.json file content |
27 | 38 | outputs: |
28 | 39 | job_result: |
29 | 40 | description: "Build job result" |
|
57 | 68 | if: github.repository_owner == 'Acode-Foundation' |
58 | 69 |
|
59 | 70 | permissions: |
60 | | -# contents write is needed to create Nightly Releases. |
61 | | - contents: write |
62 | | -# issues: write |
63 | | - pull-requests: write |
| 71 | + pull-requests: read |
64 | 72 |
|
65 | | - outputs: |
66 | | - release_output_url: ${{ steps.release.outputs.url }} |
67 | | - updated_version: ${{ steps.update-version.outputs.UPDATED_VERSION}} |
68 | | - RELEASE_NOTES: ${{ env.RELEASE_NOTES }} |
| 73 | + outputs: |
| 74 | + updated_version: ${{ steps.update-version.outputs.UPDATED_VERSION}} |
| 75 | + NORMAL_APK_PATH: ${{ steps.update-version.outputs.NORMAL_APK_PATH }} |
| 76 | + FDROID_APK_PATH: ${{ steps.update-version.outputs.FDROID_APK_PATH }} |
| 77 | + tag_commit: ${{ steps.check-nightly-tag-force-update.outputs.tag_commit }} |
| 78 | + release_required: ${{ steps.check-nightly-tag-force-update.outputs.release_required }} |
69 | 79 | steps: |
70 | 80 | - name: Fast Fail if secrets are missing |
71 | 81 | if: ${{ env.KEYSTORE_CONTENT == '' || env.BUILD_JSON_CONTENT == '' }} |
|
118 | 128 | cache: ${{ (!(inputs.is_PR && inputs.PR_NUMBER) && github.ref == 'refs/heads/main' && 'npm') || '' }} |
119 | 129 |
|
120 | 130 | - name: Add keystore and build.json from secrets |
| 131 | + if: ${{ !inputs.is_PR || inputs.is_trusted_pr }} |
121 | 132 | run: | |
122 | 133 | echo "${{ secrets.KEYSTORE_CONTENT }}" | base64 -d > ${{ env.STORE_FILE_PATH }} |
123 | 134 | echo "${{ secrets.BUILD_JSON_CONTENT }}" | base64 -d > ${{ env.BUILD_JSON_PATH }} |
|
200 | 211 | path: ${{ env.FDROID_APK_PATH }} |
201 | 212 |
|
202 | 213 | - name: remove keystore and build.json |
| 214 | + if: ${{ !inputs.is_PR || inputs.is_trusted_pr }} |
203 | 215 | run: | |
204 | 216 | rm $STORE_FILE_PATH $BUILD_JSON_PATH |
205 | 217 | echo "Keystore and build.json removed successfully." |
206 | 218 | |
207 | | - - name: Check Nightly Tag and Force Update |
208 | | - #if: github.event_name == 'push' && contains(github.event.ref, 'tags/nightly') == false |
209 | | - if: ${{ ! inputs.skip_tagging_and_releases }} |
| 219 | + - name: Check Nightly Tag |
| 220 | + if: ${{ !inputs.skip_tagging_and_releases && !inputs.is_PR }} |
210 | 221 | id: check-nightly-tag-force-update |
211 | 222 | run: | |
212 | | - # Check if the nightly tag exists and get the commit it points to |
213 | 223 | if git show-ref --quiet refs/tags/nightly; then |
214 | 224 | TAG_COMMIT=$(git rev-parse nightly) |
215 | 225 | else |
216 | 226 | TAG_COMMIT="" |
217 | 227 | fi |
218 | | - |
219 | | - # If the current commit is the same as the tag, skip updating the tag |
| 228 | +
|
220 | 229 | if [ "$TAG_COMMIT" != "${{ env.GIT_COMMIT }}" ]; then |
221 | | - echo "releaseRequired=true" >> $GITHUB_ENV |
222 | | - # export tag commit before updating for change logs comparing. |
223 | | - echo "TAG_COMMIT=$TAG_COMMIT" >> $GITHUB_ENV |
224 | | - |
225 | | - git config --global user.name 'GitHub Actions' |
226 | | - git config --global user.email 'github-actions@github.com' |
227 | | - git tag -f nightly |
228 | | - git push origin nightly --force |
| 230 | + echo "release_required=true" >> "$GITHUB_OUTPUT" |
229 | 231 | else |
230 | | - echo "Nightly tag already points to this commit. Skipping update." |
| 232 | + echo "release_required=false" >> "$GITHUB_OUTPUT" |
231 | 233 | fi |
| 234 | + echo "tag_commit=$TAG_COMMIT" >> "$GITHUB_OUTPUT" |
| 235 | + |
| 236 | + release: |
| 237 | + needs: build |
| 238 | + runs-on: ubuntu-latest |
| 239 | + if: ${{ github.repository_owner == 'Acode-Foundation' && !inputs.is_PR && !inputs.skip_tagging_and_releases && needs.build.outputs.release_required == 'true' }} |
| 240 | + permissions: |
| 241 | + contents: write |
| 242 | + |
| 243 | + outputs: |
| 244 | + release_output_url: ${{ steps.release.outputs.url }} |
| 245 | + RELEASE_NOTES: ${{ env.RELEASE_NOTES }} |
| 246 | + steps: |
| 247 | + - name: Checkout Repository |
| 248 | + uses: actions/checkout@v7 |
| 249 | + with: |
| 250 | + fetch-depth: 0 |
| 251 | + persist-credentials: true |
232 | 252 |
|
| 253 | + - name: Force-update nightly tag |
| 254 | + run: | |
| 255 | + git config --global user.name 'GitHub Actions' |
| 256 | + git config --global user.email 'github-actions@github.com' |
| 257 | + git tag -f nightly "${{ github.sha }}" |
| 258 | + git push origin nightly --force |
| 259 | +
|
| 260 | + - name: Download APK artifacts |
| 261 | + uses: actions/download-artifact@v7 |
| 262 | + with: |
| 263 | + path: /tmp/artifacts |
| 264 | + |
233 | 265 | # 🚨⚠️ WARNING: the GITHUB_TOKEN under this step, has access to write & read access to Contents, Pull Requests |
234 | 266 | # Which is why, it uses a fine-granted token with Read-Only Access to Public Repos Only. |
235 | 267 | - name: Generate Release Notes (Experimental) |
236 | | - if: ${{ success() && env.releaseRequired == 'true' }} |
237 | 268 | id: gen-release-notes |
238 | 269 | continue-on-error: true |
239 | 270 | run: | |
240 | | - RELEASE_NOTES=$(node utils/scripts/generate-release-notes.js ${{ github.repository_owner }} Acode ${{ github.sha }} --format md --from-tag ${{ env.TAG_COMMIT }} --important-only --quiet --changelog-only) |
241 | | - { |
242 | | - echo "RELEASE_NOTES<<EOF" |
243 | | - echo "$RELEASE_NOTES" |
244 | | - echo "EOF" |
245 | | - } >> $GITHUB_ENV |
246 | | - env: |
| 271 | + RELEASE_NOTES=$(node utils/scripts/generate-release-notes.js ${{ github.repository_owner }} Acode ${{ github.sha }} --format md --from-tag ${{ needs.build.outputs.tag_commit }} --important-only --quiet --changelog-only || true) |
| 272 | + { |
| 273 | + echo "RELEASE_NOTES<<EOF" |
| 274 | + echo "$RELEASE_NOTES" |
| 275 | + echo "EOF" |
| 276 | + } >> $GITHUB_ENV |
| 277 | + env: |
247 | 278 | GITHUB_TOKEN: ${{ secrets.NIGHTLY_RELEASE_NOTES_GH_TOKEN }} |
| 279 | + |
248 | 280 | - name: Release Nightly Version |
249 | | -# Only run this step, if not called from another workflow. And a previous step is successful with releasedRequired=true |
250 | | - id: release |
251 | | - if: ${{ ! inputs.skip_tagging_and_releases && steps.check-nightly-tag-force-update.outcome == 'success' && env.releaseRequired == 'true' && !inputs.is_PR }} |
252 | 281 | uses: softprops/action-gh-release@v3 |
253 | 282 | env: |
254 | 283 | FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true |
255 | 284 | with: |
256 | 285 | prerelease: true |
257 | | - name: ${{ env.UPDATED_VERSION }} |
258 | | - tag_name: ${{ env.UPDATED_VERSION }} |
| 286 | + name: ${{ needs.build.outputs.updated_version }} |
| 287 | + tag_name: ${{ needs.build.outputs.updated_version }} |
259 | 288 | files: | |
260 | | - ${{ env.NORMAL_APK_PATH }} |
261 | | - ${{ env.FDROID_APK_PATH }} |
| 289 | + /tmp/artifacts/**/acode-debug-normal-*.apk |
| 290 | + /tmp/artifacts/**/acode-debug-fdroid-*.apk |
262 | 291 | body: | |
263 | 292 | Automated Nightly (pre-release) Releases for Today |
264 | | - |
265 | | - [Compare Changes](https://github.com/${{ github.repository }}/compare/${{ env.TAG_COMMIT }}...${{ github.sha }}) |
266 | 293 |
|
267 | | - ${{ env.RELEASE_NOTES }} |
| 294 | + [Compare Changes](https://github.com/${{ github.repository }}/compare/${{ needs.build.outputs.tag_commit }}...${{ github.sha }}) |
268 | 295 |
|
269 | | - - name: Update Last Comment by bot (If ran in PR) |
270 | | - if: inputs.is_PR |
271 | | - uses: marocchino/sticky-pull-request-comment@v3 |
272 | | - with: |
273 | | - hide_and_recreate: true |
274 | | - hide_classify: "OUTDATED" |
275 | | - header: on-demand-build-status |
276 | | - message: | |
277 | | - Preview Release for this, has been built. |
278 | | - |
279 | | - [Click here to view that github actions build](https://github.com/${{ github.repository}}/actions/runs/${{ github.run_id }}) |
280 | | - |
| 296 | + ${{ env.RELEASE_NOTES }} |
281 | 297 |
|
282 | 298 | community-release-notifier: |
283 | | - needs: build |
| 299 | + needs: [build, release] |
284 | 300 | # Run only if push tags, or triggered by a schedule |
285 | | - if: ${{ github.repository_owner == 'Acode-Foundation' && (contains(fromJSON('["push", "schedule"]'), github.event_name) || ! inputs.skip_tagging_and_releases) && needs.build.outputs.release_output_url }} |
| 301 | + if: ${{ github.repository_owner == 'Acode-Foundation' && (contains(fromJSON('["push", "schedule"]'), github.event_name) || ! inputs.skip_tagging_and_releases) && needs.release.outputs.release_output_url }} |
286 | 302 | uses: Acode-Foundation/acode/.github/workflows/community-release-notifier.yml@main |
287 | 303 | with: |
288 | 304 | tag_name: ${{ needs.build.outputs.updated_version }} |
289 | | - url: ${{ needs.build.outputs.release_output_url }} |
290 | | - body: ${{ needs.build.outputs.RELEASE_NOTES }} |
| 305 | + url: ${{ needs.release.outputs.release_output_url }} |
| 306 | + body: ${{ needs.release.outputs.RELEASE_NOTES }} |
291 | 307 | secrets: |
292 | 308 | DISCORD_WEBHOOK_RELEASE_NOTES: ${{ secrets.DISCORD_WEBHOOK_RELEASE_NOTES }} |
293 | 309 | TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} |
|
0 commit comments