Skip to content

Commit

Permalink
Update github workflow script
Browse files Browse the repository at this point in the history
  • Loading branch information
cuong-tran committed Jan 24, 2024
1 parent 101999e commit d0f1830
Show file tree
Hide file tree
Showing 4 changed files with 238 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ jobs:
- name: Upload APK
uses: actions/upload-artifact@v3
with:
name: TachiyomiSY-${{ github.sha }}.apk
name: Komikku-${{ github.sha }}.apk
path: app/build/outputs/apk/dev/debug/app-dev-debug.apk
160 changes: 160 additions & 0 deletions .github/workflows/build_preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
name: Preview Builder
on:
push:
branches:
- master

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build preview app
runs-on: ubuntu-latest

steps:
- name: Clone repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Prepare build
run: |
set -e
git fetch --tags
prev_release_sha=$(git log --oneline --decorate --tags --no-walk --pretty='%C(auto)%h' | head -n 1)
echo "PREV_RELEASE_SHA=$prev_release_sha" >> $GITHUB_ENV
current_sha=$(git log -1 --pretty='%C(auto)%h' | head -n 1)
echo "CURRENT_SHA=$current_sha" >> $GITHUB_ENV
echo "COMMIT_LOGS<<{delimiter}
$(curl -H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/cuong-tran/komikku/compare/$prev_release_sha...$current_sha" \
| jq '[.commits[]|{message:(.commit.message | split("\n")), username:.author.login}]' \
| jq -r '.[]|"- \(.message | first) (@\(.username))"')
{delimiter}" >> $GITHUB_ENV
- name: Set CHANGELOG
run: |
changelog="$(git log ${{ env.PREV_RELEASE_SHA }}..${{ env.CURRENT_SHA }} --pretty=format:'{{changelogtext}}%s (@%an){{!changelogtext}}')"
changelog="${changelog//$'%'/%25}"
changelog="${changelog//$'\n'/}"
changelog="${changelog//$'\r'/}"
changelog="${changelog//$'<'/}"
changelog="${changelog//$'>'/}"
changelog="${changelog//$'&'/}"
changelog="$(echo $changelog | sed -e 's/{{changelogtext}}/<changelogtext>/g')"
changelog="$(echo $changelog | sed -e 's/{{!changelogtext}}/<\/changelogtext>/g')"
changelog="<?xml version=\"1.0\" encoding=\"utf-8\"?><changelog bulletedList=\"true\"><changelogversion versionName=\"${{ github.run_number }}\" changeDate=\"\">$changelog</changelogversion></changelog>"
echo "CHANGELOG=$changelog" >> $GITHUB_ENV
- 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@v4
with:
java-version: 17
distribution: adopt

- name: Write Version.kt
uses: DamianReeves/[email protected]
with:
path: app/src/main/java/exh/Version.kt
contents: 'package exh const val syDebugVersion: String = "${{ github.run_number }}"'
write-mode: overwrite

- name: Write changelog_debug.xml
uses: DamianReeves/[email protected]
with:
path: app/src/main/res/raw/changelog_debug.xml
contents: "${{ env.CHANGELOG }}"
write-mode: overwrite

- name: Write google-services.json
uses: DamianReeves/[email protected]
with:
path: app/google-services.json
contents: ${{ secrets.GOOGLE_SERVICES_TEXT }}
write-mode: overwrite

- name: Build app
if: ${{ ! startsWith(github.ref, 'refs/tags/') && github.repository == 'cuong-tran/komikku' }}
uses: gradle/gradle-command-action@v2
with:
arguments: assembleStandardRelease -x ktlintFormat --stacktrace

- name: Sign Android Release
if: ${{ ! startsWith(github.ref, 'refs/tags/') && github.repository == 'cuong-tran/komikku' }}
uses: r0adkll/sign-android-release@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: Clean up build artifacts
if: ${{ ! startsWith(github.ref, 'refs/tags/') && github.repository == 'cuong-tran/komikku' }}
run: |
set -e
mv app/build/outputs/apk/standard/release/app-standard-universal-release-unsigned-signed.apk Komikku-pre-${{ github.run_number }}.apk
sha=`sha256sum Komikku-pre-${{ github.run_number }}.apk | awk '{ print $1 }'`
echo "APK_UNIVERSAL_SHA=$sha" >> $GITHUB_ENV
cp app/build/outputs/apk/standard/release/app-standard-arm64-v8a-release-unsigned-signed.apk Komikku-arm64-v8a-pre-${{ github.run_number }}.apk
sha=`sha256sum Komikku-arm64-v8a-pre-${{ github.run_number }}.apk | awk '{ print $1 }'`
echo "APK_ARM64_V8A_SHA=$sha" >> $GITHUB_ENV
cp app/build/outputs/apk/standard/release/app-standard-armeabi-v7a-release-unsigned-signed.apk Komikku-armeabi-v7a-pre-${{ github.run_number }}.apk
sha=`sha256sum Komikku-armeabi-v7a-pre-${{ github.run_number }}.apk | awk '{ print $1 }'`
echo "APK_ARMEABI_V7A_SHA=$sha" >> $GITHUB_ENV
cp app/build/outputs/apk/standard/release/app-standard-x86-release-unsigned-signed.apk Komikku-x86-pre-${{ github.run_number }}.apk
sha=`sha256sum Komikku-x86-pre-${{ github.run_number }}.apk | awk '{ print $1 }'`
echo "APK_X86_SHA=$sha" >> $GITHUB_ENV
cp app/build/outputs/apk/standard/release/app-standard-x86_64-release-unsigned-signed.apk Komikku-x86_64-pre-${{ github.run_number }}.apk
sha=`sha256sum Komikku-x86_64-pre-${{ github.run_number }}.apk | awk '{ print $1 }'`
echo "APK_X86_64_SHA=$sha" >> $GITHUB_ENV
- name: Create release
if: ${{ ! startsWith(github.ref, 'refs/tags/') && github.repository == 'cuong-tran/komikku' }}
uses: softprops/action-gh-release@v1
with:
tag_name: pre-release
name: Komikku Preview Build ${{ github.run_number }}
body: |
### Commits
https://github.com/cuongtran/komikku/compare/${{ env.PREV_RELEASE_SHA }}...${{ env.CURRENT_SHA }}
${{ env.COMMIT_LOGS }}
---
### Checksums
| Variant | SHA-256 |
| ------- | ------- |
| Universal | ${{ env.APK_UNIVERSAL_SHA }} |
| arm64-v8a | ${{ env.APK_ARM64_V8A_SHA }} |
| armeabi-v7a | ${{ env.APK_ARMEABI_V7A_SHA }} |
| x86 | ${{ env.APK_X86_SHA }} |
| x86_64 | ${{ env.APK_X86_64_SHA }} |
files: |
Komikku-pre-${{ github.run_number }}.apk
Komikku-arm64-v8a-pre-${{ github.run_number }}.apk
Komikku-armeabi-v7a-pre-${{ github.run_number }}.apk
Komikku-x86-pre-${{ github.run_number }}.apk
Komikku-x86_64-pre-${{ github.run_number }}.apk
draft: false
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94 changes: 74 additions & 20 deletions .github/workflows/build_push.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Release Builder
on:
push:
branches:
- master
tags:
- v*

Expand All @@ -12,12 +10,47 @@ concurrency:

jobs:
build:
name: Build app
name: Build release app
runs-on: ubuntu-latest

steps:
- name: Clone repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Prepare build
run: |
set -e
git fetch --tags
prev_release_sha=$(git log --oneline --decorate --tags --no-walk --pretty='%C(auto)%h' | head -n 2 | tail -1)
echo "PREV_RELEASE_SHA=$prev_release_sha" >> $GITHUB_ENV
current_sha=$(git log --oneline --decorate --tags --no-walk --pretty='%C(auto)%h' | head -n 1)
echo "CURRENT_SHA=$current_sha" >> $GITHUB_ENV
echo "COMMIT_LOGS<<{delimiter}
$(curl -H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/cuong-tran/komikku/compare/$prev_release_sha...$current_sha" \
| jq '[.commits[]|{message:(.commit.message | split("\n")), username:.author.login}]' \
| jq -r '.[]|"- \(.message | first) (@\(.username))"')
{delimiter}" >> $GITHUB_ENV
- name: Set CHANGELOG
run: |
changelog="$(git log ${{ env.PREV_RELEASE_SHA }}..${{ env.CURRENT_SHA }} --pretty=format:'{{changelogtext}}%s (@%an){{!changelogtext}}')"
changelog="${changelog//$'%'/%25}"
changelog="${changelog//$'\n'/}"
changelog="${changelog//$'\r'/}"
changelog="${changelog//$'<'/}"
changelog="${changelog//$'>'/}"
changelog="${changelog//$'&'/}"
changelog="$(echo $changelog | sed -e 's/{{changelogtext}}/<changelogtext>/g')"
changelog="$(echo $changelog | sed -e 's/{{!changelogtext}}/<\/changelogtext>/g')"
changelog="<?xml version=\"1.0\" encoding=\"utf-8\"?><changelog bulletedList=\"true\"><changelogversion versionName=\"${{ github.run_number }}\" changeDate=\"\">$changelog</changelogversion></changelog>"
echo "CHANGELOG=$changelog" >> $GITHUB_ENV
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
Expand All @@ -42,11 +75,20 @@ jobs:
# SY -->

- name: Build app and run unit tests
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'cuong-tran/komikku'
uses: gradle/gradle-command-action@v2
with:
arguments: assembleStandardRelease testStandardReleaseUnitTest --stacktrace

# Sign APK and create release for tags
- name: Get tag name
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'cuong-tran/komikku'
run: |
set -x
echo "VERSION_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: Sign APK
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'cuong-tran/komikku'
uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: app/build/outputs/apk/standard/release
Expand All @@ -56,35 +98,47 @@ jobs:
keyPassword: ${{ secrets.KEY_PASSWORD }}

- name: Clean up build artifacts
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'cuong-tran/komikku'
run: |
set -e
mv app/build/outputs/apk/standard/release/app-standard-universal-release-unsigned-signed.apk komikku-${{ env.VERSION_TAG }}.apk
sha=`sha256sum komikku-${{ env.VERSION_TAG }}.apk | awk '{ print $1 }'`
mv app/build/outputs/apk/standard/release/app-standard-universal-release-unsigned-signed.apk Komikku-${{ env.VERSION_TAG }}.apk
sha=`sha256sum Komikku-${{ env.VERSION_TAG }}.apk | awk '{ print $1 }'`
echo "APK_UNIVERSAL_SHA=$sha" >> $GITHUB_ENV
cp app/build/outputs/apk/standard/release/app-standard-arm64-v8a-release-unsigned-signed.apk komikku-arm64-v8a-${{ env.VERSION_TAG }}.apk
sha=`sha256sum komikku-arm64-v8a-${{ env.VERSION_TAG }}.apk | awk '{ print $1 }'`
cp app/build/outputs/apk/standard/release/app-standard-arm64-v8a-release-unsigned-signed.apk Komikku-arm64-v8a-${{ env.VERSION_TAG }}.apk
sha=`sha256sum Komikku-arm64-v8a-${{ env.VERSION_TAG }}.apk | awk '{ print $1 }'`
echo "APK_ARM64_V8A_SHA=$sha" >> $GITHUB_ENV
cp app/build/outputs/apk/standard/release/app-standard-armeabi-v7a-release-unsigned-signed.apk komikku-armeabi-v7a-${{ env.VERSION_TAG }}.apk
sha=`sha256sum komikku-armeabi-v7a-${{ env.VERSION_TAG }}.apk | awk '{ print $1 }'`
cp app/build/outputs/apk/standard/release/app-standard-armeabi-v7a-release-unsigned-signed.apk Komikku-armeabi-v7a-${{ env.VERSION_TAG }}.apk
sha=`sha256sum Komikku-armeabi-v7a-${{ env.VERSION_TAG }}.apk | awk '{ print $1 }'`
echo "APK_ARMEABI_V7A_SHA=$sha" >> $GITHUB_ENV
cp app/build/outputs/apk/standard/release/app-standard-x86-release-unsigned-signed.apk komikku-x86-${{ env.VERSION_TAG }}.apk
sha=`sha256sum komikku-x86-${{ env.VERSION_TAG }}.apk | awk '{ print $1 }'`
cp app/build/outputs/apk/standard/release/app-standard-x86-release-unsigned-signed.apk Komikku-x86-${{ env.VERSION_TAG }}.apk
sha=`sha256sum Komikku-x86-${{ env.VERSION_TAG }}.apk | awk '{ print $1 }'`
echo "APK_X86_SHA=$sha" >> $GITHUB_ENV
cp app/build/outputs/apk/standard/release/app-standard-x86_64-release-unsigned-signed.apk komikku-x86_64-${{ env.VERSION_TAG }}.apk
sha=`sha256sum komikku-x86_64-${{ env.VERSION_TAG }}.apk | awk '{ print $1 }'`
cp app/build/outputs/apk/standard/release/app-standard-x86_64-release-unsigned-signed.apk Komikku-x86_64-${{ env.VERSION_TAG }}.apk
sha=`sha256sum Komikku-x86_64-${{ env.VERSION_TAG }}.apk | awk '{ print $1 }'`
echo "APK_X86_64_SHA=$sha" >> $GITHUB_ENV
- name: Create release
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'cuong-tran/komikku'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.VERSION_TAG }}
name: Komikku ${{ env.VERSION_TAG }}
body: |
Change logs:
${{ env.CHANGE_LOGS }}
### Commits
https://github.com/cuongtran/komikku/compare/${{ env.PREV_RELEASE_SHA }}...${{ env.CURRENT_SHA }}
${{ env.COMMIT_LOGS }}
---
### Checksums
Expand All @@ -97,14 +151,14 @@ jobs:
| x86 | ${{ env.APK_X86_SHA }} |
| x86_64 | ${{ env.APK_X86_64_SHA }} |
If you are unsure which version to choose then go with komikku-${{ env.VERSION_TAG }}.apk
If you are unsure which version to choose then go with Komikku-${{ env.VERSION_TAG }}.apk
files: |
komikku-${{ env.VERSION_TAG }}.apk
komikku-arm64-v8a-${{ env.VERSION_TAG }}.apk
komikku-armeabi-v7a-${{ env.VERSION_TAG }}.apk
komikku-x86-${{ env.VERSION_TAG }}.apk
komikku-x86_64-${{ env.VERSION_TAG }}.apk
draft: true
Komikku-${{ env.VERSION_TAG }}.apk
Komikku-arm64-v8a-${{ env.VERSION_TAG }}.apk
Komikku-armeabi-v7a-${{ env.VERSION_TAG }}.apk
Komikku-x86-${{ env.VERSION_TAG }}.apk
Komikku-x86_64-${{ env.VERSION_TAG }}.apk
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/build_push_preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ name: Remote Dispatch Action Initiator
on:
push:
branches:
- 'master'
- 'preview'

jobs:
trigger_preview_build:
name: Trigger preview build
if: ${{ github.ref == 'refs/heads/master' }}
if: ${{ github.ref == 'refs/heads/preview' }}
runs-on: ubuntu-latest

steps:
Expand All @@ -23,7 +23,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
RELEASE_BRANCHES: master
RELEASE_BRANCHES: preview
DEFAULT_BUMP: patch

- name: PING - Dispatch initiating repository event
Expand Down

0 comments on commit d0f1830

Please sign in to comment.