Skip to content

Commit 8da20f5

Browse files
committed
XXX Test ko
1 parent 52b154e commit 8da20f5

1 file changed

Lines changed: 88 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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+
- name: Install ko
30+
uses: ko-build/setup-ko@d006021bd0c28d1ce33a07e7943d48b079944c8d # v0.9.0
31+
32+
- name: Install cosign
33+
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
34+
35+
- name: Login to GHCR
36+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
37+
with:
38+
registry: ghcr.io
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Build and publish image
43+
id: build
44+
run: |
45+
export KO_DOCKER_REPO="ghcr.io/$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]' )"
46+
47+
mkdir -p ${GITHUB_WORKSPACE}/sbom-output
48+
49+
cd ${GITHUB_WORKSPACE}/tesseract
50+
image_and_digest=$(ko publish \
51+
--platform=linux/amd64,linux/arm64 \
52+
--tags=latest,${{ github.sha }} \
53+
--sbom-dir=${GITHUB_WORKSPACE}/sbom-output \
54+
github.com/transparency-dev/tesseract/cmd/${BINARY})
55+
56+
echo "Images: ${image}"
57+
echo "SBOM files:"
58+
ls -la ${GITHUB_WORKSPACE}/sbom-output/
59+
60+
image=$(echo "${image_and_digest}" | cut -d'@' -f1)
61+
digest=$(echo "${image_and_digest}" | cut -d'@' -f2)
62+
echo "image=${image}" >> "${GITHUB_OUTPUT}"
63+
echo "digest=${digest}" >> "${GITHUB_OUTPUT}"
64+
env:
65+
BINARY: ${{ matrix.binary }}
66+
67+
- name: Generate artifact attestation
68+
uses: actions/attest-build-provenance@v3
69+
with:
70+
subject-name: ${{ steps.build.outputs.image }}
71+
subject-digest: ${{ steps.build.outputs.digest }}
72+
push-to-registry: true
73+
74+
- name: Sign images
75+
run: |
76+
cosign sign --yes --recursive "${IMAGE}"
77+
env:
78+
IMAGE: ${{ steps.build.outputs.image }}
79+
80+
- name: Attest SBOMs
81+
run: |
82+
sbom="${GITHUB_WORKSPACE}/sbom-output/${BINARY##*/})-index.spdx.json"
83+
cosign attest --yes --predicate "${sbom}" --type "https://spdx.dev/Document" "${IMAGE}@${DIGEST}"
84+
env:
85+
BINARY: ${{ matrix.binary }}
86+
IMAGE: ${{ steps.build.outputs.image }}
87+
DIGEST: ${{ steps.build.outputs.digest }}
88+

0 commit comments

Comments
 (0)