From 60190012b5bdebd927b94c04ba3019fb9a179db5 Mon Sep 17 00:00:00 2001 From: czyt Date: Sat, 9 Nov 2024 14:11:53 +0800 Subject: [PATCH] fix workflow --- .github/workflows/build.yml | 71 ++++++---------------------- .github/workflows/release.yml | 87 ++++++++++++++++++----------------- 2 files changed, 58 insertions(+), 100 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6c73fba..3736d93 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3c6e46c..31e5ae2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 }}