diff --git a/.github/workflows/version-check.yml b/.github/workflows/version-check.yml new file mode 100644 index 000000000..25a9f6253 --- /dev/null +++ b/.github/workflows/version-check.yml @@ -0,0 +1,37 @@ +name: Release Version Check + +on: + push: + tags: + - 'tools/goctl/v*' + workflow_dispatch: + +jobs: + version-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.21' + + - name: Extract tag version + id: get_version + run: | + # Extract version from tools/goctl/v* format + echo "VERSION=${GITHUB_REF#refs/tags/tools/goctl/v}" >> $GITHUB_ENV + echo "Extracted version: $VERSION" + + - name: Check version in goctl source code + run: | + # Change to goctl directory + cd tools/goctl + + # Check version in BuildVersion constant + VERSION_IN_CODE=$(grep -r "const BuildVersion =" . | grep -o '".*"' | tr -d '"') + if [ "$VERSION_IN_CODE" != "$VERSION" ]; then + echo "Version mismatch: Version in code ($VERSION_IN_CODE) doesn't match tag version ($VERSION)" + exit 1 + fi