229 lines
9.4 KiB
YAML
229 lines
9.4 KiB
YAML
name: Release Builder
|
|
# Build a stable release on a tag v* newly pushed
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- v*
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
prepare-build:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
VERSION_TAG: ${{ steps.get_tag.outputs.VERSION_TAG }}
|
|
CURRENT_SHA: ${{ steps.current_commit.outputs.CURRENT_SHA }}
|
|
PREV_RELEASE_SHA: ${{ steps.previous_commit.outputs.PREV_RELEASE_SHA }}
|
|
COMMIT_LOGS: ${{ steps.commit_logs.outputs.COMMIT_LOGS }}
|
|
PREV_TAG_NAME: ${{ steps.previous_commit.outputs.PREV_TAG_NAME }}
|
|
steps:
|
|
- name: Get tag name (${{ github.ref }})
|
|
id: get_tag
|
|
run: |
|
|
set -x
|
|
echo "VERSION_TAG=${GITHUB_REF/refs\/tags\//}"
|
|
echo "VERSION_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Clone Repository (${{ steps.get_tag.outputs.VERSION_TAG }})
|
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Validate Gradle Wrapper
|
|
uses: gradle/actions/wrapper-validation@d156388eb19639ec20ade50009f3d199ce1e2808 # v4
|
|
|
|
- name: Get previous release
|
|
id: last_release
|
|
uses: InsonusK/get-latest-release@7a9ff16c8c6b7ead5d71c0f1cc61f2703170eade # v1.1.0
|
|
with:
|
|
myToken: ${{ github.token }}
|
|
exclude_types: "draft|prerelease"
|
|
view_top: 1
|
|
|
|
- name: Curren commit
|
|
id: current_commit
|
|
run: |
|
|
set -e
|
|
|
|
commit_count=$(git rev-list --count HEAD)
|
|
echo "COMMIT_COUNT=$commit_count"
|
|
echo "COMMIT_COUNT=$commit_count" >> $GITHUB_OUTPUT
|
|
current_sha=$(git rev-parse --short HEAD)
|
|
echo "CURRENT_SHA=$current_sha"
|
|
echo "CURRENT_SHA=$current_sha" >> $GITHUB_OUTPUT
|
|
|
|
- name: Previous commit
|
|
id: previous_commit
|
|
run: |
|
|
set -e
|
|
|
|
commit_count_diff=$(git rev-list --count "${{ steps.last_release.outputs.tag_name }}"..HEAD)
|
|
|
|
# Fake at least 1 commits (to avoid no changes)
|
|
if [ "${commit_count_diff}" -eq 0 ]; then
|
|
commit_count_diff=1
|
|
fi
|
|
|
|
echo "commit_count_diff=$commit_count_diff"
|
|
prev_release_sha=$(git rev-parse --short HEAD~$commit_count_diff)
|
|
echo "PREV_RELEASE_SHA=$prev_release_sha"
|
|
echo "PREV_RELEASE_SHA=$prev_release_sha" >> $GITHUB_OUTPUT
|
|
echo "PREV_TAG_NAME=${{ steps.last_release.outputs.tag_name }}"
|
|
echo "PREV_TAG_NAME=${{ steps.last_release.outputs.tag_name }}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Commit logs
|
|
id: commit_logs
|
|
run: |
|
|
set -e
|
|
|
|
echo "COMMIT_LOGS<<{delimiter}
|
|
$(curl -H "Accept: application/vnd.github.v3+json" \
|
|
"https://api.github.com/repos/komikku-app/komikku/compare/${{ steps.previous_commit.outputs.PREV_RELEASE_SHA }}...${{ steps.current_commit.outputs.CURRENT_SHA }}" \
|
|
| jq '[.commits[]|{message:(.commit.message | split("\n")), username:.author.login}]' \
|
|
| jq -r '.[]|"- \(.message | first) (@\(.username))"')
|
|
{delimiter}" >> $GITHUB_OUTPUT
|
|
|
|
build-app:
|
|
name: Build release app
|
|
runs-on: ubuntu-latest
|
|
needs: prepare-build
|
|
if: startsWith(github.ref, 'refs/tags/v') && github.repository == 'komikku-app/komikku'
|
|
steps:
|
|
- name: Clone Repository (${{ needs.prepare-build.outputs.VERSION_TAG }})
|
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Validate Gradle Wrapper
|
|
uses: gradle/actions/wrapper-validation@d156388eb19639ec20ade50009f3d199ce1e2808 # v4
|
|
|
|
- name: Setup Android SDK
|
|
run: |
|
|
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager "build-tools;29.0.3"
|
|
|
|
- name: Set up JDK
|
|
uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
|
|
with:
|
|
java-version: 17
|
|
distribution: temurin
|
|
|
|
- name: Write google-services.json
|
|
uses: DamianReeves/write-file-action@6929a9a6d1807689191dcc8bbe62b54d70a32b42 # v1.3
|
|
with:
|
|
path: app/google-services.json
|
|
contents: ${{ secrets.GOOGLE_SERVICES_JSON }}
|
|
write-mode: overwrite
|
|
|
|
- name: Write client_secrets.json
|
|
uses: DamianReeves/write-file-action@6929a9a6d1807689191dcc8bbe62b54d70a32b42 # v1.3
|
|
with:
|
|
path: app/src/main/assets/client_secrets.json
|
|
contents: ${{ secrets.GOOGLE_CLIENT_SECRETS_JSON }}
|
|
write-mode: overwrite
|
|
|
|
- name: Set up gradle
|
|
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4
|
|
|
|
- name: Build app and run unit tests
|
|
run: ./gradlew spotlessCheck assembleStandardRelease testStandardReleaseUnitTest testReleaseUnitTest --stacktrace
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
|
with:
|
|
path: "**/*.apk"
|
|
retention-days: 1
|
|
|
|
release-app:
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- prepare-build
|
|
- build-app
|
|
steps:
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
|
|
with:
|
|
merge-multiple: true
|
|
|
|
- name: Setup Android SDK
|
|
run: |
|
|
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager "build-tools;29.0.3"
|
|
|
|
- name: Sign APK
|
|
uses: r0adkll/sign-android-release@349ebdef58775b1e0d8099458af0816dc79b6407 # v1
|
|
with:
|
|
releaseDirectory: app/build/outputs/apk/standard/release
|
|
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
|
|
alias: ${{ secrets.ALIAS }}
|
|
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
|
|
keyPassword: ${{ secrets.KEY_PASSWORD }}
|
|
|
|
- name: Get SHA & clean up build artifacts
|
|
id: get_sha
|
|
run: |
|
|
set -e
|
|
|
|
mv app/build/outputs/apk/standard/release/app-standard-universal-release-unsigned-signed.apk Komikku-${{ needs.prepare-build.outputs.VERSION_TAG }}.apk
|
|
sha=`sha256sum Komikku-${{ needs.prepare-build.outputs.VERSION_TAG }}.apk | awk '{ print $1 }'`
|
|
echo "APK_UNIVERSAL_SHA=$sha" >> $GITHUB_OUTPUT
|
|
|
|
mv app/build/outputs/apk/standard/release/app-standard-arm64-v8a-release-unsigned-signed.apk Komikku-arm64-v8a-${{ needs.prepare-build.outputs.VERSION_TAG }}.apk
|
|
sha=`sha256sum Komikku-arm64-v8a-${{ needs.prepare-build.outputs.VERSION_TAG }}.apk | awk '{ print $1 }'`
|
|
echo "APK_ARM64_V8A_SHA=$sha" >> $GITHUB_OUTPUT
|
|
|
|
mv app/build/outputs/apk/standard/release/app-standard-armeabi-v7a-release-unsigned-signed.apk Komikku-armeabi-v7a-${{ needs.prepare-build.outputs.VERSION_TAG }}.apk
|
|
sha=`sha256sum Komikku-armeabi-v7a-${{ needs.prepare-build.outputs.VERSION_TAG }}.apk | awk '{ print $1 }'`
|
|
echo "APK_ARMEABI_V7A_SHA=$sha" >> $GITHUB_OUTPUT
|
|
|
|
mv app/build/outputs/apk/standard/release/app-standard-x86-release-unsigned-signed.apk Komikku-x86-${{ needs.prepare-build.outputs.VERSION_TAG }}.apk
|
|
sha=`sha256sum Komikku-x86-${{ needs.prepare-build.outputs.VERSION_TAG }}.apk | awk '{ print $1 }'`
|
|
echo "APK_X86_SHA=$sha" >> $GITHUB_OUTPUT
|
|
|
|
mv app/build/outputs/apk/standard/release/app-standard-x86_64-release-unsigned-signed.apk Komikku-x86_64-${{ needs.prepare-build.outputs.VERSION_TAG }}.apk
|
|
sha=`sha256sum Komikku-x86_64-${{ needs.prepare-build.outputs.VERSION_TAG }}.apk | awk '{ print $1 }'`
|
|
echo "APK_X86_64_SHA=$sha" >> $GITHUB_OUTPUT
|
|
|
|
- name: Create release
|
|
uses: softprops/action-gh-release@e7a8f85e1c67a31e6ed99a94b41bd0b71bbee6b8 # v2.0.9
|
|
with:
|
|
tag_name: ${{ needs.prepare-build.outputs.VERSION_TAG }}
|
|
name: Komikku ${{ needs.prepare-build.outputs.VERSION_TAG }}
|
|
body: |
|
|
#### What's Changed
|
|
##### New
|
|
|
|
##### Improve
|
|
|
|
##### Fix
|
|
|
|
${{ needs.prepare-build.outputs.COMMIT_LOGS }}
|
|
|
|
##### Based on
|
|
|
|
**Full Changelog**: [komikku-app/komikku@${{ needs.prepare-build.outputs.PREV_TAG_NAME }}...${{ needs.prepare-build.outputs.VERSION_TAG }}](https://github.com/komikku-app/komikku/compare/${{ needs.prepare-build.outputs.PREV_TAG_NAME }}...${{ needs.prepare-build.outputs.VERSION_TAG }})
|
|
|
|
---
|
|
|
|
### Checksums
|
|
|
|
| Variant | SHA-256 |
|
|
| ------- | ------- |
|
|
| Universal | ${{ steps.get_sha.outputs.APK_UNIVERSAL_SHA }} |
|
|
| arm64-v8a | ${{ steps.get_sha.outputs.APK_ARM64_V8A_SHA }} |
|
|
| armeabi-v7a | ${{ steps.get_sha.outputs.APK_ARMEABI_V7A_SHA }} |
|
|
| x86 | ${{ steps.get_sha.outputs.APK_X86_SHA }} |
|
|
| x86_64 | ${{ steps.get_sha.outputs.APK_X86_64_SHA }} |
|
|
|
|
### If you are unsure which apk to download then go with `Komikku-${{ needs.prepare-build.outputs.VERSION_TAG }}.apk`
|
|
files: |
|
|
Komikku-${{ needs.prepare-build.outputs.VERSION_TAG }}.apk
|
|
Komikku-arm64-v8a-${{ needs.prepare-build.outputs.VERSION_TAG }}.apk
|
|
Komikku-armeabi-v7a-${{ needs.prepare-build.outputs.VERSION_TAG }}.apk
|
|
Komikku-x86-${{ needs.prepare-build.outputs.VERSION_TAG }}.apk
|
|
Komikku-x86_64-${{ needs.prepare-build.outputs.VERSION_TAG }}.apk
|
|
draft: true
|
|
prerelease: false
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|