Skip to content

Commit

Permalink
update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Anillc committed Aug 18, 2022
1 parent c2942ee commit 33a28f8
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 53 deletions.
59 changes: 8 additions & 51 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,19 @@
on:
release:
types: [created]
workflow_dispatch:
on: workflow_dispatch

jobs:
release:
strategy:
matrix:
build:
- name: koishi-android
copy: copy
- name: koishi-android-with-chromium
copy: copy-extra
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install nix
uses: cachix/install-nix-action@v15

- name: setup cachix
uses: cachix/cachix-action@v10
with:
name: koishi
authToken: ${{ secrets.CACHIX_TOKEN }}

- uses: actions/setup-java@v3
with:
distribution: adopt
java-version: '11'
cache: gradle

- name: Build
- name: Create release
run: |
export COPY=${{ matrix.build.copy }}
./build.sh
- uses: ilharp/sign-android-release@v1
name: Sign app APK
id: sign_app
with:
keyAlias: koishi-android
signingKey: ${{ secrets.JKS }}
keyStorePassword: ${{ secrets.JKS_PASSWORD }}
keyPassword: ${{ secrets.JKS_PASSWORD }}

- name: Upload
run: |
RELEASE=$(curl \
LATEST_RELEASE=$(curl \
-H 'Accept: application/vnd.github.v3+json' \
-H 'Authorization: token ${{ github.token }}' \
https://api.github.com/repos/${{ github.repository }}/releases/latest)
TAG=$(echo "$RELEASE" | jq -r '.tag_name')
UPLOAD_URL=$(echo "$RELEASE" | jq -r '.upload_url' | cut -d '{' -f 1)
LATEST_TAG=$(echo "$LATEST_RELEASE" | jq -r '.tag_name')
TAG=$(echo $LATEST_TAG | awk -F. '{ print $1 "." $2 "." ($3 + 1) }')
curl -X POST \
-H 'Accept: application/vnd.github.v3+json' \
-H 'Content-Type: octet-stream' \
-H 'Authorization: token ${{ github.token }}' \
--data-binary @${{steps.sign_app.outputs.signedFile}} \
"$UPLOAD_URL?name=${{ matrix.build.name }}-$TAG.apk"
-H 'Authorization: token ${{ secrets.WORKFLOW_TOKEN }}' \
https://api.github.com/repos/${{ github.repository }}/releases \
-d "{\"tag_name\":\"$TAG\"}"
72 changes: 72 additions & 0 deletions .github/workflows/upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
on:
release:
types:
- created
workflow_dispatch:

jobs:
upload:
strategy:
matrix:
build:
- name: koishi-android
copy: copy
- name: koishi-android-with-chromium
copy: copy-extra
runs-on: ubuntu-latest
steps:
- name: Set up variables
id: vars
run: |
RELEASE=$(curl \
-H 'Accept: application/vnd.github.v3+json' \
-H 'Authorization: token ${{ github.token }}' \
https://api.github.com/repos/${{ github.repository }}/releases/latest)
TAG=$(echo "$RELEASE" | jq -r '.tag_name')
UPLOAD_URL=$(echo "$RELEASE" | jq -r '.upload_url' | cut -d '{' -f 1)
echo ::set-output name=TAG::$TAG
echo ::set-output name=UPLOAD_URL::$UPLOAD_URL
- name: Checkout
uses: actions/checkout@v3

- name: Install nix
uses: cachix/install-nix-action@v15

- name: setup cachix
uses: cachix/cachix-action@v10
with:
name: koishi
authToken: ${{ secrets.CACHIX_TOKEN }}

- uses: actions/setup-java@v3
with:
distribution: adopt
java-version: '11'
cache: gradle

- name: Build
run: |
TAG=${{ steps.vars.outputs.TAG }}
export VERSION_CODE=$(echo "${TAG:1}" | sed 's/\.//g')
export VERSION_NAME=$TAG
export COPY=${{ matrix.build.copy }}
./build.sh
- uses: ilharp/sign-android-release@v1
name: Sign app APK
id: sign_app
with:
keyAlias: koishi-android
signingKey: ${{ secrets.JKS }}
keyStorePassword: ${{ secrets.JKS_PASSWORD }}
keyPassword: ${{ secrets.JKS_PASSWORD }}

- name: Upload
run: |
curl -X POST \
-H 'Accept: application/vnd.github.v3+json' \
-H 'Content-Type: octet-stream' \
-H 'Authorization: token ${{ github.token }}' \
--data-binary @${{steps.sign_app.outputs.signedFile}} \
"${{ steps.vars.outputs.UPLOAD_URL }}?name=${{ matrix.build.name }}-${{ steps.vars.outputs.TAG }}.apk"
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId = "cn.anillc.koishi"
minSdk = 24
targetSdk = 28
versionCode = 1
versionName = "0.0.1"
versionCode = System.getenv("VERSION_CODE")?.toIntOrNull() ?: 1
versionName = System.getenv("VERSION_NAME") ?: "0.0.1"
}

buildFeatures {
Expand Down

0 comments on commit 33a28f8

Please sign in to comment.