|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +env: |
| 12 | + CARGO_TERM_COLOR: always |
| 13 | + RUST_VERSION: "1.94.1" |
| 14 | + |
| 15 | +jobs: |
| 16 | + build-release: |
| 17 | + name: Build (${{ matrix.target }}) |
| 18 | + runs-on: ${{ matrix.runner }} |
| 19 | + strategy: |
| 20 | + fail-fast: true |
| 21 | + matrix: |
| 22 | + include: |
| 23 | + - target: x86_64-unknown-linux-gnu |
| 24 | + runner: ubuntu-latest |
| 25 | + use-cross: false |
| 26 | + - target: x86_64-unknown-linux-musl |
| 27 | + runner: ubuntu-latest |
| 28 | + use-cross: false |
| 29 | + - target: aarch64-unknown-linux-gnu |
| 30 | + runner: ubuntu-latest |
| 31 | + use-cross: true |
| 32 | + - target: aarch64-unknown-linux-musl |
| 33 | + runner: ubuntu-latest |
| 34 | + use-cross: true |
| 35 | + - target: aarch64-apple-darwin |
| 36 | + runner: macos-latest |
| 37 | + use-cross: false |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v6 |
| 40 | + |
| 41 | + - uses: dtolnay/rust-toolchain@master |
| 42 | + with: |
| 43 | + toolchain: ${{ env.RUST_VERSION }} |
| 44 | + targets: ${{ matrix.target }} |
| 45 | + |
| 46 | + - name: Install musl-tools |
| 47 | + if: contains(matrix.target, 'musl') && !matrix.use-cross |
| 48 | + run: sudo apt-get update && sudo apt-get install -y musl-tools |
| 49 | + |
| 50 | + - name: Install cross |
| 51 | + if: matrix.use-cross |
| 52 | + run: cargo install cross --locked |
| 53 | + |
| 54 | + - name: Build |
| 55 | + run: | |
| 56 | + if [ "${{ matrix.use-cross }}" = "true" ]; then |
| 57 | + cross build --release --locked --target ${{ matrix.target }} |
| 58 | + else |
| 59 | + cargo build --release --locked --target ${{ matrix.target }} |
| 60 | + fi |
| 61 | +
|
| 62 | + - name: Package binary |
| 63 | + run: | |
| 64 | + BIN_NAME="dockermint" |
| 65 | + TAG="${GITHUB_REF_NAME}" |
| 66 | + ARCHIVE="${BIN_NAME}-${TAG}-${{ matrix.target }}.tar.gz" |
| 67 | + tar -czf "${ARCHIVE}" \ |
| 68 | + -C "target/${{ matrix.target }}/release" \ |
| 69 | + "${BIN_NAME}" |
| 70 | + echo "ARCHIVE=${ARCHIVE}" >> "$GITHUB_ENV" |
| 71 | +
|
| 72 | + - uses: actions/upload-artifact@v6 |
| 73 | + with: |
| 74 | + name: release-${{ matrix.target }} |
| 75 | + path: ${{ env.ARCHIVE }} |
| 76 | + retention-days: 1 |
| 77 | + |
| 78 | + publish: |
| 79 | + name: Publish Release |
| 80 | + needs: build-release |
| 81 | + runs-on: ubuntu-latest |
| 82 | + steps: |
| 83 | + - uses: actions/checkout@v6 |
| 84 | + |
| 85 | + - uses: actions/download-artifact@v7 |
| 86 | + with: |
| 87 | + pattern: release-* |
| 88 | + merge-multiple: true |
| 89 | + path: artifacts/ |
| 90 | + |
| 91 | + - name: Create source archive |
| 92 | + run: | |
| 93 | + TAG="${GITHUB_REF_NAME}" |
| 94 | + git archive --format=tar.gz --prefix="dockermint-${TAG}/" \ |
| 95 | + -o "artifacts/dockermint-${TAG}-src.tar.gz" HEAD |
| 96 | +
|
| 97 | + - name: Generate checksums |
| 98 | + working-directory: artifacts/ |
| 99 | + run: sha256sum * > SHA256SUMS.txt |
| 100 | + |
| 101 | + - name: Create GitHub Release |
| 102 | + uses: softprops/action-gh-release@v2 |
| 103 | + with: |
| 104 | + generate_release_notes: true |
| 105 | + files: artifacts/* |
0 commit comments