Skip to content

Commit 2192dfd

Browse files
Add nightly release workflow and rename production build
This commit introduces a new GitHub Actions workflow to automatically generate nightly releases. It also updates the build configuration for better clarity between different build variants. The key changes include: - A new `nightly-release.yml` workflow that builds, signs, and uploads a `nightly` pre-release to GitHub every day at midnight UTC. This workflow also handles the deletion of the previous nightly tag and release to ensure only the latest is available. - The Fastlane `deploy` lane now specifically builds the `prodRelease` variant instead of the generic `release` one. - In `app/build.gradle.kts`, the APK output file naming convention is updated to include the `flavorName` for better identification of build artifacts.
1 parent 77a0e92 commit 2192dfd

3 files changed

Lines changed: 113 additions & 5 deletions

File tree

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Nightly Release
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *" # This runs at midnight UTC every day
6+
workflow_dispatch: # This allows the workflow to be triggered manually
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
env:
12+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13+
steps:
14+
- name: Check out the repository
15+
uses: actions/checkout@v4.2.2
16+
with:
17+
token: ${{ secrets.GITHUB_TOKEN }}
18+
19+
- name: Delete existing nightly release
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
run: |
23+
release_id=$(curl -sSf -H "Authorization: Bearer $GITHUB_TOKEN" "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/nightly" | jq -r '.id')
24+
if [ -n "$release_id" ]; then
25+
# Delete the release
26+
curl -sSf \
27+
-H "Authorization: Bearer $GITHUB_TOKEN" \
28+
-X DELETE \
29+
"https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/${release_id}"
30+
31+
# Delete the tag
32+
curl -sSf \
33+
-H "Authorization: Bearer $GITHUB_TOKEN" \
34+
-X DELETE \
35+
"https://api.github.com/repos/${GITHUB_REPOSITORY}/git/refs/tags/nightly"
36+
fi
37+
38+
build:
39+
name: Build, Sign & Release
40+
runs-on: ubuntu-latest
41+
needs: release
42+
steps:
43+
- name: Checkout project
44+
uses: actions/checkout@v4.2.2
45+
with:
46+
token: ${{ secrets.GITHUB_TOKEN }}
47+
48+
- name: set up JDK 17
49+
uses: actions/setup-java@v4.7.1
50+
with:
51+
java-version: "17"
52+
distribution: "temurin"
53+
cache: gradle
54+
55+
- uses: actions/cache@v4.2.3
56+
with:
57+
path: |
58+
~/.gradle/caches
59+
~/.gradle/wrapper
60+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
61+
restore-keys: |
62+
${{ runner.os }}-gradle-
63+
64+
- name: Grant execute permission for gradlew
65+
run: chmod +x gradlew
66+
67+
- name: Build with Gradle
68+
run: ./gradlew clean && ./gradlew assembleNightlyDebug
69+
70+
- name: Sign APK - Nightly
71+
uses: ilharp/sign-android-release@v2.0.0
72+
# ID used to access action output
73+
id: sign_app_nightly
74+
with:
75+
releaseDir: app/build/outputs/apk/nightly/release
76+
signingKey: ${{ secrets.SIGNINGKEY_BASE64 }}
77+
keyAlias: ${{ secrets.KEY_ALIAS }}
78+
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
79+
keyPassword: ${{ secrets.KEY_PASSWORD }}
80+
buildToolsVersion: 35.0.0
81+
82+
- name: Extract Version
83+
id: extract_version
84+
run: |
85+
version=$(date +"%Y.%m.%d")
86+
echo "version=$version" >> $GITHUB_ENV
87+
shell: bash
88+
89+
- name: Rename files
90+
run: |
91+
mkdir -p ./build/release/
92+
mv ${{steps.sign_app_nightly.outputs.signedFile}} ./build/release/mLauncher-Nightly-Signed.apk
93+
shell: bash
94+
95+
- name: Create and Upload Release
96+
uses: softprops/action-gh-release@v2.3.2
97+
with:
98+
tag_name: nightly
99+
name: Nightly Release ${{ env.version }}
100+
body: "![GitHub Downloads (total, specific tag)](https://img.shields.io/github/downloads/CodeWorksCreativeHub/mLauncher/nightly/total)"
101+
append_body: false
102+
files: |
103+
./build/release/mLauncher-Nightly-Signed.apk
104+
prerelease: true
105+
generate_release_notes: true
106+
env:
107+
version: ${{ env.version }}
108+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

app/build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,16 @@ android {
9696

9797
applicationVariants.all {
9898

99-
val appId = this.applicationId
100-
val buildType = this.buildType.name
101-
val version = this.versionName
99+
val applicationId = this.applicationId
100+
val flavorName = this.flavorName
101+
val versionName = this.versionName
102102

103103
outputs.all {
104104
val output =
105105
this as com.android.build.gradle.internal.api.BaseVariantOutputImpl
106106

107107
output.outputFileName =
108-
"${appId}_${buildType}_${version}.apk"
108+
"${applicationId}_${flavorName}_${versionName}.apk"
109109
}
110110
}
111111

fastlane/Fastfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ platform :android do
3232

3333
desc "Deploy a new version to the Google Play"
3434
lane :deploy do
35-
gradle(task: "clean assembleRelease")
35+
gradle(task: "clean assembleProdRelease")
3636
upload_to_play_store
3737
end
3838
end

0 commit comments

Comments
 (0)