Skip to content

my-test-build

my-test-build #33

Workflow file for this run

name: my-test-build
on:
repository_dispatch:
workflow_dispatch:
inputs:
ssh:
description: 'SSH connection to Actions'
required: false
default: 'false'
tag_name:
description: 'Tag name for the release'
required: false
default: 'v1.0.0'
watch:
types: [ started ]
push:
branches:
- master
- main
paths-ignore:
- '**.md'
- '.github/**'
- '!.github/workflows/my-test-build.yml'
tags:
- "v*"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- platform: android
os: ubuntu-latest
- platform: windows
os: windows-latest
arch: amd64
steps:
- name: Set Project Path
run: |
echo "project_path=${{ github.workspace }}" >> $GITHUB_ENV
- name: Show Project Path
run: |
echo "project_path: ${{ env.project_path }}"
- name: Set Android env vars
if: startsWith(matrix.platform, 'android')
run: |
echo "KEYSTORE_BASE64=${{ secrets.ANDROID_KEYSTORE_BASE64 }}" >> $GITHUB_ENV
echo "KEY_ALIAS=${{ secrets.ANDROID_KEY_ALIAS }}" >> $GITHUB_ENV
echo "STORE_PASSWORD=${{ secrets.ANDROID_STORE_PASSWORD }}" >> $GITHUB_ENV
echo "KEY_PASSWORD=${{ secrets.ANDROID_KEY_PASSWORD }}" >> $GITHUB_ENV
- name: Setup Android SDK
if: startsWith(matrix.platform, 'android')
run: |
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager "build-tools;30.0.3"
- name: Setup Mingw64 for Windows
if: startsWith(matrix.platform, 'windows')
uses: msys2/setup-msys2@v2
with:
msystem: mingw64
install: mingw-w64-x86_64-gcc
update: true
- name: Set Mingw64 Env
if: startsWith(matrix.platform, 'windows')
run: |
echo "${{ runner.temp }}\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Check Environment
run: |
echo "Running on ${{ matrix.os }}"
echo "Arch: ${{ runner.arch }}"
gcc --version 2>&1 || echo "GCC not available"
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
ref: ${{ github.event.inputs.tag_name || github.ref }}
# APK签名设置
- name: Setup Android Signing
if: startsWith(matrix.platform, 'android')
id: android_keystore
uses: timheuer/base64-to-file@v1.2
with:
fileName: key.jks
encodedString: ${{ secrets.KEYSTORE_BASE64 }}
- name: 创建key.properties
if: startsWith(matrix.platform, 'android')
run: |
echo "storeFile=${{ steps.android_keystore.outputs.filePath }}" > android/key.properties
echo "storePassword=${{ secrets.STORE_PASSWORD }}" >> android/key.properties
echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> android/key.properties
echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> android/key.properties
- name: Setup JAVA for Android
if: startsWith(matrix.platform, 'android')
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
cache: "gradle"
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: 3.32.7
channel: 'stable'
cache: true
- name: Setup Rust
uses: Swatinem/rust-cache@v2
- name: Enable Flutter Desktop platforms
if: matrix.platform == 'windows'
run: |
flutter config --enable-${{ matrix.platform }}-desktop
# 更新Flutter的packages
- name: 更新Flutter的packages
run: flutter pub get
- name: Install flutter_distributor
run: dart pub global activate flutter_distributor
- name: Build Android APK
if: startsWith(matrix.platform, 'android')
run: |
cd ${{ env.project_path }}
flutter build apk --release --split-per-abi
- name: Build Windows packages
if: startsWith(matrix.platform, 'windows')
run: |
cd ${{ env.project_path }}
flutter_distributor package --platform windows --targets msix,zip,exe --skip-clean
- name: Upload Package to Artifacts
uses: actions/upload-artifact@v4
with:
name: artifact-${{ matrix.platform }}${{ matrix.arch && format('-{0}', matrix.arch) }}
retention-days: 90
overwrite: true
path: |
${{ env.project_path }}/build/app/outputs/flutter-apk/*.apk
${{ env.project_path }}/build/dist/*/*
upload-release:
permissions: write-all
needs: [ build ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.tag_name || github.ref }}
- name: Download
uses: actions/download-artifact@v4
with:
path: ./dist/
pattern: artifact-*
merge-multiple: true
- name: Move File
run: |
mkdir -p dist_2
find dist -type f | xargs -i mv {} dist_2
ls dist_2
- name: Read version
id: version
uses: juliangruber/read-file-action@v1
with:
path: assets/version.json
- name: Get tag name
id: tag
run: |
echo "tag_name=${{ github.event.inputs.tag_name || github.ref_name }}" >> $GITHUB_ENV
- name: Upload Release
uses: softprops/action-gh-release@v2
with:
tag_name: "${{ env.tag_name }}"
name: "${{ env.tag_name }}"
body: "${{ fromJson(steps.version.outputs.content).version_desc }}"
prerelease: ${{ fromJson(steps.version.outputs.content).prerelease || false }}
token: ${{ secrets.GITHUB_TOKEN }}
files: ./dist_2/*
draft: false
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
retain_days: 0
keep_minimum_runs: 3