-
-
Notifications
You must be signed in to change notification settings - Fork 71
113 lines (107 loc) · 4.29 KB
/
release.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: release
on:
push:
tags: [ 'v*' ]
permissions:
contents: read
jobs:
goreleaser:
outputs:
hashes: ${{ steps.hash.outputs.hashes }}
version: ${{ steps.hash.outputs.version }}
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Unshallow
run: git fetch --prune --unshallow
- name: Setup Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: 1.21.x
cache-dependency-path: |
**/go.sum
**/go.mod
- name: Setup Syft
uses: anchore/sbom-action/download-syft@78fc58e266e87a38d4194b2137a3d4e9bcaf7ca1 # v0.14.3
- name: Run GoReleaser
id: run-goreleaser
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0
with:
version: latest
args: release --skip-validate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_TOKEN }}
- name: Generate SLSA subject
id: hash
env:
ARTIFACTS: "${{ steps.run-goreleaser.outputs.artifacts }}"
run: |
set -euo pipefail
hashes=$(echo $ARTIFACTS | jq --raw-output '.[] | {name, "digest": (.extra.Digest // .extra.Checksum)} | select(.digest) | {digest} + {name} | join(" ") | sub("^sha256:";"")' | base64 -w0)
if test "$hashes" = ""; then # goreleaser < v1.13.0
checksum_file=$(echo "$ARTIFACTS" | jq -r '.[] | select (.type=="Checksum") | .path')
hashes=$(cat $checksum_file | base64 -w0)
fi
echo "hashes=$hashes" >> $GITHUB_OUTPUT
echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
publish-artifacts:
needs: [goreleaser]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Cosign
uses: sigstore/cosign-installer@11086d25041f77fe8fe7b9ea4e48e3b9192b8f19 # v3.1.2
- name: Setup Timoni
uses: ./actions/setup
- name: Login to GHCR
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Version info
id: info
run: |
VERSION=$(timoni -v | awk '{ print $NF }')
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Push minimal module
run: |
timoni mod push ./examples/minimal oci://ghcr.io/stefanprodan/timoni/minimal \
-v ${{ steps.info.outputs.version }} --latest \
-a 'org.opencontainers.image.licenses=Apache-2.0' \
-a 'org.opencontainers.image.source=https://github.com/stefanprodan/timoni' \
-a 'org.opencontainers.image.description=A minimal timoni.sh module.' \
-a 'org.opencontainers.image.documentation=https://timoni.sh' \
--sign cosign
- name: Push schemas
run: |
timoni artifact push oci://ghcr.io/stefanprodan/timoni/schemas \
-f ./schemas -t ${{ steps.info.outputs.version }} -t latest \
-a 'org.opencontainers.image.licenses=Apache-2.0' \
-a 'org.opencontainers.image.source=https://github.com/stefanprodan/timoni' \
-a 'org.opencontainers.image.description=Timoni CUE schemas.' \
-a 'org.opencontainers.image.documentation=https://timoni.sh' \
--content-type="cue.mod/pkg" \
--sign cosign
provenance:
needs: [goreleaser]
permissions:
actions: read # To read the workflow path.
id-token: write # To sign the provenance.
contents: write # To add assets to a release.
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.9.0
with:
provenance-name: "timoni_${{ needs.goreleaser.outputs.version }}_provenance.intoto.jsonl"
base64-subjects: "${{ needs.goreleaser.outputs.hashes }}"
upload-assets: true # upload to a new release