|
37 | 37 | echo "Using ref: $REF" |
38 | 38 | echo "Using version: $VERSION" |
39 | 39 |
|
| 40 | + verify-version: |
| 41 | + name: Verify version matches tag |
| 42 | + needs: setup |
| 43 | + runs-on: ubuntu-latest |
| 44 | + |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v4 |
| 47 | + with: |
| 48 | + ref: ${{ needs.setup.outputs.ref }} |
| 49 | + |
| 50 | + - name: Verify Cargo.toml version matches tag |
| 51 | + run: | |
| 52 | + TAG_VERSION="${{ needs.setup.outputs.version }}" |
| 53 | + # Remove 'v' prefix if present |
| 54 | + TAG_VERSION="${TAG_VERSION#v}" |
| 55 | + CARGO_VERSION=$(grep "^version" Cargo.toml | head -1 | cut -d'"' -f2) |
| 56 | + |
| 57 | + echo "Tag version: $TAG_VERSION" |
| 58 | + echo "Cargo.toml version: $CARGO_VERSION" |
| 59 | + |
| 60 | + if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then |
| 61 | + echo "❌ Error: Tag version ($TAG_VERSION) doesn't match Cargo.toml version ($CARGO_VERSION)" |
| 62 | + echo "Please ensure the version in Cargo.toml matches the tag you're trying to release." |
| 63 | + exit 1 |
| 64 | + fi |
| 65 | + echo "✅ Version check passed!" |
| 66 | +
|
40 | 67 | test: |
41 | 68 | name: Run tests |
42 | | - needs: setup |
| 69 | + needs: [setup, verify-version] |
43 | 70 | runs-on: ubuntu-latest |
44 | 71 |
|
45 | 72 | steps: |
|
58 | 85 |
|
59 | 86 | build-binaries: |
60 | 87 | name: Build binaries |
61 | | - needs: [setup, test] |
| 88 | + needs: [setup, verify-version, test] |
62 | 89 | strategy: |
63 | 90 | matrix: |
64 | 91 | include: |
@@ -252,14 +279,9 @@ jobs: |
252 | 279 | - name: Install Rust |
253 | 280 | uses: dtolnay/rust-toolchain@stable |
254 | 281 |
|
255 | | - - name: Verify version matches tag |
| 282 | + - name: Get Cargo version for checking |
256 | 283 | run: | |
257 | | - TAG_VERSION="${GITHUB_REF#refs/tags/v}" |
258 | 284 | CARGO_VERSION=$(grep "^version" Cargo.toml | head -1 | cut -d'"' -f2) |
259 | | - if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then |
260 | | - echo "Error: Tag version ($TAG_VERSION) doesn't match Cargo.toml version ($CARGO_VERSION)" |
261 | | - exit 1 |
262 | | - fi |
263 | 285 | echo "CARGO_VERSION=$CARGO_VERSION" >> $GITHUB_ENV |
264 | 286 |
|
265 | 287 | - name: Authenticate with crates.io |
|
0 commit comments