Skip to content

Release Build

Release Build #121

Workflow file for this run

name: Release Build
on:
workflow_dispatch:
env:
ANDROID_NDK_VERSION: r25c
COMMIT_ID: "${{ github.sha }}"
NO_BUILD_PROMPT: "no new commits, no need to build."
jobs:
commit-num-check:
name: Check Commit Num
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- name: Get New Commits
id: get-commits
run: echo "NEW_COMMIT_COUNT=$(git log --oneline --since '24 hours ago' | wc -l)" >> $GITHUB_OUTPUT
- name: Get Commit IDs
id: get-commit-ids
run: |
echo "UI_CID=`cd sealdice-ui && git rev-parse HEAD`" >> $GITHUB_OUTPUT;
echo "CORE_CID=`cd sealdice-core && git rev-parse HEAD`" >> $GITHUB_OUTPUT;
# echo "ANDROID_VERSION=`cd sealdice-android && git describe --tags --abbrev=0`" >> $GITHUB_OUTPUT;
- name: Get Version
id: get-version
run: |
cd sealdice-core
# echo "PROJECT_VERSION=dev-${COMMIT_ID::7}" >> "$GITHUB_OUTPUT";
echo "PROJECT_VERSION=1.4.5" >> "$GITHUB_OUTPUT";
echo "PROJECT_VERSION_DISPLAY=v1.4.5 v20240410" >> "$GITHUB_OUTPUT";
echo "ANDROID_VERSION=v0.6.1" >> $GITHUB_OUTPUT;
- name: Warning
run: if [ $(git log --oneline --since '24 hours ago' | wc -l) <= 0 ]; then echo $NO_BUILD_PROMPT; fi
outputs:
commit-count: ${{ steps.get-commits.outputs.NEW_COMMIT_COUNT }}
CORE_CID: ${{ steps.get-commit-ids.outputs.CORE_CID }}
UI_CID: ${{ steps.get-commit-ids.outputs.UI_CID }}
ANDROID_VERSION: ${{ steps.get-commit-ids.outputs.ANDROID_VERSION }}
PROJECT_VERSION: ${{ steps.get-version.outputs.PROJECT_VERSION }}
PROJECT_VERSION_DISPLAY: ${{ steps.get-version.outputs.PROJECT_VERSION_DISPLAY }}
resources-download:
name: Download Related Resources
runs-on: ubuntu-latest
needs: commit-num-check
if: ${{ needs.commit-num-check.outputs.commit-count > 0 }}
steps:
- name: Code
uses: actions/checkout@v3
with:
submodules: true
- name: Upload Documents
uses: actions/upload-artifact@v4
with:
name: documents
path: ./sealdice-builtins/data
lagrange-download:
name: Download Lagrange
runs-on: ubuntu-latest
needs: commit-num-check
if: ${{ needs.commit-num-check.outputs.commit-count > 0 }}
steps:
- name: Download
run: |
mkdir lag
curl https://d1.sealdice.com/lagrange/0.0.3/Lagrange.OneBot_linux-arm64_7.0.zip?v=1 > lag/Lagrange.OneBot.linux-arm64.zip
curl https://d1.sealdice.com/lagrange/0.0.3/Lagrange.OneBot_linux-x64_7.0.zip > lag/Lagrange.OneBot.linux-amd64.zip
curl https://d1.sealdice.com/lagrange/0.0.3/Lagrange.OneBot_win-x64_7.0.zip > lag/Lagrange.OneBot.windows-amd64.zip
curl https://d1.sealdice.com/lagrange/0.0.3/Lagrange.OneBot_win-x86_7.0.zip > lag/Lagrange.OneBot.windows-386.zip
curl https://d1.sealdice.com/lagrange/0.0.3/Lagrange.OneBot_osx-arm64_7.0.zip > lag/Lagrange.OneBot.darwin-arm64.zip
curl https://d1.sealdice.com/lagrange/0.0.3/Lagrange.OneBot_osx-x64_7.0.zip > lag/Lagrange.OneBot.darwin-amd64.zip
curl https://d1.sealdice.com/lagrange/0.0.3/Lagrange.OneBot_linux-musl-arm64_7.0.zip > lag/Lagrange.OneBot.android-arm64.zip
- name: Upload
uses: actions/upload-artifact@v4
with:
name: lagrange
path: ./lag
lagrange-setup:
name: Download Lagrange
runs-on: ubuntu-latest
needs: lagrange-download
strategy:
matrix:
# target: linux/amd64, linux/arm64, windows/386, windows/amd64, darwin/amd64, darwin/arm64
goos: [ linux, windows, darwin, android ]
goarch: [ '386', amd64, arm64 ]
exclude:
- goos: linux
goarch: '386'
- goos: windows
goarch: arm64
- goos: darwin
goarch: '386'
- goos: android
goarch: amd64
- goos: android
goarch: '386'
steps:
- name: Get Lagrange
uses: actions/download-artifact@v4
with:
name: lagrange
path: ./lagrange
- name: Extract
run: |
mkdir extract
ls ./lagrange/Lagrange.OneBot.${{ matrix.goos }}-${{ matrix.goarch }}.zip
file ./lagrange/Lagrange.OneBot.${{ matrix.goos }}-${{ matrix.goarch }}.zip
unzip ./lagrange/Lagrange.OneBot.${{ matrix.goos }}-${{ matrix.goarch }}.zip -d ./extract/Lagrange.OneBot.${{ matrix.goos }}-${{ matrix.goarch }}
- name: Upload
uses: actions/upload-artifact@v4
with:
name: lagrange.${{ matrix.goos }}-${{ matrix.goarch }}
path: ./extract/Lagrange.OneBot.${{ matrix.goos }}-${{ matrix.goarch }}
ui-build:
name: Build UI
runs-on: ubuntu-latest
needs: commit-num-check
if: ${{ needs.commit-num-check.outputs.commit-count > 0 }}
env:
UI_CID: ${{needs.commit-num-check.outputs.UI_CID}}
steps:
- name: Cache ui dist get
id: cache-ui-dist
uses: actions/cache@v3
env:
cache-name: cache-ui-dist
with:
path: ./sealdice-ui/dist
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.UI_CID }}
- name: Code
if: ${{ steps.cache-ui-dist.outputs.cache-hit != 'true' }}
uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- if: ${{ steps.cache-ui-dist.outputs.cache-hit == 'true' }}
name: Show cache
continue-on-error: true
run: ls ./sealdice-ui/dist
- name: Install Node
uses: actions/setup-node@v3
if: ${{ steps.cache-ui-dist.outputs.cache-hit != 'true' }}
with:
node-version: latest
- name: Install Dependencies
if: ${{ steps.cache-ui-dist.outputs.cache-hit != 'true' }}
working-directory: ./sealdice-ui
run: npm install
- name: Build WebUI
if: ${{ steps.cache-ui-dist.outputs.cache-hit != 'true' }}
working-directory: ./sealdice-ui
run: npm run build
- name: Upload UI
uses: actions/upload-artifact@v4
with:
name: sealdice-ui
path: ./sealdice-ui/dist
core-build:
name: Build Core
runs-on: ubuntu-20.04
needs:
- commit-num-check
- ui-build
env:
CORE_CID: ${{needs.commit-num-check.outputs.CORE_CID}}
PROJECT_VERSION: ${{needs.commit-num-check.outputs.PROJECT_VERSION}}
strategy:
matrix:
# target: linux/amd64, linux/arm64, windows/386, windows/amd64
goos: [ linux, windows ]
goarch: [ '386', amd64, arm64 ]
exclude:
- goos: linux
goarch: '386'
- goos: windows
goarch: arm64
fail-fast: true
steps:
# - name: Cache dist get
# id: cache-core-dist
# uses: actions/cache@v3
# env:
# cache-name: cache-core-${{ matrix.goos }}-${{ matrix.goarch }}
# with:
# path: ./sealdice-core/output
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.CORE_CID }}
- name: Apt-get Update
run: sudo apt-get update
- name: Code
if: steps.cache-core-dist.outputs.cache-hit != 'true'
uses: actions/checkout@v3
with:
submodules: true
- name: Install Cross-compiler for Windows
if: matrix.goos == 'windows' && steps.cache-core-dist.outputs.cache-hit != 'true'
run: sudo apt-get -y install mingw-w64
- name: Install Cross-compiler for Linux Arm64
if: matrix.goos == 'linux' && matrix.goarch == 'arm64' && steps.cache-core-dist.outputs.cache-hit != 'true'
run: sudo apt-get -y install gcc-aarch64-linux-gnu
- name: Install Go
uses: actions/setup-go@v3
if: steps.cache-core-dist.outputs.cache-hit != 'true'
with:
go-version: '1.20'
- name: Install Dependencies
if: steps.cache-core-dist.outputs.cache-hit != 'true'
working-directory: ./sealdice-core
run: |
go mod tidy
go get .
- name: Get UI Resources
if: steps.cache-core-dist.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
name: sealdice-ui
path: ./sealdice-core/static/frontend
- name: Set Env
if: steps.cache-core-dist.outputs.cache-hit != 'true'
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
working-directory: ./sealdice-core
run: |
if [ $GOOS = 'windows' ]; then
echo "BINARY_NAME=sealdice-core.exe" >> $GITHUB_ENV;
else
echo "BINARY_NAME=sealdice-core" >> $GITHUB_ENV;
fi
if [ $GOOS = 'windows' ] && [ $GOARCH = '386' ]; then
echo "CC=i686-w64-mingw32-gcc" >> $GITHUB_ENV;
elif [ $GOOS = 'windows' ] && [ $GOARCH = 'amd64' ]; then
echo "CC=x86_64-w64-mingw32-gcc" >> $GITHUB_ENV;
elif [ $GOOS = 'linux' ] && [ $GOARCH = 'amd64' ]; then
echo "CC=gcc" >> $GITHUB_ENV;
elif [ $GOOS = 'linux' ] && [ $GOARCH = 'arm64' ]; then
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV;
fi
- name: Build Binary
if: steps.cache-core-dist.outputs.cache-hit != 'true'
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GO111MODULE: on
# CGO_ENABLED: ${{ matrix.goarch != 'arm64' && 1 || 0 }}
CGO_ENABLED: ${{ matrix.goos == 'windows' && 1 || 0 }} # 为了规避glibc兼容问题,linux上不使用cgo
CGO_FLAGS: -Werror=unused-variable -Werror=implicit-function-declaration -O2 -H=windowsgui
working-directory: ./sealdice-core
run: go build -o "output/$BINARY_NAME" -trimpath -ldflags "-s -w -X sealdice-core/dice.VERSION_PRERELEASE='' -X sealdice-core/dice.VERSION_BUILD_METADATA=+${CUR_TIME}.${COMMIT_ID::7} -X sealdice-core/dice.APP_CHANNEL=stable" .
- name: Upload Core
uses: actions/upload-artifact@v4
with:
name: sealdice-core_${{ env.PROJECT_VERSION }}_${{ matrix.goos }}_${{ matrix.goarch }}
path: ./sealdice-core/output
core-darwin-build:
name: Build Core
runs-on: macos-latest
needs:
- commit-num-check
- ui-build
env:
CORE_CID: ${{needs.commit-num-check.outputs.CORE_CID}}
PROJECT_VERSION: ${{needs.commit-num-check.outputs.PROJECT_VERSION}}
strategy:
matrix:
# target: darwin/amd64 darwin/arm64
goos: [ darwin ]
goarch: [ amd64, arm64 ]
fail-fast: true
steps:
- name: Cache dist get
id: cache-core-dist
uses: actions/cache@v3
env:
cache-name: cache-core-${{ matrix.goos }}-${{ matrix.goarch }}
with:
path: ./sealdice-core/output
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.CORE_CID }}
- name: Code
if: steps.cache-core-dist.outputs.cache-hit != 'true'
uses: actions/checkout@v3
with:
submodules: true
- name: Install Go
if: steps.cache-core-dist.outputs.cache-hit != 'true'
uses: actions/setup-go@v3
with:
go-version: '1.20'
- name: Install dependencies
if: steps.cache-core-dist.outputs.cache-hit != 'true'
working-directory: ./sealdice-core
run: |
go mod tidy
go get .
- name: Get UI Resources
if: steps.cache-core-dist.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
name: sealdice-ui
path: ./sealdice-core/static/frontend
- name: Build Binary
if: steps.cache-core-dist.outputs.cache-hit != 'true'
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GO111MODULE: on
CGO_ENABLED: 1
CGO_FLAGS: -Werror=unused-variable -Werror=implicit-function-declaration -O2
working-directory: ./sealdice-core
run: go build -o "output/sealdice-core" -trimpath -ldflags "-s -w -X sealdice-core/dice.VERSION_PRERELEASE='' -X sealdice-core/dice.VERSION_BUILD_METADATA=+${CUR_TIME}.${COMMIT_ID::7} -X sealdice-core/dice.APP_CHANNEL=stable" .
- name: Upload Core
uses: actions/upload-artifact@v4
with:
name: sealdice-core_${{ env.PROJECT_VERSION }}_${{ matrix.goos }}_${{ matrix.goarch }}
path: ./sealdice-core/output
core-android-build:
name: Build Core (android, arm64)
runs-on: ubuntu-20.04
needs:
- commit-num-check
- ui-build
env:
CORE_CID: ${{needs.commit-num-check.outputs.CORE_CID}}
PROJECT_VERSION: ${{needs.commit-num-check.outputs.PROJECT_VERSION}}
steps:
- name: Cache dist get
id: cache-core-dist
uses: actions/cache@v3
env:
cache-name: cache-core-${{ matrix.goos }}-${{ matrix.goarch }}
with:
path: ./sealdice-core/output
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.CORE_CID }}
- name: Code
if: steps.cache-core-dist.outputs.cache-hit != 'true'
uses: actions/checkout@v3
with:
submodules: true
- name: Setup Android NDK
if: steps.cache-core-dist.outputs.cache-hit != 'true'
id: setup-ndk
uses: nttld/setup-ndk@v1
with:
ndk-version: ${{ env.ANDROID_NDK_VERSION }}
link-to-sdk: true
local-cache: false
- name: Install Go
if: steps.cache-core-dist.outputs.cache-hit != 'true'
uses: actions/setup-go@v3
with:
go-version: '1.20'
- name: Install dependencies
if: steps.cache-core-dist.outputs.cache-hit != 'true'
working-directory: ./sealdice-core
run: |
go mod tidy
go get .
- name: Get UI Resources
if: steps.cache-core-dist.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
name: sealdice-ui
path: ./sealdice-core/static/frontend
- name: Build binary
if: steps.cache-core-dist.outputs.cache-hit != 'true'
env:
GOOS: android
GOARCH: arm64
CGO_ENABLED: 1
CC: ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android33-clang
CGO_FLAGS: -Werror=unused-variable -Werror=implicit-function-declaration -O2
working-directory: ./sealdice-core
run: go build -o "output/sealdice-core" -trimpath -ldflags "-s -w -X sealdice-core/dice.VERSION_PRERELEASE='' -X sealdice-core/dice.VERSION_BUILD_METADATA=+${CUR_TIME}.${COMMIT_ID::7} -X sealdice-core/dice.APP_CHANNEL=stable" .
- name: Upload Core
uses: actions/upload-artifact@v4
with:
name: sealdice-core_${{ env.PROJECT_VERSION }}_android_arm64
path: ./sealdice-core/output
android-build:
name: Build Android Apk
runs-on: ubuntu-20.04
needs:
- commit-num-check
- core-android-build
- resources-download
- lagrange-setup
env:
PROJECT_VERSION: ${{needs.commit-num-check.outputs.PROJECT_VERSION}}
ANDROID_VERSION: ${{needs.commit-num-check.outputs.ANDROID_VERSION}}
steps:
- name: Code
uses: actions/checkout@v3
with:
submodules: true
- name: Get Core-android
uses: actions/download-artifact@v4
with:
name: sealdice-core_${{ env.PROJECT_VERSION }}_android_arm64
path: ./sealdice-android/app/src/main/assets/sealdice
- name: Get Documents
uses: actions/download-artifact@v4
with:
name: documents
path: ./sealdice-android/app/src/main/assets/sealdice/data
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'
- name: Set Execution Flag
working-directory: ./sealdice-android
run: chmod +x gradlew
- name: Remove ARCA Config
working-directory: ./sealdice-android/app/src/main/java/com/sealdice/dice
run: |
sed -i '/secrets.Auth.*/d' MyApplication.kt
sed -i '/httpSender {/,/}/d' MyApplication.kt
- name: Set Version
working-directory: ./sealdice-android/app
run: |
sed -i 's/versionName ".*"/versionName "${{ env.ANDROID_VERSION }}"/g' build.gradle
- name: Build Apk
working-directory: ./sealdice-android
run: |
bash ./gradlew assembleRelease --stacktrace
- name: Sign Android release
uses: r0adkll/sign-android-release@v1
# ID used to access action output
id: sign_app
with:
releaseDirectory: ./sealdice-android/app/build/outputs/apk/release
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
env:
# override default build-tools version (29.0.3) -- optional
BUILD_TOOLS_VERSION: "34.0.0"
- name: Rename Apk
working-directory: ./sealdice-android
run: |
mv ./app/build/outputs/apk/release/app-release-unsigned-signed.apk ./app/build/outputs/apk/release/sealdice_android_${{ env.PROJECT_VERSION }}_arm64.apk
- name: Upload Apk
uses: actions/upload-artifact@v4
with:
name: sealdice_${{ env.PROJECT_VERSION }}_android_arm64
path: ./sealdice-android/app/build/outputs/apk/release/sealdice_android_${{ env.PROJECT_VERSION }}_arm64.apk
- name: prepare
env:
GOARCH: arm64
run: |
cp ./sealdice-android/app/build/outputs/apk/release/sealdice_android_${{ env.PROJECT_VERSION }}_arm64.apk ./sealdice-android_${ANDROID_VERSION}_core_${PROJECT_VERSION}_${GOARCH}.APK
echo "DIST=sealdice-android_${ANDROID_VERSION}_core_${PROJECT_VERSION}_${GOARCH}.APK" >> $GITHUB_ENV;
- name: Upload APK to dist
uses: actions/upload-artifact@v4
with:
name: sealdice-prerelease
path: ${{ env.DIST }}
pc-pack:
name: PC Pack
runs-on: ubuntu-latest
needs:
- resources-download
- core-build
- core-darwin-build
- commit-num-check
- lagrange-setup
env:
PROJECT_VERSION: ${{needs.commit-num-check.outputs.PROJECT_VERSION}}
strategy:
matrix:
# target: linux/amd64, linux/arm64, windows/386, windows/amd64, darwin/amd64, darwin/arm64
goos: [ linux, windows, darwin ]
goarch: [ '386', amd64, arm64 ]
exclude:
- goos: linux
goarch: '386'
- goos: windows
goarch: arm64
- goos: darwin
goarch: '386'
steps:
- name: Get Documents
uses: actions/download-artifact@v4
with:
name: documents
path: ./data
- name: Get Lagrange
uses: actions/download-artifact@v4
with:
name: lagrange.${{ matrix.goos }}-${{ matrix.goarch }}
path: ./lagrange/
- name: Get Core
uses: actions/download-artifact@v4
with:
name: sealdice-core_${{ env.PROJECT_VERSION }}_${{ matrix.goos }}_${{ matrix.goarch }}
path: .
- name: Upload
uses: actions/upload-artifact@v4
with:
name: sealdice_${{ env.PROJECT_VERSION }}_${{ matrix.goos }}_${{ matrix.goarch }}
path: .
preparation:
name: Compressed Files Preparation
runs-on: ubuntu-latest
needs:
- pc-pack
- commit-num-check
env:
PROJECT_VERSION: ${{needs.commit-num-check.outputs.PROJECT_VERSION}}
strategy:
matrix:
# target: linux/amd64, linux/arm64, windows/386, windows/amd64, darwin/amd64, darwin/arm64, android/arm64
goos: [ linux, windows, darwin ]
goarch: [ '386', amd64, arm64 ]
exclude:
- goos: linux
goarch: '386'
- goos: windows
goarch: arm64
- goos: darwin
goarch: '386'
steps:
- name: Get Files
uses: actions/download-artifact@v4
with:
name: sealdice_${{ env.PROJECT_VERSION }}_${{ matrix.goos }}_${{ matrix.goarch }}
path: ./temp/
- name: Compress (default)
if: matrix.goos != 'windows' && matrix.goos != 'android'
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
chmod +x ./temp/sealdice-core
tar -zcvf sealdice-core_${PROJECT_VERSION}_${GOOS}_${GOARCH}.tar.gz -C ./temp .;
echo "DIST=sealdice-core_${PROJECT_VERSION}_${GOOS}_${GOARCH}.tar.gz" >> $GITHUB_ENV;
- name: Compress (windows)
if: matrix.goos == 'windows'
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
cd ./temp
zip -r ../sealdice-core_${PROJECT_VERSION}_${GOOS}_${GOARCH}.zip .
echo "DIST=sealdice-core_${PROJECT_VERSION}_${GOOS}_${GOARCH}.zip" >> $GITHUB_ENV;
- name: Upload
uses: actions/upload-artifact@v3
with:
name: sealdice-prerelease
path: ${{ env.DIST }}
prerelease:
name: PreRelease
runs-on: ubuntu-latest
needs:
- preparation
- android-build
- commit-num-check
env:
PROJECT_VERSION: ${{needs.commit-num-check.outputs.PROJECT_VERSION}}
PROJECT_VERSION_DISPLAY: ${{needs.commit-num-check.outputs.PROJECT_VERSION_DISPLAY}}
permissions:
contents: write
steps:
- name: Get Files
uses: actions/download-artifact@v3
with:
name: sealdice-prerelease
path: ./dist/
- name: Pack All platform
run: |
cd ./dist
mv ./sealdice-core_${PROJECT_VERSION}_windows_386.zip ./sealdice-core_${PROJECT_VERSION}_windows_i386.zip
zip -r ./sealdice-core_all_platform_${PROJECT_VERSION}.zip ./
- name: Update Prerelease
uses: andelf/nightly-release@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.PROJECT_VERSION }}
name: ${{ env.PROJECT_VERSION_DISPLAY }}
prerelease: true
body: '[改动日志](https://sealdice.com/changelog)'
files: |
./dist/sealdice*
clear-temp-artifact:
name: Clear Temp Artifacts
if: always()
runs-on: ubuntu-latest
needs:
- prerelease
steps:
- uses: geekyeggo/delete-artifact@v4
with:
name: |
documents
go-cqhttp*
sealdice-ui
sealdice-core*
sealdice-prerelease