Skip to content

Commit f54e452

Browse files
committed
feat. debug build workflow
1 parent 0bfedde commit f54e452

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

.github/workflows/debug-build.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- build
7+
pull_request:
8+
branches:
9+
- build
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Clone repository
16+
uses: actions/checkout@v4
17+
18+
- name: Install deprndencies
19+
run: npm install
20+
21+
- name: Setup Acode
22+
run: npm install
23+
24+
- name: Build APK
25+
shell: bash
26+
run: |
27+
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
28+
GITHUB_SHA="${{ github.event.pull_request.head.sha }}" # Do not use last merge commit set in GITHUB_SHA
29+
fi
30+
CURRENT_VERSION_NAME="$(jq ".version" package.json | sed 's/"//g')"
31+
RELEASE_VERSION_NAME="v$CURRENT_VERSION_NAME+${GITHUB_SHA:0:7}" # The "+" is necessary so that versioning precedence is not affected
32+
if ! printf "%s" "${RELEASE_VERSION_NAME/v/}" | grep -qP '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'; then
33+
exit_on_error "The versionName '${RELEASE_VERSION_NAME/v/}' is not a valid version as per semantic version '2.0.0' spec in the format 'major.minor.patch(-prerelease)(+buildmetadata)'. https://semver.org/spec/v2.0.0.html."
34+
fi
35+
36+
APK_DIR_PATH="./platforms/android/app/build/outputs/apk/debug"
37+
APK_VERSION_TAG="$RELEASE_VERSION_NAME-github-debug" # Note the "-", GITHUB_SHA will already have "+" before it
38+
APK_BASENAME_PREFIX="acode_$APK_VERSION_TAG"
39+
# Used by attachment steps later
40+
echo "APK_DIR_PATH=$APK_DIR_PATH" >> $GITHUB_ENV
41+
echo "APK_VERSION_TAG=$APK_VERSION_TAG" >> $GITHUB_ENV
42+
echo "APK_BASENAME_PREFIX=$APK_BASENAME_PREFIX" >> $GITHUB_ENV
43+
44+
node ./utils/config.js d paid
45+
npx webpack --progress --mode production
46+
node ./utils/loadStyles.js
47+
cordova build android
48+
exit_on_error "Build failed for '$APK_VERSION_TAG' build."
49+
50+
cp "$APK_DIR_PATH/app-debug.apk" "$APK_DIR_PATH/${APK_BASENAME_PREFIX}.apk"
51+
52+
echo "Generating sha25sums file"
53+
if ! (cd "$APK_DIR_PATH"; sha256sum \
54+
"${APK_BASENAME_PREFIX}.apk"
55+
> "${APK_BASENAME_PREFIX}_sha256sums"); then
56+
exit_on_error "Generate sha25sums failed for '$APK_VERSION_TAG' release."
57+
58+
- name: Attach APK file
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: ${{ env.APK_BASENAME_PREFIX }}
62+
path: |
63+
${{ env.APK_DIR_PATH }}/${{ env.APK_BASENAME_PREFIX }}.apk
64+
${{ env.APK_DIR_PATH }}/output-metadata.json
65+
66+
- name: Attach sha256sums file
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: ${{ env.APK_BASENAME_PREFIX }}_sha256sums
70+
path: |
71+
${{ env.APK_DIR_PATH }}/${{ env.APK_BASENAME_PREFIX }}_sha256sums
72+
${{ env.APK_DIR_PATH }}/output-metadata.json

0 commit comments

Comments
 (0)