name: Release on: push: tags: - 'v*' env: CARGO_TERM_COLOR: always RUST_BACKTRACE: 1 permissions: contents: write jobs: build: name: build ${{ matrix.target }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: - target: x86_64-unknown-linux-gnu os: ubuntu-latest archive: tar.gz - target: aarch64-apple-darwin os: macos-latest archive: tar.gz - target: x86_64-apple-darwin os: macos-latest archive: tar.gz - target: x86_64-pc-windows-msvc os: windows-latest archive: zip steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 - name: Install Rust stable uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable with: targets: ${{ matrix.target }} - name: Build release binary run: cargo build --release --target ${{ matrix.target }} - name: Package (unix) if: matrix.archive == 'tar.gz' shell: bash run: | archive="memex-${GITHUB_REF_NAME}-${{ matrix.target }}.tar.gz" tar -C "target/${{ matrix.target }}/release" -czvf "$archive" memex shasum -a 256 "$archive" > "$archive.sha256" - name: Package (windows) if: matrix.archive == 'zip' shell: pwsh run: | $archive = "memex-$env:GITHUB_REF_NAME-${{ matrix.target }}.zip" Compress-Archive -Path "target\${{ matrix.target }}\release\memex.exe" -DestinationPath $archive $hash = (Get-FileHash -Algorithm SHA256 $archive).Hash.ToLower() "$hash $archive" | Out-File -Encoding ASCII "$archive.sha256" - name: Upload artifacts uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 with: name: memex-${{ matrix.target }} path: | memex-*.tar.gz memex-*.zip memex-*.sha256 release: name: Create GitHub release needs: build runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 with: path: artifacts merge-multiple: true - name: Publish draft release uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3 with: draft: true name: ${{ github.ref_name }} tag_name: ${{ github.ref_name }} generate_release_notes: true files: artifacts/* publish-crate: name: Publish to crates.io needs: build runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 - uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable - name: cargo publish run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}