Files
ecs/.github/workflows/build.yml
spiritlhl 25f2a10ce8
Some checks failed
Build All Platforms / Prepare Version (push) Has been cancelled
Build All Platforms / Build Android APK (push) Has been cancelled
Build All Platforms / Build Desktop Apps (amd64, linux-amd64, ubuntu-latest, linux) (push) Has been cancelled
Build All Platforms / Build Desktop Apps (amd64, macos-amd64, macos-13, darwin) (push) Has been cancelled
Build All Platforms / Build Desktop Apps (amd64, windows-amd64, windows-latest, windows) (push) Has been cancelled
Build All Platforms / Build Desktop Apps (arm64, macos-arm64, macos-latest, darwin) (push) Has been cancelled
Build All Platforms / Upload to Latest Release (push) Has been cancelled
fix:修复fyne编译模式
2025-10-31 18:05:06 +08:00

342 lines
11 KiB
YAML

name: Build All Platforms
on:
push:
branches:
- 'android-app'
workflow_dispatch:
jobs:
prepare:
name: Prepare Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.VERSION }}
app_version: ${{ steps.version.outputs.APP_VERSION }}
is_release: ${{ steps.version.outputs.IS_RELEASE }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get version info
id: version
run: |
BASE_VERSION=$(cat VERSION)
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
APP_VERSION=${VERSION#v}
IS_RELEASE="true"
else
APP_VERSION="$BASE_VERSION"
VERSION=v${BASE_VERSION}-$(date +%Y%m%d)-$(git rev-parse --short HEAD)
IS_RELEASE="false"
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "APP_VERSION=$APP_VERSION" >> $GITHUB_OUTPUT
echo "IS_RELEASE=$IS_RELEASE" >> $GITHUB_OUTPUT
echo "Building version: $VERSION"
echo "App version: $APP_VERSION"
build-android:
name: Build Android APK
needs: prepare
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23.x'
cache: true
- name: Install Fyne CLI
run: |
go install fyne.io/tools/cmd/fyne@latest
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Install Android SDK
uses: android-actions/setup-android@v3
- name: Install Android NDK
run: |
sdkmanager --install "ndk;25.2.9519653"
echo "ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk/25.2.9519653" >> $GITHUB_ENV
- name: Install Android Build Tools
run: |
sdkmanager --install "build-tools;33.0.2"
sdkmanager --install "platforms;android-33"
- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Configure Git for Private Modules
run: |
git config --global url."https://${{ secrets.GHT }}@github.com/".insteadOf "https://github.com/"
git config --global url."git@github.com:".insteadOf "https://github.com/"
env:
GITHUB_TOKEN: ${{ secrets.GHT }}
- name: Download dependencies
run: go mod download
env:
GOPRIVATE: github.com/oneclickvirt/security
- name: Verify dependencies
run: go mod verify
- name: Update FyneApp.toml version
run: |
sed -i "s/Version = .*/Version = \"${{ needs.prepare.outputs.version }}\"/" FyneApp.toml
cat FyneApp.toml
- name: Build Android APK (arm64)
env:
ANDROID_NDK_HOME: ${{ env.ANDROID_NDK_HOME }}
GOPRIVATE: github.com/oneclickvirt/security
run: |
fyne package --os android --app-id com.oneclickvirt.goecs --app-version "${{ needs.prepare.outputs.app_version }}"
if [ -f *.apk ]; then
mkdir -p .build
mv *.apk .build/goecs-android-arm64-${{ needs.prepare.outputs.version }}.apk
echo "ARM64 APK 构建成功"
else
echo "ARM64 APK 构建失败"
exit 1
fi
- name: Build Android APK (x86_64)
env:
ANDROID_NDK_HOME: ${{ env.ANDROID_NDK_HOME }}
GOPRIVATE: github.com/oneclickvirt/security
run: |
fyne package --os android/amd64 --app-id com.oneclickvirt.goecs --app-version "${{ needs.prepare.outputs.app_version }}"
if [ -f *.apk ]; then
mv *.apk .build/goecs-android-x86_64-${{ needs.prepare.outputs.version }}.apk
echo "x86_64 APK 构建成功"
else
echo "x86_64 APK 构建失败"
exit 1
fi
- name: List build artifacts
run: |
ls -lh .build/
du -sh .build/*.apk
- name: Upload ARM64 APK
uses: actions/upload-artifact@v4
with:
name: goecs-android-arm64-${{ needs.prepare.outputs.version }}
path: .build/goecs-android-arm64-${{ needs.prepare.outputs.version }}.apk
retention-days: 90
- name: Upload x86_64 APK
uses: actions/upload-artifact@v4
with:
name: goecs-android-x86_64-${{ needs.prepare.outputs.version }}
path: .build/goecs-android-x86_64-${{ needs.prepare.outputs.version }}.apk
retention-days: 90
build-desktop:
name: Build Desktop Apps
needs: prepare
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# macOS builds
- os: macos-latest
platform: darwin
arch: arm64
name: macos-arm64
- os: macos-13 # Intel Mac runner
platform: darwin
arch: amd64
name: macos-amd64
# Windows builds
- os: windows-latest
platform: windows
arch: amd64
name: windows-amd64
# Linux builds
- os: ubuntu-latest
platform: linux
arch: amd64
name: linux-amd64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23.x'
cache: true
- name: Install Fyne CLI
run: go install fyne.io/tools/cmd/fyne@latest
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libgl1-mesa-dev xorg-dev
- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Configure Git for Private Modules
run: |
git config --global url."https://${{ secrets.GHT }}@github.com/".insteadOf "https://github.com/"
env:
GITHUB_TOKEN: ${{ secrets.GHT }}
- name: Download dependencies
run: go mod download
env:
GOPRIVATE: github.com/oneclickvirt/security
- name: Verify dependencies
run: go mod verify
- name: Update FyneApp.toml version
shell: bash
run: |
if [ "${{ runner.os }}" == "macOS" ]; then
sed -i '' "s/Version = .*/Version = \"${{ needs.prepare.outputs.version }}\"/" FyneApp.toml
else
sed -i "s/Version = .*/Version = \"${{ needs.prepare.outputs.version }}\"/" FyneApp.toml
fi
cat FyneApp.toml
- name: Build for ${{ matrix.name }}
env:
GOPRIVATE: github.com/oneclickvirt/security
shell: bash
run: |
mkdir -p .build
# Build the package with ldflags
fyne package -os ${{ matrix.platform }} -name goecs --app-version "${{ needs.prepare.outputs.app_version }}" -ldflags "-checklinkname=0 -s -w"
# Package the output
if [ "${{ matrix.platform }}" == "darwin" ]; then
if [ -d goecs.app ]; then
tar -czf .build/goecs-${{ matrix.name }}-${{ needs.prepare.outputs.version }}.tar.gz goecs.app
echo "macOS app 构建成功"
else
echo "macOS app 构建失败"
exit 1
fi
elif [ "${{ matrix.platform }}" == "windows" ]; then
if [ -f goecs.exe ]; then
mv goecs.exe .build/goecs-${{ matrix.name }}-${{ needs.prepare.outputs.version }}.exe
echo "Windows exe 构建成功"
else
echo "Windows exe 构建失败"
exit 1
fi
elif [ "${{ matrix.platform }}" == "linux" ]; then
if [ -f goecs ]; then
tar -czf .build/goecs-${{ matrix.name }}-${{ needs.prepare.outputs.version }}.tar.gz goecs
echo "Linux binary 构建成功"
else
echo "Linux binary 构建失败"
exit 1
fi
fi
- name: List build artifacts
shell: bash
run: |
ls -lh .build/
du -sh .build/*
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: goecs-${{ matrix.name }}-${{ needs.prepare.outputs.version }}
path: .build/*
retention-days: 90
upload-to-release:
name: Upload to Latest Release
needs: [prepare, build-android, build-desktop]
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/android-app'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Display structure of downloaded files
run: ls -R artifacts/
- name: Get latest release
id: get_release
run: |
LATEST_RELEASE=$(gh release list --limit 1 --json tagName,url --jq '.[0]')
if [ -z "$LATEST_RELEASE" ]; then
echo "No existing release found, creating a new one"
gh release create "${{ needs.prepare.outputs.version }}" \
--title "Release ${{ needs.prepare.outputs.version }}" \
--notes "Automated build from ${{ github.sha }}"
RELEASE_TAG="${{ needs.prepare.outputs.version }}"
else
RELEASE_TAG=$(echo "$LATEST_RELEASE" | jq -r '.tagName')
echo "Found existing release: $RELEASE_TAG"
fi
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifacts to release
run: |
cd artifacts
for dir in */; do
cd "$dir"
for file in *; do
if [ -f "$file" ]; then
echo "Uploading $file to release ${{ steps.get_release.outputs.RELEASE_TAG }}"
gh release upload "${{ steps.get_release.outputs.RELEASE_TAG }}" "$file" --clobber
fi
done
cd ..
done
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}