name: CLI Release on: push: branches: - main paths: - 'cli/**' - '.github/workflows/cli-release.yml' workflow_dispatch: # Add permissions for creating releases permissions: contents: write pull-requests: write jobs: build: strategy: matrix: include: - os: ubuntu-latest target: x86_64-unknown-linux-gnu artifact_name: buster-cli-linux-x86_64.tar.gz use_tar: true - os: macos-latest target: x86_64-apple-darwin artifact_name: buster-cli-darwin-x86_64.tar.gz use_tar: true - os: macos-latest target: aarch64-apple-darwin artifact_name: buster-cli-darwin-arm64.tar.gz use_tar: true - os: windows-latest target: x86_64-pc-windows-msvc artifact_name: buster-cli-windows-x86_64.zip use_tar: false runs-on: ${{ matrix.os }} steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install Rust uses: actions-rs/toolchain@v1 with: toolchain: stable target: ${{ matrix.target }} profile: minimal override: true - name: Cache Rust dependencies uses: Swatinem/rust-cache@v2 - name: Configure Cargo for optimized build run: | mkdir -p .cargo echo '[profile.release]' > .cargo/config.toml echo 'lto = true' >> .cargo/config.toml echo 'codegen-units = 1' >> .cargo/config.toml echo 'panic = "abort"' >> .cargo/config.toml echo 'opt-level = 3' >> .cargo/config.toml echo 'strip = true' >> .cargo/config.toml - name: Build optimized release working-directory: ./cli run: cargo build --release --target ${{ matrix.target }} - name: Compress binary (Unix) if: matrix.use_tar working-directory: ./cli run: | cd target/${{ matrix.target }}/release tar czf ${{ matrix.artifact_name }} buster-cli if [[ "${{ runner.os }}" == "macOS" ]]; then shasum -a 256 ${{ matrix.artifact_name }} > ${{ matrix.artifact_name }}.sha256 else sha256sum ${{ matrix.artifact_name }} > ${{ matrix.artifact_name }}.sha256 fi - name: Compress binary (Windows) if: matrix.use_tar == false working-directory: ./cli shell: pwsh run: | cd target/${{ matrix.target }}/release Compress-Archive -Path buster-cli.exe -DestinationPath ${{ matrix.artifact_name }} Get-FileHash -Algorithm SHA256 ${{ matrix.artifact_name }} | Select-Object -ExpandProperty Hash > ${{ matrix.artifact_name }}.sha256 - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: buster-cli-${{ matrix.target }} path: | cli/target/${{ matrix.target }}/release/${{ matrix.artifact_name }} cli/target/${{ matrix.target }}/release/${{ matrix.artifact_name }}.sha256 retention-days: 1 release: needs: build runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - name: Download all artifacts uses: actions/download-artifact@v4 - name: Extract version from Cargo.toml id: get_version run: | VERSION=$(grep '^version =' cli/Cargo.toml | sed 's/version = "\(.*\)"/\1/') echo "version=$VERSION" >> $GITHUB_OUTPUT echo "Extracted version: $VERSION" - name: Create Release uses: softprops/action-gh-release@v1 with: tag_name: v${{ steps.get_version.outputs.version }} name: Release v${{ steps.get_version.outputs.version }} files: | **/buster-cli-linux-x86_64.tar.gz **/buster-cli-linux-x86_64.tar.gz.sha256 **/buster-cli-darwin-x86_64.tar.gz **/buster-cli-darwin-x86_64.tar.gz.sha256 **/buster-cli-darwin-arm64.tar.gz **/buster-cli-darwin-arm64.tar.gz.sha256 **/buster-cli-windows-x86_64.zip **/buster-cli-windows-x86_64.zip.sha256 draft: false prerelease: false generate_release_notes: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}