Skip to content

Commit b4c7d75

Browse files
authored
Merge branch 'Acode-Foundation:main' into feat/new-strings
2 parents 7c7299d + b7ff0dc commit b4c7d75

2 files changed

Lines changed: 93 additions & 68 deletions

File tree

‎.github/workflows/nightly-build.yml‎

Lines changed: 73 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
default: false
1616
type: boolean
1717
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.
1822
PR_NUMBER:
1923
required: true
2024
type: number
@@ -24,6 +28,13 @@
2428
default: true
2529
type: boolean
2630
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
2738
outputs:
2839
job_result:
2940
description: "Build job result"
@@ -57,15 +68,14 @@
5768
if: github.repository_owner == 'Acode-Foundation'
5869

5970
permissions:
60-
# contents write is needed to create Nightly Releases.
61-
contents: write
62-
# issues: write
63-
pull-requests: write
71+
pull-requests: read
6472

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 }}
6979
steps:
7080
- name: Fast Fail if secrets are missing
7181
if: ${{ env.KEYSTORE_CONTENT == '' || env.BUILD_JSON_CONTENT == '' }}
@@ -118,6 +128,7 @@
118128
cache: ${{ (!(inputs.is_PR && inputs.PR_NUMBER) && github.ref == 'refs/heads/main' && 'npm') || '' }}
119129

120130
- name: Add keystore and build.json from secrets
131+
if: ${{ !inputs.is_PR || inputs.is_trusted_pr }}
121132
run: |
122133
echo "${{ secrets.KEYSTORE_CONTENT }}" | base64 -d > ${{ env.STORE_FILE_PATH }}
123134
echo "${{ secrets.BUILD_JSON_CONTENT }}" | base64 -d > ${{ env.BUILD_JSON_PATH }}
@@ -200,94 +211,99 @@
200211
path: ${{ env.FDROID_APK_PATH }}
201212

202213
- name: remove keystore and build.json
214+
if: ${{ !inputs.is_PR || inputs.is_trusted_pr }}
203215
run: |
204216
rm $STORE_FILE_PATH $BUILD_JSON_PATH
205217
echo "Keystore and build.json removed successfully."
206218
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 }}
210221
id: check-nightly-tag-force-update
211222
run: |
212-
# Check if the nightly tag exists and get the commit it points to
213223
if git show-ref --quiet refs/tags/nightly; then
214224
TAG_COMMIT=$(git rev-parse nightly)
215225
else
216226
TAG_COMMIT=""
217227
fi
218-
219-
# If the current commit is the same as the tag, skip updating the tag
228+
220229
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"
229231
else
230-
echo "Nightly tag already points to this commit. Skipping update."
232+
echo "release_required=false" >> "$GITHUB_OUTPUT"
231233
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
232252

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+
233265
# 🚨⚠️ WARNING: the GITHUB_TOKEN under this step, has access to write & read access to Contents, Pull Requests
234266
# Which is why, it uses a fine-granted token with Read-Only Access to Public Repos Only.
235267
- name: Generate Release Notes (Experimental)
236-
if: ${{ success() && env.releaseRequired == 'true' }}
237268
id: gen-release-notes
238269
continue-on-error: true
239270
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:
247278
GITHUB_TOKEN: ${{ secrets.NIGHTLY_RELEASE_NOTES_GH_TOKEN }}
279+
248280
- 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 }}
252281
uses: softprops/action-gh-release@v3
253282
env:
254283
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
255284
with:
256285
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 }}
259288
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
262291
body: |
263292
Automated Nightly (pre-release) Releases for Today
264-
265-
[Compare Changes](https://github.com/${{ github.repository }}/compare/${{ env.TAG_COMMIT }}...${{ github.sha }})
266293
267-
${{ env.RELEASE_NOTES }}
294+
[Compare Changes](https://github.com/${{ github.repository }}/compare/${{ needs.build.outputs.tag_commit }}...${{ github.sha }})
268295
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 }}
281297
282298
community-release-notifier:
283-
needs: build
299+
needs: [build, release]
284300
# 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 }}
286302
uses: Acode-Foundation/acode/.github/workflows/community-release-notifier.yml@main
287303
with:
288304
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 }}
291307
secrets:
292308
DISCORD_WEBHOOK_RELEASE_NOTES: ${{ secrets.DISCORD_WEBHOOK_RELEASE_NOTES }}
293309
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}

‎.github/workflows/on-demand-preview-releases-PR.yml‎

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
# defined at workflow-level as the workflow, Requires these permissions to function.
1111
permissions:
12-
contents: write
12+
contents: read
1313
pull-requests: write
1414
# All Pull Requests are issues, but not all issues are Pull Requests (like GitHub says 🙃)
1515
issues: write
@@ -39,8 +39,6 @@ jobs:
3939
clean: false
4040
fetch-depth: 0
4141
persist-credentials: false
42-
# Checkout pull request HEAD commit instead of merge commit
43-
ref: ${{ github.event.pull_request.head.sha }}
4442

4543
- name: Remove Manually added PR Label
4644
if: |
@@ -73,25 +71,36 @@ jobs:
7371

7472
trigger_builder:
7573
needs: job_trigger
76-
secrets: inherit
74+
secrets:
75+
KEYSTORE_CONTENT: ${{ secrets.KEYSTORE_CONTENT }}
76+
BUILD_JSON_CONTENT: ${{ secrets.BUILD_JSON_CONTENT }}
7777
uses: Acode-Foundation/acode/.github/workflows/nightly-build.yml@main
7878
with:
7979
is_PR: true
8080
PR_NUMBER: ${{ github.event.pull_request.number }}
81+
is_trusted_pr: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
8182
skip_tagging_and_releases: true
8283

8384
update_Last_Comment:
8485
needs: [job_trigger,trigger_builder]
8586
runs-on: ubuntu-latest
86-
if: ${{ github.repository_owner == 'Acode-Foundation' && always() && contains(fromJSON('["failure","cancelled"]'), needs.trigger_builder.result) }}
87+
if: ${{ github.repository_owner == 'Acode-Foundation' && always() && contains(fromJSON('["failure","cancelled", "success"]'), needs.trigger_builder.result) }}
8788
steps:
88-
# - name: Checkout code
89-
# uses: actions/checkout@v4
90-
# with:
91-
# clean: false
92-
# fetch-depth: 0
89+
90+
- name: Update Last Comment by bot (If Workflow Triggering succeeded)
91+
if: ${{ needs.trigger_builder.result == 'success' && github.event.pull_request.number }}
92+
uses: marocchino/sticky-pull-request-comment@v3
93+
with:
94+
hide_and_recreate: true
95+
hide_classify: "OUTDATED"
96+
header: on-demand-build-status
97+
message: |
98+
Preview Release for this, has been built.
99+
100+
[Click here to view that github actions build](https://github.com/${{ github.repository}}/actions/runs/${{ github.run_id }})
93101

94102
- name: Update Last Comment by bot (if Workflow Triggering failed)
103+
if: ${{ needs.trigger_builder.result != 'success' && github.event.pull_request.number }}
95104
uses: marocchino/sticky-pull-request-comment@v3
96105
with:
97106
hide_and_recreate: true
@@ -102,4 +111,4 @@ jobs:
102111
status: **${{ needs.trigger_builder.result || 'failure'}}**
103112
104113
---
105-
For Owners: Please [Click here to view that github actions](https://github.com/${{ github.repository}}/actions/runs/${{ github.run_id }})
114+
Please [Click here to view that github actions](https://github.com/${{ github.repository}}/actions/runs/${{ github.run_id }})

0 commit comments

Comments
 (0)