Skip to content

Commit

Permalink
fix: put version parsing in script
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmcgary committed Jan 14, 2025
1 parent 9ee56f0 commit d3bf2f0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
21 changes: 2 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,7 @@ jobs:
env:
REF: ${{ github.ref }}
run: |
versionFile=$(cat VERSION | tr -d '[:space:]')
if [[ $REF == refs/tags/* ]]; then
# check if versionFile equals the tag.
if [[ $versionFile != "${REF#refs/tags/}" ]]; then
echo "Version in VERSION file does not match the tag"
exit 1
fi
else
# if this isnt a release, add the commit hash to the end of the version
v=$(git rev-parse --short HEAD) echo -n "${versionFile}+${v}" > VERSION
fi
./scripts/version.sh $REF
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
Expand Down Expand Up @@ -105,14 +95,7 @@ jobs:
env:
REF: ${{ github.ref }}
run: |
versionFile=$(cat VERSION | tr -d '[:space:]')
if [[ $REF == refs/tags/* ]]; then
# check if versionFile equals the tag.
if [[ $versionFile != "${REF#refs/tags/}" ]]; then
echo "Version in VERSION file does not match the tag"
exit 1
fi
else
./scripts/version.sh $REF
- name: Build binary
run: |
VERSION=$(cat VERSION | tr -d '[:space:]')
Expand Down
19 changes: 19 additions & 0 deletions scripts/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

REF=$1

versionFile=$(cat VERSION | tr -d '[:space:]')
if [[ $REF == refs/tags/* ]]; then
# check if versionFile equals the tag.
if [[ $versionFile != "${REF#refs/tags/}" ]]; then
echo "Version in VERSION file does not match the tag"
exit 1
fi
echo "Version correctly matches tag"
else
# if this isnt a release, add the commit hash to the end of the version
v=$(git rev-parse --short HEAD)
updatedVersion = "${versionFile}+${v}"
echo "Updated version to '${updatedVersion}'"
echo -n $updatedVersion > VERSION
fi

0 comments on commit d3bf2f0

Please sign in to comment.