From 4b8ae926daf88db95b01578521ada4083a7d9d41 Mon Sep 17 00:00:00 2001 From: rain-bus Date: Wed, 3 Jun 2026 18:47:22 +0800 Subject: [PATCH] ci: add GitHub Actions release workflow for multi-platform builds --- .github/workflows/release.yml | 96 +++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ad3edaf --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,96 @@ +name: Release + +on: + push: + tags: ["v*"] + +permissions: + contents: write + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + name: Build ${{ matrix.target }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + # Linux + - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + artifact: sshell-x86_64-linux + - os: ubuntu-latest + target: aarch64-unknown-linux-gnu + artifact: sshell-aarch64-linux + # macOS + - os: macos-latest + target: aarch64-apple-darwin + artifact: sshell-aarch64-macos + - os: macos-13 + target: x86_64-apple-darwin + artifact: sshell-x86_64-macos + # Windows + - os: windows-latest + target: x86_64-pc-windows-msvc + artifact: sshell-x86_64-windows.exe + - os: windows-latest + target: aarch64-pc-windows-msvc + artifact: sshell-aarch64-windows.exe + + steps: + - uses: actions/checkout@v4 + + - uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - name: Install cross-compilation tools (Linux aarch64) + if: matrix.target == 'aarch64-unknown-linux-gnu' + run: | + sudo apt-get update + sudo apt-get install -y gcc-aarch64-linux-gnu + + - uses: Swatinem/rust-cache@v2 + with: + key: ${{ matrix.target }} + + - name: Build + run: cargo build --release --target ${{ matrix.target }} + + - name: Rename binary (Unix) + if: runner.os != 'Windows' + run: | + cp target/${{ matrix.target }}/release/sshell ${{ matrix.artifact }} + chmod +x ${{ matrix.artifact }} + + - name: Rename binary (Windows) + if: runner.os == 'Windows' + run: | + copy target\${{ matrix.target }}\release\sshell.exe ${{ matrix.artifact }} + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.artifact }} + path: ${{ matrix.artifact }} + + release: + name: Create GitHub Release + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/download-artifact@v4 + with: + path: artifacts + merge-multiple: true + + - name: Create release + uses: softprops/action-gh-release@v2 + with: + generate_release_notes: true + files: artifacts/*