Skip to content

Commit 11720fb

Browse files
committed
add build and release-draft workflows
1 parent 4ea28e1 commit 11720fb

File tree

2 files changed

+128
-0
lines changed

2 files changed

+128
-0
lines changed

.github/workflows/build.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build Android Project
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
paths-ignore:
7+
- '**/README.md'
8+
- '**/TAGS.md'
9+
- 'fastlane/**'
10+
- /.github/workflows/build.yml
11+
- /.github/workflows/release-draft.yml
12+
pull_request:
13+
branches: [ "main" ]
14+
paths-ignore:
15+
- '**/README.md'
16+
- '**/TAGS.md'
17+
- 'fastlane/**'
18+
19+
20+
21+
jobs:
22+
build:
23+
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: set up JDK 21
29+
uses: actions/setup-java@v4
30+
with:
31+
java-version: '21'
32+
distribution: 'temurin'
33+
cache: gradle
34+
35+
- name: Grant execute permission for gradlew
36+
run: chmod +x gradlew
37+
- name: Build with Gradle without running tests
38+
run: ./gradlew build --exclude-task test
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: APK Release Draft
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
app_name:
7+
description: 'App Name'
8+
required: true
9+
default: 'SensorServer'
10+
tag_name:
11+
description: 'Tag Name'
12+
required: true
13+
14+
permissions:
15+
contents: write
16+
17+
jobs:
18+
build-release:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v3
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Decode Keystore
28+
id: decode_keystore
29+
uses: timheuer/base64-to-file@v1
30+
with:
31+
fileName: "keystore"
32+
encodedString: ${{ secrets.ANDROID_KEYSTORE_BASE_64 }}
33+
34+
- name: Set up Java
35+
uses: actions/setup-java@v3
36+
with:
37+
distribution: 'temurin'
38+
java-version: '21'
39+
40+
- name: Grant execute permission to gradlew
41+
run: chmod +x ./gradlew
42+
43+
- name: Build APK
44+
run: |
45+
./gradlew assembleRelease \
46+
-Pandroid.injected.signing.store.file=${{ steps.decode_keystore.outputs.filePath }} \
47+
-Pandroid.injected.signing.store.password=${{ secrets.ANDROID_KEYSTORE_STORE_PASSWORD }} \
48+
-Pandroid.injected.signing.key.alias=${{ secrets.ANDROID_KEYSTORE_ALIAS }} \
49+
-Pandroid.injected.signing.key.password=${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
50+
51+
- name: Rename APK
52+
run: |
53+
mv app/build/outputs/apk/release/app-release.apk "${{ github.event.inputs.app_name }}-${{ github.event.inputs.tag_name }}.apk"
54+
echo "renamed_apk=${{ github.event.inputs.app_name }}-${{ github.event.inputs.tag_name }}.apk" >> $GITHUB_ENV
55+
56+
# It uses `continue-on-error: true` so the job won't fail if it breaks
57+
- name: Get commit messages since last tag
58+
id: release_notes
59+
continue-on-error: true
60+
run: |
61+
git fetch --tags
62+
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
63+
if [ -z "$LAST_TAG" ]; then
64+
git log --pretty=format:"%s %h" > changelog.txt
65+
else
66+
git log ${LAST_TAG}..HEAD --pretty=format:"%s %h" > changelog.txt
67+
fi
68+
69+
70+
# If previous step failed
71+
- name: Ensure changelog.txt exists
72+
if: failure()
73+
run: echo "unable to find commits from last tag" > changelog.txt
74+
75+
76+
- name: Upload APK Artifact
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: ${{ github.event.inputs.app_name }}-${{ github.event.inputs.tag_name }}
80+
path: ${{ env.renamed_apk }}
81+
82+
- name: Create Release Draft
83+
uses: ncipollo/release-action@v1
84+
with:
85+
artifacts: ${{ env.renamed_apk }}
86+
tag: ${{ github.event.inputs.tag_name }}
87+
draft: true
88+
name: ${{ github.event.inputs.tag_name }}
89+
prerelease: false
90+
bodyFile: changelog.txt

0 commit comments

Comments
 (0)