Skip to content

Commit 907f012

Browse files
Add GitHub release workflow
1 parent f0cd3e2 commit 907f012

File tree

10 files changed

+134
-10
lines changed

10 files changed

+134
-10
lines changed

.github/workflows/assemble.yml

+16-3
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,27 @@ on:
66
jobs:
77
build:
88
runs-on: ubuntu-latest
9+
env:
10+
KS_PASSWORD: ${{ secrets.KS_PASSWORD }}
11+
KS_KEY_ALIAS: ${{ secrets.KS_KEY_ALIAS }}
12+
APK_NAME: 'app-release.apk'
13+
APK_PATH: 'app/build/outputs/apk/release/app-release.apk'
914
steps:
1015
- name: Checkout code
1116
uses: actions/checkout@v4
1217
- name: Setup JDK 17
1318
id: setup-java
1419
uses: actions/setup-java@v4
1520
with:
16-
distribution: 'zulu'
21+
distribution: zulu
1722
java-version: 17
18-
- name: Assemble app
19-
run: ./gradlew assemble
23+
- name: Assemble release
24+
run: ./gradlew assembleRelease -DKS_PASSWORD=${{ env.KS_PASSWORD }} -DKS_KEY_ALIAS=${{ env.KS_KEY_ALIAS }}
25+
- name: Upload apk
26+
id: upload_apk
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: ${{ env.APK_NAME }}
30+
path: ${{ env.APK_PATH }}
31+
overwrite: true
32+
retention-days: 1

.github/workflows/deploy.yml

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Required PAT repository permissions:
2+
# - Actions: RW
3+
# - Contents: RW
4+
# - Pull requests: RO
5+
# - Secrets: RO
6+
# - Workflows: RW
7+
name: Deploy
8+
on:
9+
workflow_run:
10+
workflows:
11+
- Assemble
12+
types:
13+
- completed
14+
jobs:
15+
setup_env:
16+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
17+
runs-on: ubuntu-latest
18+
outputs:
19+
commit_subject: ${{ steps.output1.outputs.commit_subject }}
20+
release_tag: ${{ steps.output2.outputs.release_tag }}
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
- id: output1
25+
run: echo "commit_subject=$(git log -1 --format=%s)" >> $GITHUB_OUTPUT
26+
- id: output2
27+
run: echo "release_tag=$(git log -1 --format=%s | sed 's/.*Release //')" >> $GITHUB_OUTPUT
28+
deploy:
29+
needs: setup_env
30+
env:
31+
APK_NAME: 'app-release.apk'
32+
APK_CONTENT_TYPE: 'application/vnd.android.package-archive'
33+
COMMIT_SUBJECT: ${{ needs.setup_env.outputs.commit_subject }}
34+
RELEASE_TAG: ${{ needs.setup_env.outputs.release_tag }}
35+
if: ${{ startsWith(needs.setup_env.outputs.commit_subject, 'Release v') }}
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@v4
40+
with:
41+
fetch-depth: 0
42+
- name: Build changelog
43+
id: build_changelog
44+
uses: mikepenz/release-changelog-builder-action@v4
45+
with:
46+
configurationJson: |
47+
{
48+
"template": "### Signing Certificate Checksum\n E9:3B:0B:2E:AF:EE:95:0D:EF:8B:E0:48:98:D3:45:25:22:13:41:57:B0:35:ED:EC:7E:84:F4:2E:F5:F9:38:E6\n\n#{{CHANGELOG}}\n\n<details>\n<summary>Uncategorized</summary>\n\n#{{UNCATEGORIZED}}\n</details>"
49+
}
50+
commitMode: true
51+
failOnError: true
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
54+
- name: Download apk
55+
id: download_apk
56+
uses: actions/download-artifact@v4
57+
with:
58+
name: ${{ env.APK_NAME }}
59+
github-token: ${{ secrets.GH_TOKEN }}
60+
repository: ${{ github.repository }}
61+
run-id: ${{ github.event.workflow_run.id }}
62+
- name: Create tag
63+
uses: rickstaa/action-create-tag@v1
64+
id: tag_create
65+
with:
66+
tag: ${{ env.RELEASE_TAG }}
67+
message: ${{ env.COMMIT_SUBJECT }}
68+
- name: Create release
69+
uses: ncipollo/release-action@v1
70+
with:
71+
artifactContentType: ${{ env.APK_CONTENT_TYPE }}
72+
artifacts: ${{ format('{0}/{1}', steps.download_apk.outputs.download-path, env.APK_NAME) }}
73+
body: ${{ steps.build_changelog.outputs.changelog }}
74+
skipIfReleaseExists: true
75+
tag: ${{ env.RELEASE_TAG }}
76+
token: ${{ secrets.GH_TOKEN }}

