feat: prep for v0.2.0 release #9
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| name: Build ${{ matrix.target }} | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 30 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Linux x86_64 | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| artifact_name: componentize-go | |
| asset_name: componentize-go-linux-amd64 | |
| # Linux aarch64 | |
| - target: aarch64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| artifact_name: componentize-go | |
| asset_name: componentize-go-linux-arm64 | |
| # macOS x86_64 | |
| - target: x86_64-apple-darwin | |
| os: macos-latest | |
| artifact_name: componentize-go | |
| asset_name: componentize-go-darwin-amd64 | |
| # macOS aarch64 | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| artifact_name: componentize-go | |
| asset_name: componentize-go-darwin-arm64 | |
| # Windows x86_64 | |
| - target: x86_64-pc-windows-msvc | |
| os: windows-latest | |
| artifact_name: componentize-go.exe | |
| asset_name: componentize-go-windows-amd64 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Setup Rust | |
| 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 | |
| - name: Cache Rust | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: ${{ matrix.target }} | |
| - name: Build binary | |
| run: cargo build --release --target ${{ matrix.target }} | |
| env: | |
| CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc | |
| - name: Strip binary (Linux and macOS) | |
| if: runner.os != 'Windows' | |
| run: | | |
| if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then | |
| aarch64-linux-gnu-strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }} | |
| else | |
| strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }} | |
| fi | |
| - name: Upload binary | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: ${{ matrix.asset_name }} | |
| path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }} | |
| release: | |
| name: Create Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v7 | |
| with: | |
| path: artifacts | |
| - name: Flatten, rename, and compress artifacts | |
| run: | | |
| mkdir -p release | |
| for dir in artifacts/*/; do | |
| asset_name=$(basename "$dir") | |
| binary=$(ls "$dir") | |
| if [[ "$asset_name" == *windows* ]]; then | |
| cd "$dir" | |
| zip -9 "../../release/${asset_name}.zip" "$binary" | |
| cd ../.. | |
| else | |
| cd "$dir" | |
| tar -czvf "../../release/${asset_name}.tar.gz" "$binary" | |
| cd ../.. | |
| fi | |
| done | |
| - name: Generate checksums | |
| run: | | |
| cd release | |
| sha256sum * > checksums.txt | |
| - name: Create Release | |
| run: gh release create --generate-notes ${{ github.ref_name }} release/* | |
| env: | |
| GH_TOKEN: ${{ github.token }} |