Skip to content

Commit

Permalink
Add github release action
Browse files Browse the repository at this point in the history
  • Loading branch information
HeroBrine1st committed Sep 6, 2024
1 parent 2b76114 commit ecf52b6
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 1 deletion.
76 changes: 76 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#file: noinspection SpellCheckingInspection
name: Publish release

on:
push:
tags:
- "*"

permissions:
contents: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: # fix git tag --format=... showing commit message instead of tag message
fetch-depth: 1 # despite being the default, it allows checking out a tag
ref: ${{ github.ref }}
- name: Abort if tag is not annotated
run: |
tag_type=$(git cat-file -t $GITHUB_REF)
if [ "$tag_type" != "tag" ]; then # if not annotated, tag_type is "commit"
echo "The tag $GITHUB_REF_NAME is not annotated. Aborting job."
exit 1
fi
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Set up android SDK
uses: android-actions/setup-android@v2
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: wrapper
- name: Run tests
run: ./gradlew testReleaseUnitTest
- name: Decode Keystore
env:
ENCODED_STRING: ${{ secrets.KEYSTORE }}
run: |
echo $ENCODED_STRING | base64 -di > app/keystore.jks
- name: Show signing report
env:
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
run: ./gradlew signingReport
- name: Build release APK
env:
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
run: ./gradlew :app:assembleRelease
- name: Clean up
if: ${{ !cancelled() }}
run: rm app/keystore.jks
- name: Make directory for release files
run: mkdir ./dist
- name: Compress proguard mappings
run: tar -C app/build/outputs/mapping/release -c . | zstd --ultra --long -22 -T0 > ./dist/proguard-mappings.tar.zst
- name: Rename apk
run: mv app/build/outputs/apk/release/app-release.apk ./dist/e621-$GITHUB_REF_NAME.apk
- name: Fetch release notes
run: git tag -l --format="%(contents)" $GITHUB_REF_NAME | tee ./release.txt
- name: Publish release
uses: softprops/action-gh-release@v2
with:
files: |
./dist/**
fail_on_unmatched_files: true
make_latest: true
body_path: "./release.txt"
generate_release_notes: true
13 changes: 12 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,17 @@ android {
"%s/%s (Android/%s; %s build; +https://github.com/HeroBrine1st/E621) Ktor/${libs.versions.ktor.get()}"
)
}

signingConfigs {
create("release") {
storeFile = file("keystore.jks")
storePassword = System.getenv("SIGNING_STORE_PASSWORD")
keyAlias = System.getenv("SIGNING_KEY_ALIAS")
keyPassword = System.getenv("SIGNING_KEY_PASSWORD")

// Apk will be in app/build/outputs/apk/release/app-release.apk
// or app-release-unsigned.apk, if unsigned
}
}
buildTypes {
release {
isMinifyEnabled = true
Expand All @@ -50,6 +60,7 @@ android {
"proguard-rules.pro",
"intellij-idea-does-not-like-these-proguard-rules.pro"
)
signingConfig = signingConfigs.getByName("release")
}
debug {
applicationIdSuffix = ".debug"
Expand Down

0 comments on commit ecf52b6

Please sign in to comment.