Skip to content

Commit

Permalink
fix workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
czyt committed Nov 9, 2024
1 parent 6a327bf commit 6019001
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 100 deletions.
71 changes: 14 additions & 57 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,91 +8,48 @@ on:

jobs:
build:
name: ${{ matrix.os }}-${{ matrix.arch }}
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Windows builds
- os: windows-latest
arch: x64
cc: cl

# macOS builds
- os: macos-latest
arch: x64
cc: clang
- os: macos-latest
arch: arm64
cc: clang

# Linux builds
- os: ubuntu-latest
arch: x64
cc: gcc
- os: ubuntu-latest
arch: arm64
cc: gcc

artifact_name: rime-deploy-linux
- os: macos-latest
artifact_name: rime-deploy-macos
- os: windows-latest
artifact_name: rime-deploy-windows.exe

steps:
- uses: actions/checkout@v4

# 设置编译环境
- name: Setup Build Environment
shell: bash
run: |
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
sudo apt-get update
sudo apt-get install -y build-essential cmake
if [ "${{ matrix.arch }}" = "arm64" ]; then
sudo apt-get install -y gcc-aarch64-linux-gnu
fi
elif [ "${{ matrix.os }}" = "macos-latest" ]; then
brew install cmake
elif [ "${{ matrix.os }}" = "windows-latest" ]; then
choco install cmake
sudo apt-get install -y build-essential
fi
# 配置 CMake
- name: Configure CMake
shell: bash
run: |
mkdir build
cd build
if [ "${{ matrix.os }}" = "ubuntu-latest" ] && [ "${{ matrix.arch }}" = "arm64" ]; then
cmake .. -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc
else
cmake .. -DCMAKE_C_COMPILER=${{ matrix.cc }}
fi
# 编译
- name: Build
shell: bash
run: |
cd build
cmake --build . --config Release
# 打包构建产物
- name: Package
shell: bash
run: |
make
mkdir -p artifacts
if [ "${{ matrix.os }}" = "windows-latest" ]; then
cp build/Release/rime-deploy.exe artifacts/rime-deploy-${{ matrix.os }}-${{ matrix.arch }}.exe
cp rime-deploy.exe artifacts/${{ matrix.artifact_name }}
else
cp build/rime-deploy artifacts/rime-deploy-${{ matrix.os }}-${{ matrix.arch }}
cp rime-deploy artifacts/${{ matrix.artifact_name }}
chmod +x artifacts/${{ matrix.artifact_name }}
fi
# 上传构建产物
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: rime-deploy-${{ matrix.os }}-${{ matrix.arch }}
name: rime-deploy-${{ matrix.os }}
path: artifacts/*

# 创建 Release (仅在 tag 推送时)
- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
Expand Down
87 changes: 44 additions & 43 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,58 @@
name: Release

on:
push:
tags:
- 'v*'
release:
types: [created]

jobs:
release:
name: Create Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: false
prerelease: false
generate_release_notes: true

build-release:
needs: release
name: Build Release on ${{ matrix.os }}
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
artifact_name: rime-deploy-linux
asset_name: rime-deploy-linux-x64
# Windows builds
- os: windows-latest
artifact_name: rime-deploy-windows.exe
asset_name: rime-deploy-windows-x64.exe

# macOS builds
- os: macos-latest
artifact_name: rime-deploy-macos
asset_name: rime-deploy-macos-x64
- os: windows-latest
artifact_name: rime-deploy-windows.exe
asset_name: rime-deploy-windows-x64.exe

# Linux builds
- os: ubuntu-latest
artifact_name: rime-deploy-linux
asset_name: rime-deploy-linux-x64

steps:
- uses: actions/checkout@v4

- name: Build
run: |
mkdir build && cd build
cmake ..
cmake --build . --config Release
- name: Upload Release Asset
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: build/Release/${{ matrix.artifact_name }}
- uses: actions/checkout@v4

- name: Setup Build Environment
shell: bash
run: |
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
sudo apt-get update
sudo apt-get install -y build-essential
fi
- name: Build
shell: bash
run: |
make
mkdir -p artifacts
if [ "${{ matrix.os }}" = "windows-latest" ]; then
cp rime-deploy.exe artifacts/${{ matrix.artifact_name }}
else
cp rime-deploy artifacts/${{ matrix.artifact_name }}
chmod +x artifacts/${{ matrix.artifact_name }}
fi
- name: Upload Release Asset
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: artifacts/${{ matrix.artifact_name }}

0 comments on commit 6019001

Please sign in to comment.