Skip to content

Commit

Permalink
install-slsactl: Skip tests on tag push
Browse files Browse the repository at this point in the history
Avoids the race condition whereby the install-slsactl attempts to
download binaries from the project, while they are being built and
published by a different action.

Signed-off-by: Paulo Gomes <[email protected]>
  • Loading branch information
pjbgf committed Dec 10, 2024
1 parent ef90536 commit d4636df
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 26 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/test-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: Test Actions

on:
push:
tags-ignore:
# Ignore release tags, as the install-slsactl will probably
# be executed before the release takes place, causing it to
# fail as it will try to download the binaries of the current
# release, which may or may not be available.
- 'v*'

pull_request:
workflow_dispatch:

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ jobs:
uses: actions/checkout@v4

- uses: ./actions/install-slsactl
with:
version: ${{ github.sha }}
- run: make e2e
59 changes: 33 additions & 26 deletions actions/install-slsactl/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,38 +49,45 @@ runs:
echo "Using last tag ${VERSION} as version"
fi
echo "Downloading checksum file and signatures for release ${VERSION}"
curl -LO "https://${REPO}/releases/download/${VERSION}/slsactl_${VERSION#v}_checksums.txt.pem"
curl -LO "https://${REPO}/releases/download/${VERSION}/slsactl_${VERSION#v}_checksums.txt.sig"
curl -LO "https://${REPO}/releases/download/${VERSION}/slsactl_${VERSION#v}_checksums.txt"
if [[ "${VERSION}" =~ ^v ]]; then
echo "Downloading checksum file and signatures for release ${VERSION}"
curl -LO "https://${REPO}/releases/download/${VERSION}/slsactl_${VERSION#v}_checksums.txt.pem"
curl -LO "https://${REPO}/releases/download/${VERSION}/slsactl_${VERSION#v}_checksums.txt.sig"
curl -LO "https://${REPO}/releases/download/${VERSION}/slsactl_${VERSION#v}_checksums.txt"
cosign verify-blob \
--certificate-identity "https://${REPO}/.github/workflows/release.yml@refs/tags/${VERSION}" \
--certificate-oidc-issuer "https://token.actions.githubusercontent.com" \
--certificate "slsactl_${VERSION#v}_checksums.txt.pem" \
--signature "slsactl_${VERSION#v}_checksums.txt.sig" "slsactl_${VERSION#v}_checksums.txt"
cosign verify-blob \
--certificate-identity "https://${REPO}/.github/workflows/release.yml@refs/tags/${VERSION}" \
--certificate-oidc-issuer "https://token.actions.githubusercontent.com" \
--certificate "slsactl_${VERSION#v}_checksums.txt.pem" \
--signature "slsactl_${VERSION#v}_checksums.txt.sig" "slsactl_${VERSION#v}_checksums.txt"
OS="linux"
if [[ ${RUNNER_OS} != "Linux" ]]; then
echo "Unsupported OS: ${RUNNER_OS}"
exit 1
fi
OS="linux"
if [[ ${RUNNER_OS} != "Linux" ]]; then
echo "Unsupported OS: ${RUNNER_OS}"
exit 1
fi
ARCH=""
if [[ $(uname -m) == "x86_64" ]]; then
ARCH=amd64
fi
if [[ $(uname -m) == "aarch64" ]]; then
ARCH=arm64
fi
ARCH=""
if [[ $(uname -m) == "x86_64" ]]; then
ARCH=amd64
fi
if [[ $(uname -m) == "aarch64" ]]; then
ARCH=arm64
fi
FILE="slsactl_${VERSION#v}_${OS}_${ARCH}"
FILE="slsactl_${VERSION#v}_${OS}_${ARCH}"
echo "Installing ${FILE}"
curl -LO "https://${REPO}/releases/download/${VERSION}/${FILE}"
grep "${FILE}" "slsactl_${VERSION#v}_checksums.txt" | sha256sum -c
echo "Installing ${FILE}"
curl -LO "https://${REPO}/releases/download/${VERSION}/${FILE}"
grep "${FILE}" "slsactl_${VERSION#v}_checksums.txt" | sha256sum -c
chmod +x "${FILE}"
else
echo 'Version is not "latest" nor starts with "v". Fallback to go install with commit ID.'
go install "github.com/rancherlabs/slsactl@${VERSION}"
FILE="$(go env GOPATH)/bin/slsactl"
fi
chmod +x "${FILE}"
if sudo -l &> /dev/null; then
sudo mv "${FILE}" /usr/local/bin/slsactl
else
Expand Down

0 comments on commit d4636df

Please sign in to comment.