.github/workflows/detekt.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
id: setup-java
1414
uses: actions/setup-java@v4
1515
with:
16-
distribution: 'zulu'
16+
distribution: zulu
1717
java-version: 17
1818
- name: Run detekt
1919
run: ./gradlew detekt

.github/workflows/ktlint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
id: setup-java
1414
uses: actions/setup-java@v4
1515
with:
16-
distribution: 'zulu'
16+
distribution: zulu
1717
java-version: 17
1818
- name: Run ktlint
1919
run: ./gradlew lintKotlin

.github/workflows/lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
id: setup-java
1414
uses: actions/setup-java@v4
1515
with:
16-
distribution: 'zulu'
16+
distribution: zulu
1717
java-version: 17
1818
- name: Run lint
1919
run: ./gradlew lint

.github/workflows/spotless.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
id: setup-java
1414
uses: actions/setup-java@v4
1515
with:
16-
distribution: 'zulu'
16+
distribution: zulu
1717
java-version: 17
1818
- name: Run spotless
1919
run: ./gradlew spotlessKotlinCheck

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
.externalNativeBuild
1515
.cxx
1616
local.properties
17+
keystore.properties

app/build.gradle.kts

+35-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
22
import io.gitlab.arturbosch.detekt.Detekt
33
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
4+
import java.io.FileInputStream
5+
import java.util.Properties
46

57
plugins {
68
alias(libs.plugins.android.application)
@@ -28,8 +30,38 @@ android {
2830
versionName = "2.1.0"
2931
}
3032

33+
signingConfigs {
34+
create("release") {
35+
val keyStorePassword = "KS_PASSWORD"
36+
val keyStoreKeyAlias = "KS_KEY_ALIAS"
37+
val properties = Properties().apply {
38+
val file = File(projectDir.parent, "keystore.properties")
39+
if (file.exists()) {
40+
load(FileInputStream(file))
41+
}
42+
}
43+
val password = properties
44+
.getOrDefault(keyStorePassword, null)
45+
?.toString()
46+
?: System.getenv(keyStorePassword)
47+
val alias = properties
48+
.getOrDefault(keyStoreKeyAlias, null)
49+
?.toString()
50+
?: System.getenv(keyStoreKeyAlias)
51+
storeFile = File(projectDir.parent, "keystore.jks")
52+
storePassword = password
53+
keyAlias = alias
54+
keyPassword = password
55+
enableV1Signing = false
56+
enableV2Signing = false
57+
enableV3Signing = true
58+
enableV4Signing = true
59+
}
60+
}
61+
3162
buildTypes {
3263
release {
64+
signingConfig = signingConfigs.findByName("release")
3365
isMinifyEnabled = true
3466
isShrinkResources = true
3567
proguardFiles(
@@ -60,7 +92,9 @@ android {
6092

6193
tasks.withType<DependencyUpdatesTask>().configureEach {
6294
fun isNonStable(version: String): Boolean {
63-
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase().contains(it) }
95+
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { keyWord ->
96+
version.uppercase().contains(keyWord)
97+
}
6498
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
6599
val isStable = stableKeyword || regex.matches(version)
66100
return isStable.not()
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Sat Jan 27 16:16:15 CET 2024
1+
#Sun Feb 04 14:55:21 CET 2024
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-rc-3-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

keystore.jks

2.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)