Skip to content

Commit

Permalink
ensure releases only use released versions of syft
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Goodman <[email protected]>
  • Loading branch information
wagoodman committed Jan 25, 2024
1 parent 73cb5f6 commit a845f71
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/scripts/check-syft-version-is-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -e

version=$(grep -E "github.com/anchore/syft" go.mod | awk '{print $NF}')

# ensure that the version is a release version (not a commit hash)
# a release in this case means that the go tooling resolved the version to a tag
# this does not guarantee that the tag has a github release associated with it
if [[ ! $version =~ ^v[0-9]+\.[0-9]+\.[0-9]?$ ]]; then
echo "syft version in go.mod is not a release version: $version"
echo "please update the version in go.mod to a release version and try again"
exit 1
else
echo "syft version in go.mod is a release version: $version"
fi
3 changes: 3 additions & 0 deletions .github/scripts/trigger-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ if ! [ -x "$(command -v gh)" ]; then
exit 1
fi

# we want to stop the release as early as possible if the version is not a release version
./.github/scripts/check-syft-version-is-release.sh

gh auth status

# we need all of the git state to determine the next version. Since tagging is done by
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1

- name: Check if pinned syft is a release version
run: .github/scripts/check-syft-version-is-release.sh

- name: Check if tag already exists
# note: this will fail if the tag already exists
run: |
Expand Down

0 comments on commit a845f71

Please sign in to comment.