Skip to content

Commit 8420daf

Browse files
authored
Merge branch 'Acode-Foundation:main' into main
2 parents 0c4fe92 + cdeda55 commit 8420daf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+2847
-869
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.sh text eol=lf

.github/CODEOWNERS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.github/CODEOWNERS @Acode-Foundation
2+
3+
# workflows
4+
.github/workflows/nightly-build.yml @unschooledgamer
5+
.github/workflows/on-demand-preview-releases-PR.yml @unschooledgamer
6+
.github/workflows/community-release-notifier.yml @unschooledgamer
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: community-release-notifier
2+
on:
3+
release:
4+
types: [ released ]
5+
workflow_call:
6+
inputs:
7+
tag_name:
8+
required: true
9+
description: "Release tag_name"
10+
type: 'string'
11+
url:
12+
required: true
13+
description: "release URL"
14+
type: 'string'
15+
secrets:
16+
DISCORD_WEBHOOK_RELEASE_NOTES:
17+
description: 'Discord Webhook for Notifying Releases to Discord'
18+
required: true
19+
20+
jobs:
21+
discord-release:
22+
if: github.repository_owner == 'Acode-Foundation'
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Get Release Content
26+
id: get-release-content
27+
uses: 2428392/gh-truncate-string-action@b3ff790d21cf42af3ca7579146eedb93c8fb0757 # v1.4.1
28+
with:
29+
maxLength: 2000
30+
stringToTruncate: |
31+
📢 Acode [${{ github.event.release.tag_name || inputs.tag_name }}](<${{ github.event.release.url || inputs.url }}>) was just Released 🎉!
32+
33+
34+
- name: Discord Webhook Action (Publishing)
35+
uses: tsickert/discord-webhook@c840d45a03a323fbc3f7507ac7769dbd91bfb164 # v5.3.0
36+
with:
37+
webhook-url: ${{ secrets.DISCORD_WEBHOOK_RELEASE_NOTES }}
38+
content: ${{ steps.get-release-content.outputs.string }}
Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
# Implement to use environment secrets someday, At the moment GH Actions doesn't support those in reusable workflows (ref: https://github.com/actions/runner/issues/1490)
2+
# at least that's what I found.
3+
name: Nightly Build
4+
5+
on:
6+
schedule:
7+
# Fire every day at 7:00am UTC (Roughly before EU workday and after US workday)
8+
- cron: "0 7 * * *"
9+
push:
10+
tags:
11+
- nightly
12+
workflow_call:
13+
inputs:
14+
is_PR:
15+
default: false
16+
type: boolean
17+
description: If a Pull Request has triggered it.
18+
PR_NUMBER:
19+
required: true
20+
type: number
21+
description: The Pull Request that triggered this workflow
22+
skip_tagging_and_releases:
23+
required: false
24+
default: true
25+
type: boolean
26+
description: Skips Tagging & releases, since workflow_call isn't available for github.event_name, default is true
27+
outputs:
28+
job_result:
29+
description: "Build job result"
30+
value: ${{ jobs.build.result }}
31+
32+
workflow_dispatch:
33+
inputs:
34+
skip_tagging_and_releases:
35+
required: false
36+
default: true
37+
type: boolean
38+
description: Skips Tagging & releases, since workflow_call isn't available for github.event_name, default is true
39+
40+
concurrency:
41+
# Allow only one workflow per any non-`main` branch.
42+
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}-${{ inputs.is_PR && 'is_PR' || 'not_PR'}}
43+
cancel-in-progress: true
44+
45+
permissions:
46+
contents: read
47+
48+
env:
49+
STORE_FILE_PATH: /tmp/app-debug.keystore
50+
BUILD_JSON_PATH: build.json
51+
VERSION_LABEL: ${{ (inputs.is_PR && 'pr') || 'nightly' }}
52+
DISCORD_RELEASE_NOTIFIER_ENABLED: "true"
53+
jobs:
54+
build:
55+
timeout-minutes: 60
56+
runs-on: ubuntu-latest
57+
if: github.repository_owner == 'Acode-Foundation'
58+
59+
permissions:
60+
# contents write is needed to create Nightly Releases.
61+
contents: write
62+
# issues: write
63+
pull-requests: write
64+
65+
outputs:
66+
release_output_url: ${{ steps.release.outputs.url }}
67+
updated_version: ${{ steps.update-version.outputs.UPDATED_VERSION}}
68+
steps:
69+
- name: Fast Fail if secrets are missing
70+
if: ${{ env.KEYSTORE_CONTENT == '' || env.BUILD_JSON_CONTENT == '' }}
71+
env:
72+
KEYSTORE_CONTENT: ${{ secrets.KEYSTORE_CONTENT }}
73+
BUILD_JSON_CONTENT: ${{ secrets.BUILD_JSON_CONTENT }}
74+
run: |
75+
echo "::error title=Missing Secrets::KEYSTORE_CONTENT or BUILD_JSON_CONTENT secrets are missing! Aborting workflow."
76+
exit 1
77+
78+
- name: Logging & summaries
79+
run: |
80+
echo "::group::Logging"
81+
echo "🎯 github trigger event name: ${{ github.event_name }}"
82+
echo "is_PR: ${{ inputs.is_PR }} "
83+
echo "PR_NUMBER: ${{ inputs.PR_NUMBER }}"
84+
echo "env: STORE_FILE_PATH: ${{ env.STORE_FILE_PATH }}"
85+
echo "env: BUILD_JSON_PATH: ${{ env.BUILD_JSON_PATH }}"
86+
echo "env: VERSION_LABEL: ${{ env. VERSION_LABEL }}"
87+
echo "github sha: ${{ github.sha }}"
88+
echo "should not skip tags, releases: ${{ ! inputs.skip_tagging_and_releases }} "
89+
echo "::endgroup::"
90+
91+
echo "## 🚀 Build Type: ${{ env.VERSION_LABEL }}" >> $GITHUB_STEP_SUMMARY
92+
echo "is_PR: ${{ inputs.is_PR || 'NOT a PR' }}" >> $GITHUB_STEP_SUMMARY
93+
echo "PR_NUMBER: ${{ inputs.PR_NUMBER || 'not a PR' }}" >> $GITHUB_STEP_SUMMARY
94+
echo "should not skip tags, releases: ${{ ! inputs.skip_tagging_and_releases }}" >> $GITHUB_STEP_SUMMARY
95+
96+
- name: Checkout Repository
97+
uses: actions/checkout@v4
98+
with:
99+
fetch-depth: 0 # Required for tags
100+
# persists credentials locally if tagging and releases are not skipped.
101+
persist-credentials: ${{ ! inputs.skip_tagging_and_releases }}
102+
ref: ${{ (inputs.is_PR && inputs.PR_NUMBER) && github.event.pull_request.head.sha || '' }}
103+
104+
- name: Set up Java 21
105+
uses: actions/setup-java@v4
106+
with:
107+
distribution: 'temurin'
108+
java-version: '21'
109+
cache: ${{ (!(inputs.is_PR && inputs.PR_NUMBER) && github.ref == 'refs/heads/main' && 'gradle') || '' }}
110+
111+
- name: Set up Node.js
112+
uses: actions/setup-node@v4
113+
with:
114+
node-version: 'lts/*' # or '18.x' for latest stable
115+
116+
- name: Add keystore and build.json from secrets
117+
run: |
118+
echo "${{ secrets.KEYSTORE_CONTENT }}" | base64 -d > $STORE_FILE_PATH
119+
echo "${{ secrets.BUILD_JSON_CONTENT }}" | base64 -d > $BUILD_JSON_PATH
120+
echo "Keystore and build.json added successfully."
121+
122+
- name: Export Commit Hash & prev tag
123+
run: |
124+
echo "GIT_COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV
125+
echo "PREV_TAG=$(git describe --tags --abbrev=0 || git rev-list --max-parents=0 HEAD)" >> $GITHUB_ENV
126+
127+
- name: Extract versionCode and version from config.xml
128+
id: extract_version
129+
run: |
130+
if [ ! -f config.xml ]; then
131+
echo "config.xml not found!"
132+
exit 1
133+
fi
134+
VERSION_CODE=$(grep 'versionCode=' config.xml | sed -E 's/.*versionCode="([0-9]+)".*/\1/')
135+
VERSION=$(grep -oP 'version="\K[0-9.]+' config.xml)
136+
echo "VERSION_CODE=$VERSION_CODE" >> $GITHUB_OUTPUT
137+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
138+
echo "Extracted Version Code: $VERSION_CODE"
139+
echo "Extracted Version: $VERSION"
140+
141+
- name: Append Commit Hash to Version and Update config.xml
142+
id: update-version
143+
run: |
144+
SHORT_COMMIT_HASH=$(echo "${{ env.GIT_COMMIT }}" | cut -c 1-7)
145+
if ${{ inputs.is_PR || false }}; then
146+
PR_NUMBER=${{ inputs.PR_NUMBER }}
147+
else
148+
PR_NUMBER=
149+
fi
150+
UPDATED_VERSION="${{ steps.extract_version.outputs.VERSION }}-${{ env.VERSION_LABEL }}.${PR_NUMBER:-$SHORT_COMMIT_HASH}"
151+
echo "Updated Version: $UPDATED_VERSION"
152+
153+
# Update config.xml with the new version
154+
sed -i "s/version=\"${{ steps.extract_version.outputs.VERSION }}\"/version=\"$UPDATED_VERSION\"/g" config.xml
155+
echo "Updated version in config.xml"
156+
# Output the updated version
157+
echo "UPDATED_VERSION=$UPDATED_VERSION" >> $GITHUB_ENV
158+
echo "UPDATED_VERSION=$UPDATED_VERSION" >> $GITHUB_OUTPUT
159+
160+
- name: Install Node.js Packages
161+
run: npm install
162+
163+
- name: Install Cordova CLI
164+
run: npm install -g cordova
165+
166+
- name: Run npm setup
167+
run: npm run setup
168+
169+
- name: Run npm build paid dev apk
170+
run: |
171+
node utils/storage_manager.mjs y
172+
npm run build paid dev apk
173+
echo "VERSION: $UPDATED_VERSION" >> $GITHUB_STEP_SUMMARY
174+
175+
- name: Upload APK Artifact
176+
uses: actions/upload-artifact@v4
177+
with:
178+
name: app-debug-${{ env.GIT_COMMIT }}
179+
path: platforms/android/app/build/outputs/apk/debug/app-debug.apk
180+
181+
- name: remove keystore and build.json
182+
run: |
183+
rm $STORE_FILE_PATH $BUILD_JSON_PATH
184+
echo "Keystore and build.json removed successfully."
185+
186+
- name: Check Nightly Tag and Force Update
187+
#if: github.event_name == 'push' && contains(github.event.ref, 'tags/nightly') == false
188+
if: ${{ ! inputs.skip_tagging_and_releases }}
189+
run: |
190+
# Check if the nightly tag exists and get the commit it points to
191+
if git show-ref --quiet refs/tags/nightly; then
192+
TAG_COMMIT=$(git rev-parse nightly)
193+
else
194+
TAG_COMMIT=""
195+
fi
196+
197+
# If the current commit is the same as the tag, skip updating the tag
198+
if [ "$TAG_COMMIT" != "${{ env.GIT_COMMIT }}" ]; then
199+
echo "releaseRequired=true" >> $GITHUB_ENV
200+
# export tag commit before updating for change logs comparing.
201+
echo "TAG_COMMIT=$TAG_COMMIT" >> $GITHUB_ENV
202+
203+
git config --global user.name 'GitHub Actions'
204+
git config --global user.email 'github-actions@github.com'
205+
git tag -f nightly
206+
git push origin nightly --force
207+
else
208+
echo "Nightly tag already points to this commit. Skipping update."
209+
fi
210+
211+
- name: Release Nightly Version
212+
# Only run this step, if not called from another workflow. And a previous step is successful with releasedRequired=true
213+
id: release
214+
if: ${{ ! inputs.skip_tagging_and_releases && success() && env.releaseRequired == 'true' }}
215+
uses: softprops/action-gh-release@v2
216+
with:
217+
prerelease: true
218+
name: ${{ env.UPDATED_VERSION }}
219+
tag_name: ${{ env.UPDATED_VERSION }}
220+
files: |
221+
platforms/android/app/build/outputs/apk/debug/app-debug.apk
222+
body: |
223+
Automated Nightly (pre-release) Releases for Today
224+
225+
[Compare Changes](https://github.com/${{ github.repository }}/compare/${{ env.TAG_COMMIT }}...${{ github.sha }})
226+
227+
- name: Update Last Comment by bot (If ran in PR)
228+
if: inputs.is_PR
229+
uses: marocchino/sticky-pull-request-comment@v2
230+
with:
231+
hide_and_recreate: true
232+
hide_classify: "OUTDATED"
233+
header: on-demand-build-status
234+
message: |
235+
Preview Release for this, has been built.
236+
237+
[Click here to view that github actions build](https://github.com/${{ github.repository}}/actions/runs/${{ github.run_id }})
238+
239+
240+
community-release-notifier:
241+
needs: build
242+
# Run only if push tags, or triggered by a schedule
243+
if: ${{ github.repository_owner == 'Acode-Foundation' && (contains(fromJSON('["push", "schedule"]'), github.event_name) || ! inputs.skip_tagging_and_releases) && needs.build.outputs.release_output_url }}
244+
uses: Acode-Foundation/acode/.github/workflows/community-release-notifier.yml@main
245+
with:
246+
tag_name: ${{ needs.build.outputs.updated_version }}
247+
url: ${{ needs.build.outputs.release_output_url }}
248+
secrets:
249+
DISCORD_WEBHOOK_RELEASE_NOTES: ${{ secrets.DISCORD_WEBHOOK_RELEASE_NOTES }}

0 commit comments

Comments
 (0)