forked from lightninglabs/taproot-assets
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request lightninglabs#720 from lightninglabs/validate-rele…
…ase-version makefile: add command to generate git release tags
- Loading branch information
Showing
6 changed files
with
180 additions
and
51 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,16 +22,28 @@ jobs: | |
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set env | ||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | ||
|
||
- name: Validate release tag ${{ env.RELEASE_VERSION }} | ||
run: | | ||
expected_tag=$(./scripts/get-git-tag-name.sh version.go) | ||
actual_tag=${{ env.RELEASE_VERSION }} | ||
if [ "$actual_tag" = "$expected_tag" ]; then | ||
echo "Git tag release string is as expected." | ||
else | ||
echo "Error: Versions are not equal. Actual: $actual_tag, Expected: $expected_tag" | ||
exit 1 | ||
fi | ||
- name: setup go ${{ env.GO_VERSION }} | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '${{ env.GO_VERSION }}' | ||
|
||
- name: Set env | ||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | ||
|
||
- name: build release for all architectures | ||
run: SKIP_VERSION_CHECK=1 make release tag=${{ env.RELEASE_VERSION }} | ||
run: make release tag=${{ env.RELEASE_VERSION }} | ||
|
||
- name: Create Release | ||
uses: lightninglabs/gh-actions/[email protected] | ||
|
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/bin/bash | ||
|
||
# This script derives a git tag name from the version fields found in a given Go | ||
# file. It also checks if the derived git tag name is a valid SemVer compliant | ||
# version string. | ||
|
||
# get_git_tag_name reads the version fields from the given file and then | ||
# constructs and returns a git tag name. | ||
get_git_tag_name() { | ||
local file_path="$1" | ||
|
||
# Check if the file exists | ||
if [ ! -f "$file_path" ]; then | ||
echo "Error: File not found at $file_path" >&2 | ||
exit 1 | ||
fi | ||
|
||
# Read and parse the version fields. We interpret these fields using regex | ||
# matching which effectively serves as a basic sanity check. | ||
local app_major | ||
app_major=$(grep -oP 'AppMajor\s*uint\s*=\s*\K\d+' "$file_path") | ||
|
||
local app_minor | ||
app_minor=$(grep -oP 'AppMinor\s*uint\s*=\s*\K\d+' "$file_path") | ||
|
||
local app_patch | ||
app_patch=$(grep -oP 'AppPatch\s*uint\s*=\s*\K\d+' "$file_path") | ||
|
||
local app_status | ||
app_status=$(grep -oP 'AppStatus\s*=\s*"\K([a-z]*)' "$file_path") | ||
|
||
local app_pre_release | ||
app_pre_release=$(grep -oP 'AppPreRelease\s*=\s*"\K([a-z0-9]*)' "$file_path") | ||
|
||
# Parse the GitTagIncludeStatus field. | ||
local git_tag_include_status | ||
git_tag_include_status=false | ||
|
||
if grep -q 'GitTagIncludeStatus = true' "$file_path"; then | ||
git_tag_include_status=true | ||
elif grep -q 'GitTagIncludeStatus = false' "$file_path"; then | ||
git_tag_include_status=false | ||
else | ||
echo "Error: GitTagIncludeStatus is not present in the Go version file." | ||
exit 1 | ||
fi | ||
|
||
# Construct the git tag name with conditional inclusion of app_status and | ||
# app_pre_release. | ||
tag_name="v${app_major}.${app_minor}.${app_patch}" | ||
|
||
# Append app_status if git_tag_include_status is true and app_status if | ||
# specified. | ||
if [ "$git_tag_include_status" = true ] && [ -n "$app_status" ]; then | ||
tag_name+="-${app_status}" | ||
|
||
# Append app_pre_release if specified. | ||
if [ -n "$app_pre_release" ]; then | ||
tag_name+=".${app_pre_release}" | ||
fi | ||
else | ||
# If the app_status field is not specified, then append | ||
# app_pre_release (if specified) using a dash prefix. | ||
if [ -n "$app_pre_release" ]; then | ||
tag_name+="-${app_pre_release}" | ||
fi | ||
fi | ||
|
||
echo "$tag_name" | ||
} | ||
|
||
file_path="$1" | ||
echo "Reading version fields from file: $file_path" >&2 | ||
tag_name=$(get_git_tag_name "$file_path") | ||
echo "Derived git tag name: $tag_name" >&2 | ||
|
||
echo "$tag_name" |
This file contains 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
This file contains 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