Skip to content

Commit fc5cbae

Browse files
committed
XXX Test ko
1 parent 52b154e commit fc5cbae

1 file changed

Lines changed: 92 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- 'main'
8+
9+
10+
jobs:
11+
release:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
packages: write
16+
attestations: write
17+
id-token: write
18+
strategy:
19+
matrix:
20+
binary: ["fsck", "tesseract/aws", "tesseract/gcp", "tesseract/posix"]
21+
steps:
22+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
23+
with:
24+
path: tesseract
25+
26+
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
27+
with:
28+
go-version-file: tesseract/go.mod
29+
cache-dependency-path: tesseract/go.sum
30+
31+
- name: Install ko
32+
uses: ko-build/setup-ko@d006021bd0c28d1ce33a07e7943d48b079944c8d # v0.9.0
33+
34+
- name: Install cosign
35+
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
36+
37+
- name: Login to GHCR
38+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
39+
with:
40+
registry: ghcr.io
41+
username: ${{ github.actor }}
42+
password: ${{ secrets.GITHUB_TOKEN }}
43+
44+
- name: Build and publish image
45+
id: build
46+
run: |
47+
export KO_DOCKER_REPO="ghcr.io/$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]' )"
48+
49+
mkdir -p ${GITHUB_WORKSPACE}/sbom-output
50+
51+
cd ${GITHUB_WORKSPACE}/tesseract
52+
image_and_digest=$(ko publish \
53+
--base-import-paths \
54+
--platform=linux/amd64,linux/arm64 \
55+
--tags=latest,${{ github.sha }} \
56+
--sbom-dir=${GITHUB_WORKSPACE}/sbom-output \
57+
github.com/transparency-dev/tesseract/cmd/${BINARY})
58+
59+
echo "Images: ${image}"
60+
echo "SBOM files:"
61+
ls -la ${GITHUB_WORKSPACE}/sbom-output/
62+
63+
image=$(echo "${image_and_digest}" | cut -d'@' -f1)
64+
digest=$(echo "${image_and_digest}" | cut -d'@' -f2)
65+
echo "image=${image}" >> "${GITHUB_OUTPUT}"
66+
echo "digest=${digest}" >> "${GITHUB_OUTPUT}"
67+
env:
68+
BINARY: ${{ matrix.binary }}
69+
70+
- name: Generate artifact attestation
71+
uses: actions/attest-build-provenance@v3
72+
with:
73+
subject-name: ${{ steps.build.outputs.image }}
74+
subject-digest: ${{ steps.build.outputs.digest }}
75+
push-to-registry: true
76+
77+
- name: Sign images
78+
run: |
79+
cosign sign --yes --recursive "${IMAGE}@${DIGEST}"
80+
env:
81+
IMAGE: ${{ steps.build.outputs.image }}
82+
DIGEST: ${{ steps.build.outputs.digest }}
83+
84+
- name: Attest SBOMs
85+
run: |
86+
sbom="${GITHUB_WORKSPACE}/sbom-output/${BINARY##*/}-index.spdx.json"
87+
cosign attest --yes --predicate "${sbom}" --type "https://spdx.dev/Document" "${IMAGE}@${DIGEST}"
88+
env:
89+
BINARY: ${{ matrix.binary }}
90+
IMAGE: ${{ steps.build.outputs.image }}
91+
DIGEST: ${{ steps.build.outputs.digest }}
92+

0 commit comments

Comments
 (0)