Skip to content

Commit

Permalink
👷 添加Android自动构建
Browse files Browse the repository at this point in the history
  • Loading branch information
zty012 committed Dec 14, 2024
1 parent 7e1566b commit 43e928c
Show file tree
Hide file tree
Showing 2 changed files with 169 additions and 8 deletions.
89 changes: 85 additions & 4 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# 创建一个release
create-release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- run: gh release create nightly --title "Nightly Build" --body "如果下面没有可下载的文件,说明构建失败,请联系开发者" --prerelease
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# 开始构建并发布 Nightly Release
publish-tauri:
permissions:
Expand Down Expand Up @@ -91,9 +102,79 @@ jobs:
LR_GITHUB_CLIENT_SECRET: ${{ secrets.ENV_GITHUB_CLIENT_SECRET }}
LR_ARK_API_KEY: ${{ secrets.ENV_ARK_API_KEY }}
with:
# upload to release
tagName: "nightly"
releaseName: "Nightly Build"
releaseBody: ""
releaseDraft: false
prerelease: true
args: ${{ matrix.args }}

publish-tauri-android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "zulu"
java-version: "17"

- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Install NDK
run: sdkmanager "ndk;27.0.11902837"

- name: setup node
uses: actions/setup-node@v4
with:
node-version: lts/*

- name: install pnpm
run: npm install -g pnpm

- name: install Rust stable
uses: dtolnay/rust-toolchain@stable # Set this to dtolnay/rust-toolchain@nightly
with:
# Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
targets: "aarch64-linux-android,x86_64-linux-android"

- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: "./src-tauri -> target"

- name: install frontend dependencies
# If you don't have `beforeBuildCommand` configured you may want to build your frontend here too.
run: pnpm install # change this to npm or pnpm depending on which one you use.

- name: edit version
run: |
sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"0.0.1\"/" src-tauri/tauri.conf.json
- name: setup sign
run: |
cd src-tauri/gen/android
# create keystore.properties
cat > keystore.properties <<EOF
password=${{ secrets.ANDROID_RELEASE_PASSWORD }}
keyAlias=upload
storeFile=upload.jks
EOF
# create upload.jks
echo "${{ secrets.ANDROID_RELEASE_KEYSTORE }}" | base64 --decode > upload.jks
- name: build
run: pnpm tauri android build -v
env:
NDK_HOME: ${{ env.ANDROID_HOME }}/ndk/27.0.11902837
LR_GITHUB_CLIENT_SECRET: ${{ secrets.ENV_GITHUB_CLIENT_SECRET }}
LR_ARK_API_KEY: ${{ secrets.ENV_ARK_API_KEY }}

- name: rename apk file
run: |
cd src-tauri/gen/android/app/build/outputs/apk/universal/release
mv app-universal-release.apk Project.Graph_0.0.0-nightly.${{ github.sha }}_universal-signed.apk
- name: upload
run: gh release upload nightly src-tauri/gen/android/app/build/outputs/apk/universal/release/Project.Graph_0.0.0-nightly.${{ github.sha }}_universal-signed.apk --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88 changes: 84 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ on:
required: true

jobs:
# 创建一个release
create-release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- run: gh release create v${{ github.event.inputs.version }} --title "Release v${{ github.event.inputs.version }}" --body "如果下面没有可下载的文件,说明构建失败,请联系开发者"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish-tauri:
permissions:
contents: write
Expand Down Expand Up @@ -83,8 +94,77 @@ jobs:
LR_ARK_API_KEY: ${{ secrets.ENV_ARK_API_KEY }}
with:
tagName: "v${{ github.event.inputs.version }}"
releaseName: "Release v${{ github.event.inputs.version }}"
releaseBody: ""
releaseDraft: false
prerelease: false
args: ${{ matrix.args }}

publish-tauri-android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "zulu"
java-version: "17"

- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Install NDK
run: sdkmanager "ndk;27.0.11902837"

- name: setup node
uses: actions/setup-node@v4
with:
node-version: lts/*

- name: install pnpm
run: npm install -g pnpm

- name: install Rust stable
uses: dtolnay/rust-toolchain@stable # Set this to dtolnay/rust-toolchain@nightly
with:
# Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
targets: "aarch64-linux-android,x86_64-linux-android"

- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: "./src-tauri -> target"

- name: install frontend dependencies
# If you don't have `beforeBuildCommand` configured you may want to build your frontend here too.
run: pnpm install # change this to npm or pnpm depending on which one you use.

- name: edit version
run: |
sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"${{ github.event.inputs.version }}\"/" src-tauri/tauri.conf.json
- name: setup sign
run: |
cd src-tauri/gen/android
# create keystore.properties
cat > keystore.properties <<EOF
password=${{ secrets.ANDROID_RELEASE_PASSWORD }}
keyAlias=upload
storeFile=upload.jks
EOF
# create upload.jks
echo "${{ secrets.ANDROID_RELEASE_KEYSTORE }}" | base64 --decode > upload.jks
- name: build
run: pnpm tauri android build -v
env:
NDK_HOME: ${{ env.ANDROID_HOME }}/ndk/27.0.11902837
LR_GITHUB_CLIENT_SECRET: ${{ secrets.ENV_GITHUB_CLIENT_SECRET }}
LR_ARK_API_KEY: ${{ secrets.ENV_ARK_API_KEY }}

- name: rename apk file
run: |
cd src-tauri/gen/android/app/build/outputs/apk/universal/release
mv app-universal-release.apk Project.Graph_${{ github.event.inputs.version }}_universal-signed.apk
- name: upload
run: gh release upload v${{ github.event.inputs.version }} src-tauri/gen/android/app/build/outputs/apk/universal/release/Project.Graph_${{ github.event.inputs.version }}_universal-signed.apk --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 43e928c

Please sign in to comment.