1313
1414permissions :
1515 contents : write
16- attestations : write
1716 id-token : write
1817
1918concurrency :
9493 TAG_NAME : ${{ github.event.release.tag_name || inputs.tag }}
9594 steps :
9695 - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
96+ with :
97+ fetch-depth : 0
98+
99+ - name : Validate tag and ancestry
100+ shell : bash
101+ run : |
102+ set -euo pipefail
103+ [[ "${TAG_NAME}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([-.].*)?$ ]] || {
104+ echo "invalid release tag: ${TAG_NAME}"
105+ exit 1
106+ }
107+ git rev-parse -q --verify "refs/tags/${TAG_NAME}" >/dev/null || {
108+ echo "tag ${TAG_NAME} does not exist in repository"
109+ exit 1
110+ }
111+ git fetch origin master --force
112+ TAG_COMMIT="$(git rev-list -n1 "${TAG_NAME}")"
113+ git merge-base --is-ancestor "${TAG_COMMIT}" "origin/master" || {
114+ echo "tag ${TAG_NAME} does not point to commit reachable from master"
115+ exit 1
116+ }
117+
118+ - name : Install cosign
119+ run : |
120+ set -euo pipefail
121+ COSIGN_VERSION=v2.4.1
122+ mkdir -p "$HOME/.local/bin"
123+ curl --retry 5 --retry-all-errors --connect-timeout 10 --max-time 120 -sSfL \
124+ "https://github.com/sigstore/cosign/releases/download/${COSIGN_VERSION}/cosign-linux-amd64" \
125+ -o "$HOME/.local/bin/cosign"
126+ chmod +x "$HOME/.local/bin/cosign"
127+ echo "$HOME/.local/bin" >> "$GITHUB_PATH"
97128
98129 - uses : actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
99130 with :
@@ -107,6 +138,33 @@ jobs:
107138 cat ./*.sha256 > checksums.txt
108139 rm ./*.sha256
109140
141+ - name : Sign checksums (keyless)
142+ working-directory : artifacts
143+ env :
144+ COSIGN_YES : " true"
145+ run : |
146+ set -euo pipefail
147+ COSIGN_CACHE_DIR="$(mktemp -d)"
148+ trap 'rm -rf "$COSIGN_CACHE_DIR"' EXIT
149+ env XDG_CACHE_HOME="$COSIGN_CACHE_DIR" cosign sign-blob \
150+ --output-signature checksums.txt.sig \
151+ --output-certificate checksums.txt.pem \
152+ checksums.txt \
153+ --yes
154+
155+ - name : Verify checksums signature
156+ working-directory : artifacts
157+ run : |
158+ set -euo pipefail
159+ COSIGN_CACHE_DIR="$(mktemp -d)"
160+ trap 'rm -rf "$COSIGN_CACHE_DIR"' EXIT
161+ env XDG_CACHE_HOME="$COSIGN_CACHE_DIR" cosign verify-blob \
162+ --certificate checksums.txt.pem \
163+ --signature checksums.txt.sig \
164+ --certificate-identity-regexp '^https://github\.com/usetero/cli/\.github/workflows/release\.yml@refs/(tags/.*|heads/master)$' \
165+ --certificate-oidc-issuer https://token.actions.githubusercontent.com \
166+ checksums.txt
167+
110168 - name : Upload release assets
111169 env :
112170 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
@@ -115,6 +173,8 @@ jobs:
115173 gh release upload "${TAG_NAME}" \
116174 artifacts/*.tar.gz \
117175 artifacts/checksums.txt \
176+ artifacts/checksums.txt.sig \
177+ artifacts/checksums.txt.pem \
118178 scripts/install.sh \
119179 --clobber
120180
0 commit comments