Skip to content

CI-Build auto upload to Release in Pre-Release #377

CI-Build auto upload to Release in Pre-Release

CI-Build auto upload to Release in Pre-Release #377

Workflow file for this run

name: Android CI
on:
pull_request:
branches-ignore:
- ''
push:
tags:
- '*'
branches-ignore:
- ''
workflow_dispatch:
jobs:
FCLTeamBuild:
if: github.repository_owner == 'FCL-Team' && !startsWith(github.ref, 'refs/pull/')
strategy:
matrix:
arch: [ "all", "arm", "arm64", "x86", "x64" ]
fail-fast: false
env:
FCL_KEYSTORE_PASSWORD: ${{ secrets.FCL_KEYSTORE_PASSWORD }}
CURSE_API_KEY: ${{ secrets.CURSE_API_KEY }}
OAUTH_API_KEY: ${{ secrets.OAUTH_API_KEY }}
name: Build for ${{matrix.arch}}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
- name: Build ${{matrix.arch}} .apk
run: |
chmod +x gradlew
./gradlew assemblerelease -Darch=${{matrix.arch}}
- name: Upload to Artifact
if: startsWith(github.ref, 'refs/heads/')
uses: actions/upload-artifact@v4
with:
name: app-${{matrix.arch}}
path: FCL/build/outputs/apk/release/*
#retention-days: 1
#only for fork
DebugBuild:
if: github.repository_owner != 'FCL-Team' || startsWith(github.ref, 'refs/pull/')
name: Build Debug
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
- name: Build debug apk
run: |
chmod +x gradlew
./gradlew assemblefordebug -Darch=all
- name: Upload debug apk
uses: actions/upload-artifact@v4
with:
name: app-debug-all
path: FCL/build/outputs/apk/fordebug/*
Release:
needs: FCLTeamBuild
runs-on: ubuntu-20.04
if: github.repository_owner == 'FCL-Team' && !startsWith(github.ref, 'refs/pull/')
name: Init & Prepare CI-Build
steps:
- name: Download Artifact Zips
uses: actions/download-artifact@v4
with:
path: FCL/build/outputs/apk/temp
- name: "CI Release Prepare"
id: github-text
run: |
echo "build_time=$(TZ=Asia/Shanghai date "+%Y.%m.%d %H:%M")" >> $GITHUB_OUTPUT
mkdir -p FCL/build/outputs/apk/release
find FCL/build/outputs/apk/temp/ -mindepth 1 -maxdepth 1 -type d -exec sh -c 'mv -v "$0"/* FCL/build/outputs/apk/release/' {} \;
- name: Delete old files
uses: 8Mi-Tech/delete-release-assets-action@main
with:
github_token: "${{ secrets.GITHUB_TOKEN }}"
tag: CI-Build-${{github.ref_name}}
deleteOnlyFromDrafts: false
- name: Set Text
run: |
cat > ci-build.md << 'EOF'
Build Time / 构建时间 : ${{ steps.github-text.outputs.build_time }}
自动同步分支 ${{ github.ref_name }} 的代码,以保持最新
Synchronize ${{ github.ref_name }} branch code updates, keeping only the latest version
<br>
EOF
- name: Update Tag
uses: richardsimko/[email protected]
with:
tag_name: CI-Build-${{github.ref_name}}
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: CI-Release
uses: softprops/action-gh-release@v1
with:
token: "${{ secrets.GITHUB_TOKEN }}"
name: FoldCraftLauncer CI-Build
tag_name: CI-Build-${{github.ref_name}}
prerelease: true
body_path: ci-build.md
files: |
FCL/build/outputs/apk/release/*.apk
- name: Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
token: "${{ secrets.GITHUB_TOKEN }}"
files: |
FCL/build/outputs/apk/release/*.apk