fix: dockerhub release #15
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: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| - run: cargo test --locked --all-targets | |
| build: | |
| needs: test | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| ## macOS: aarch64, x86_64 | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| bin_ext: "" | |
| - target: x86_64-apple-darwin | |
| os: macos-latest | |
| bin_ext: "" | |
| ## Linux: | |
| ## Linux: aarch64, x86_64 | |
| - target: aarch64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| bin_ext: "" | |
| - target: aarch64-unknown-linux-musl | |
| os: ubuntu-latest | |
| bin_ext: "" | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| bin_ext: "" | |
| - target: x86_64-unknown-linux-musl | |
| os: ubuntu-latest | |
| bin_ext: "" | |
| ## Windows: x86_64 | |
| - target: x86_64-pc-windows-msvc | |
| os: windows-latest | |
| bin_ext: ".exe" | |
| - target: x86_64-pc-windows-gnu | |
| os: windows-latest | |
| bin_ext: ".exe" | |
| # FreeBSD: x86_64 | |
| - target: x86_64-unknown-freebsd | |
| os: ubuntu-latest | |
| bin_ext: "" | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install cross | |
| if: startsWith(matrix.os, 'ubuntu') | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cross | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Build (Ubuntu via cross) | |
| if: startsWith(matrix.os, 'ubuntu') | |
| run: cross build --release --locked --target ${{ matrix.target }} | |
| - name: Build (non-Ubuntu) | |
| if: "!startsWith(matrix.os, 'ubuntu')" | |
| run: cargo build --release --locked --target ${{ matrix.target }} | |
| - name: Prepare release archive | |
| id: prepare | |
| shell: bash | |
| run: | | |
| mkdir -p dist | |
| binary="diff-coverage${{ matrix.bin_ext }}" | |
| asset="diff-coverage-${{ github.ref_name }}-${{ matrix.target }}.tar.gz" | |
| cp "target/${{ matrix.target }}/release/$binary" "dist/$binary" | |
| tar -C dist -czf "dist/$asset" "$binary" | |
| rm "dist/$binary" | |
| echo "asset=dist/$asset" >> "$GITHUB_OUTPUT" | |
| - name: Upload release assets | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| ${{ steps.prepare.outputs.asset }} | |
| dispatch-docker: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| actions: write | |
| contents: read | |
| steps: | |
| - name: Trigger docker workflow | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| TAG="${{ github.ref_name }}" | |
| gh workflow run docker.yml -R "$GITHUB_REPOSITORY" --ref "$TAG" -f tag="$TAG" | |
| publish: | |
| runs-on: ubuntu-latest | |
| environment: release | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: rust-lang/crates-io-auth-action@v1 | |
| id: auth | |
| - run: cargo publish | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} |