|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v[0-9]+.[0-9]+.[0-9]+" |
| 7 | + |
| 8 | +env: |
| 9 | + CARGO_TERM_COLOR: always |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + name: Build ${{ matrix.target }} |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + include: |
| 19 | + - target: x86_64-unknown-linux-musl |
| 20 | + os: ubuntu-latest |
| 21 | + binary: vastlint |
| 22 | + archive: vastlint-linux-x86_64.tar.gz |
| 23 | + |
| 24 | + - target: aarch64-unknown-linux-musl |
| 25 | + os: ubuntu-latest |
| 26 | + binary: vastlint |
| 27 | + archive: vastlint-linux-aarch64.tar.gz |
| 28 | + |
| 29 | + - target: x86_64-apple-darwin |
| 30 | + os: macos-latest |
| 31 | + binary: vastlint |
| 32 | + archive: vastlint-macos-x86_64.tar.gz |
| 33 | + |
| 34 | + - target: aarch64-apple-darwin |
| 35 | + os: macos-latest |
| 36 | + binary: vastlint |
| 37 | + archive: vastlint-macos-aarch64.tar.gz |
| 38 | + |
| 39 | + steps: |
| 40 | + - uses: actions/checkout@v4 |
| 41 | + |
| 42 | + - name: Install Rust toolchain |
| 43 | + uses: dtolnay/rust-toolchain@stable |
| 44 | + with: |
| 45 | + targets: ${{ matrix.target }} |
| 46 | + |
| 47 | + - name: Install musl tools (Linux) |
| 48 | + if: contains(matrix.target, 'musl') |
| 49 | + run: | |
| 50 | + sudo apt-get update -q |
| 51 | + sudo apt-get install -y musl-tools |
| 52 | +
|
| 53 | + - name: Install cross (Linux aarch64) |
| 54 | + if: matrix.target == 'aarch64-unknown-linux-musl' |
| 55 | + run: cargo install cross --locked |
| 56 | + |
| 57 | + - name: Build (cross — Linux aarch64) |
| 58 | + if: matrix.target == 'aarch64-unknown-linux-musl' |
| 59 | + run: cross build --release --target ${{ matrix.target }} -p vastlint-cli |
| 60 | + |
| 61 | + - name: Build (cargo — all others) |
| 62 | + if: matrix.target != 'aarch64-unknown-linux-musl' |
| 63 | + run: cargo build --release --target ${{ matrix.target }} -p vastlint-cli |
| 64 | + |
| 65 | + - name: Package |
| 66 | + run: | |
| 67 | + BINARY=target/${{ matrix.target }}/release/${{ matrix.binary }} |
| 68 | + tar czf ${{ matrix.archive }} -C $(dirname $BINARY) $(basename $BINARY) |
| 69 | +
|
| 70 | + - name: Upload artifact |
| 71 | + uses: actions/upload-artifact@v4 |
| 72 | + with: |
| 73 | + name: ${{ matrix.archive }} |
| 74 | + path: ${{ matrix.archive }} |
| 75 | + |
| 76 | + release: |
| 77 | + name: Create GitHub Release |
| 78 | + needs: build |
| 79 | + runs-on: ubuntu-latest |
| 80 | + permissions: |
| 81 | + contents: write |
| 82 | + |
| 83 | + steps: |
| 84 | + - uses: actions/checkout@v4 |
| 85 | + |
| 86 | + - name: Download all artifacts |
| 87 | + uses: actions/download-artifact@v4 |
| 88 | + with: |
| 89 | + path: artifacts |
| 90 | + merge-multiple: true |
| 91 | + |
| 92 | + - name: Create release |
| 93 | + uses: softprops/action-gh-release@v2 |
| 94 | + with: |
| 95 | + files: artifacts/* |
| 96 | + generate_release_notes: true |
| 97 | + |
| 98 | + publish: |
| 99 | + name: Publish to crates.io |
| 100 | + needs: build |
| 101 | + runs-on: ubuntu-latest |
| 102 | + # Set ENABLE_CRATES_PUBLISH to "true" in repo variables (Settings → Variables) |
| 103 | + # to enable publishing. Without it this job is skipped entirely. |
| 104 | + if: vars.ENABLE_CRATES_PUBLISH == 'true' |
| 105 | + |
| 106 | + steps: |
| 107 | + - uses: actions/checkout@v4 |
| 108 | + |
| 109 | + - name: Install Rust toolchain |
| 110 | + uses: dtolnay/rust-toolchain@stable |
| 111 | + |
| 112 | + - name: Publish vastlint-core |
| 113 | + run: cargo publish -p vastlint-core --no-verify |
| 114 | + env: |
| 115 | + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
| 116 | + |
| 117 | + # Wait for crates.io to index the core crate before publishing the CLI |
| 118 | + - name: Wait for crates.io index |
| 119 | + run: sleep 30 |
| 120 | + |
| 121 | + - name: Publish vastlint-cli |
| 122 | + run: cargo publish -p vastlint-cli --no-verify |
| 123 | + env: |
| 124 | + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
0 commit comments