ci: add package version check (#396)

* ci: add package version check

Signed-off-by: Andy Lee <andy.lee@suse.com>

* ci: extract check version in a script

Signed-off-by: Andy Lee <andy.lee@suse.com>

* ci: update env variable

Signed-off-by: Andy Lee <andy.lee@suse.com>

---------

Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
Andy Lee 2025-07-16 13:17:05 +08:00 committed by GitHub
parent 4486f71c8f
commit c541f81dc3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 50 additions and 14 deletions

View File

@ -11,18 +11,19 @@ defaults:
working-directory: ./
jobs:
lint:
check-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Checkout repository
uses: actions/checkout@v4
- name: Run tests
uses: ./.github/actions/lint
- name: Check package version
env:
TAG_VERSION: ${{ github.event.release.tag_name }}
run: ./scripts/check-version.sh $TAG_VERSION
build-and-push-extension-catalog:
needs: lint
needs: check-version
uses: ./.github/workflows/build-extension-catalog.yml
permissions:
actions: write

View File

@ -29,19 +29,20 @@ jobs:
else
echo "Error: invalid tag format." && exit 1
fi
lint:
check-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Checkout repository
uses: actions/checkout@v4
- name: Check package version
env:
TAG_VERSION: ${{ github.event.release.tag_name }}
run: ./scripts/check-version.sh $TAG_VERSION
- name: Run tests
uses: ./.github/actions/lint
build-extension-charts:
needs:
- setup-release-tag
- lint
- check-version
uses: rancher/dashboard/.github/workflows/build-extension-charts.yml@master
permissions:
actions: write

View File

@ -5,9 +5,20 @@ on:
- v[1-9].*
jobs:
check-version:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check package version
env:
TAG_VERSION: ${{github.ref_name}}
run: ./scripts/check-version.sh $TAG_VERSION
build:
name: Build and Upload Package
uses: ./.github/workflows/build-and-publish-standalone.yaml
needs: check-version
permissions:
contents: read
packages: write

23
scripts/check-version.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
TAG_VERSION=$1
if [[ -z "$TAG_VERSION" ]]; then
echo "No tag version provided"
exit 1
fi
VERSION=$(jq -r .version package.json)
EXTENSION_VERSION=$(jq -r .version pkg/harvester/package.json)
PKG_VERSION="v${EXTENSION_VERSION}"
if [[ "$VERSION" != "$EXTENSION_VERSION" ]]; then
echo "Package version mismatch: $VERSION vs $EXTENSION_VERSION"
exit 1
fi
if [[ "${TAG_VERSION}" != "$PKG_VERSION" ]]; then
echo "Package version $PKG_VERSION in pkg/harvester/package.json does not match tag version ${TAG_VERSION}"
exit 1
fi
echo "Package version and tag version match: ${TAG_VERSION}"