Skip to content

wf

wf #15

name: Windows CMake Build and Release
on:
push:
branches: [ main ]
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
strategy:
matrix:
arch: [x64, Win32] # Win32代表32位,x64是64位
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup CMake
uses: lukka/get-cmake@v3
with:
cmake-version: '3.26.4' # 或其他你需要的版本
- name: Configure CMake
run: cmake -S . -B build_${{ matrix.arch }} -G "Visual Studio 17 2022" -A ${{ matrix.arch }}
- name: Build
run: cmake --build build_${{ matrix.arch }} --config MinSizeRel -- /m /p:RestorePackages=false
- name: Package artifacts
shell: powershell
run: |
New-Item -ItemType Directory -Force -Path artifacts
Copy-Item -Path build_${{ matrix.arch }}\MinSizeRel\*.exe -Destination artifacts\
Copy-Item -Path build_${{ matrix.arch }}\MinSizeRel\*.dll -Destination artifacts\
- name: Zip artifacts
shell: powershell
run: |
Compress-Archive -Path artifacts\* -DestinationPath artifacts_${{ matrix.arch }}.zip
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: s-inject_${{ matrix.arch }}
path: artifacts_${{ matrix.arch }}.zip
release:
needs: build
runs-on: windows-latest
steps:
- name: Download x64 artifact
uses: actions/download-artifact@v3
with:
name: s-inject_x64
path: x64
- name: Download x86 artifact
uses: actions/download-artifact@v3
with:
name: s-inject_Win32
path: x86
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
body: Release generated by GitHub Actions
- name: Upload x64 Release Asset
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
name: s-inject_x64.zip
asset_path: x64/artifacts_x64.zip
asset_name: s-inject_x64.zip
asset_content_type: application/zip
- name: Upload x86 Release Asset
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
name: s-inject_x86.zip
asset_path: x86/artifacts_Win32.zip
asset_name: s-inject_x86.zip
asset_content_type: application/zip