mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-19 17:59:05 -05:00
Add compare versions script (#720)
This commit is contained in:
28
.github/scripts/compare-release-versions.sh
vendored
Executable file
28
.github/scripts/compare-release-versions.sh
vendored
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
# Compare the semver tag against the current release in the VERSION file
|
||||
|
||||
set -uo pipefail
|
||||
|
||||
# Bail if VERSION cannot be found
|
||||
if [[ ! -f version/VERSION ]]; then
|
||||
echo "The VERSION file could not be found. Please create a VERSION file in the version/ directory. The contents of version should match the tag without the v prefix."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Bail if the input was not a tag
|
||||
if [[ ! "$GITHUB_REF_TYPE" == "tag" ]]; then
|
||||
echo "This action only runs on tags. Please create a tag and try again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create a clean semver tag without the v prefix
|
||||
CLEAN_TAG=$(echo "$GITHUB_REF_NAME" | sed 's/^v//')
|
||||
|
||||
VERSION=$(cat version/VERSION)
|
||||
if [[ "$VERSION" != "$CLEAN_TAG" ]]; then
|
||||
echo "The VERSION file does not match the tag. Please update the version/VERSION file to match the tag without the v prefix."
|
||||
echo "The VERSION file contains: $VERSION but the tag is: $CLEAN_TAG."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "The VERSION file matches the tag. Proceeding with the release of $VERSION."
|
||||
3
.github/workflows/release.yml
vendored
3
.github/workflows/release.yml
vendored
@@ -33,6 +33,9 @@ jobs:
|
||||
- name: Fetch tags
|
||||
run: git fetch --force --tags
|
||||
|
||||
- name: Compare versions
|
||||
run: ./.github/scripts/compare-release-version.sh
|
||||
|
||||
- name: Determine Go version
|
||||
id: go
|
||||
uses: ./.github/actions/go-version
|
||||
|
||||
Reference in New Issue
Block a user