name: Release on: push: tags: - "v*" workflow_dispatch: permissions: contents: write env: CARGO_TERM_COLOR: always jobs: build-release: name: Build (${{ matrix.target }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: - target: x86_64-unknown-linux-gnu os: ubuntu-latest use_cross: false archive_name: brokecrew-${{ github.ref_name }}-x86_64-unknown-linux-gnu.tar.gz - target: aarch64-unknown-linux-gnu os: ubuntu-latest use_cross: true archive_name: brokecrew-${{ github.ref_name }}-aarch64-unknown-linux-gnu.tar.gz - target: x86_64-apple-darwin os: macos-13 use_cross: false archive_name: brokecrew-${{ github.ref_name }}-x86_64-apple-darwin.tar.gz - target: aarch64-apple-darwin os: macos-latest use_cross: false archive_name: brokecrew-${{ github.ref_name }}-aarch64-apple-darwin.tar.gz - target: x86_64-pc-windows-msvc os: windows-latest use_cross: false archive_name: brokecrew-${{ github.ref_name }}-x86_64-pc-windows-msvc.zip steps: - name: Checkout source uses: actions/checkout@v4 - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.target }} - name: Install Cross for cross-compilation if: matrix.use_cross run: cargo install cross --git https://github.com/cross-rs/cross - name: Build release binary run: | if [ "${{ matrix.use_cross }}" = "true" ]; then cross build --release --target ${{ matrix.target }} else cargo build --release --target ${{ matrix.target }} fi shell: bash - name: Package artifacts (Unix) if: runner.os != 'Windows' run: | BIN_PATH="target/${{ matrix.target }}/release/brokecrew" STAGING="brokecrew-staging" mkdir -p "$STAGING" cp "$BIN_PATH" "$STAGING/brokecrew" cp README.md LICENSE-MIT LICENSE-APACHE "$STAGING/" mkdir -p "$STAGING/config" cp config/personas.example.toml "$STAGING/config/" tar -czvf "${{ matrix.archive_name }}" -C "$STAGING" . shell: bash - name: Package artifacts (Windows) if: runner.os == 'Windows' run: | $bin = "target/${{ matrix.target }}/release/brokecrew.exe" $staging = "brokecrew-staging" New-Item -ItemType Directory -Force -Path $staging Copy-Item $bin -Destination "$staging/brokecrew.exe" Copy-Item README.md, LICENSE-MIT, LICENSE-APACHE -Destination "$staging/" New-Item -ItemType Directory -Force -Path "$staging/config" Copy-Item config/personas.example.toml -Destination "$staging/config/" Compress-Archive -Path "$staging/*" -DestinationPath "${{ matrix.archive_name }}" shell: pwsh - name: Generate SHA256 checksum run: | if [ "${{ runner.os }}" = "Windows" ]; then CertUtil -hashfile "${{ matrix.archive_name }}" SHA256 | Select-String -Pattern "^[a-f0-9]" | ForEach-Object { "$($_.Line.Trim()) ${{ matrix.archive_name }}" } > "${{ matrix.archive_name }}.sha256" else shasum -a 256 "${{ matrix.archive_name }}" > "${{ matrix.archive_name }}.sha256" fi shell: bash - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: assets-${{ matrix.target }} path: | ${{ matrix.archive_name }} ${{ matrix.archive_name }}.sha256 publish-release: name: Publish GitHub Release needs: [build-release] runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Download all built artifacts uses: actions/download-artifact@v4 with: path: dist merge-multiple: true - name: Create Release and Upload Assets uses: softprops/action-gh-release@v2 with: files: | dist/* generate_release_notes: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} publish-crates: name: Publish to Crates.io needs: [build-release] runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/v') steps: - name: Checkout source uses: actions/checkout@v4 - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable - name: Publish to crates.io if: env.CARGO_REGISTRY_TOKEN != '' run: cargo publish --token "$CARGO_REGISTRY_TOKEN" env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}