Repository navigation
fix: [CI/CD] Version check prevent duplicate version release #1
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: Version Check | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| jobs: | |
| check-version: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Extract versions | |
| id: versions | |
| run: | | |
| CARGO_VER=$(grep '^version' Cargo.toml | head -n1 | cut -d'"' -f2) | |
| NPM_VER=$(node -p "require('./package.json').version") | |
| echo "cargo=$CARGO_VER" >> $GITHUB_OUTPUT | |
| echo "npm=$NPM_VER" >> $GITHUB_OUTPUT | |
| - name: Verify version consistency | |
| run: | | |
| if [ "${{ steps.versions.outputs.cargo }}" != "${{ steps.versions.outputs.npm }}" ]; then | |
| echo "Version mismatch: Cargo.toml (${{ steps.versions.outputs.cargo }}) vs package.json (${{ steps.versions.outputs.npm }})" | |
| exit 1 | |
| fi | |
| - name: Prevent duplicate release | |
| run: | | |
| VER="${{ steps.versions.outputs.cargo }}" | |
| if git tag -l "v$VER" | grep -q "^v$VER$"; then | |
| echo "Tag v$VER already exists. Duplicate release prevented." | |
| exit 1 | |
| fi |