Repository navigation
115 lines (101 loc) · 4.07 KB
/
Copy pathrelease.yaml
File metadata and controls
115 lines (101 loc) · 4.07 KB
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
114
115
# SPDX-FileCopyrightText: Copyright 2025 The SLSA Authors
# SPDX-License-Identifier: Apache-2.0
---
name: release
on:
push:
tags:
- 'v*'
permissions:
contents: read
jobs:
# Build and publish the release with goreleaser. This job holds all of the
# build steps; the provenance is generated by a separate, dedicated job so
# nothing that runs here shares the attester's runner or signing identity.
release:
runs-on: ubuntu-latest
permissions:
contents: write # create the release and upload the binaries and the SBOM
outputs:
tag_name: ${{ steps.tag.outputs.tag_name }}
steps:
- name: Check out code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
fetch-depth: 1
- uses: carabiner-dev/actions/go/versions@2f56fd66c5ef961f72bca3dbacbbfbd9acc717ee # v1.3.2
id: go-versions
- uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
with:
go-version: ${{ steps.go-versions.outputs.GO_VERSION_STABLE }}
check-latest: true
cache: false
- name: Set tag output
id: tag
run: echo "tag_name=${GITHUB_REF#refs/*/}" >> "$GITHUB_OUTPUT"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@a4f02ab5355a589de60d917a659ce617ed19b3de # v7.3.0
id: goreleaser
with:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# The SBOM is pushed to the release, so the attester picks it up as
# one more release asset when it attests the run.
- name: Generate SBOM
id: sbom
uses: carabiner-dev/actions/unpack/sbom@2f56fd66c5ef961f72bca3dbacbbfbd9acc717ee # v1.3.2
with:
push-to-release: ${{ steps.tag.outputs.tag_name }}
# goreleaser leaves its build output under dist/, which unpack
# would otherwise scan while discovering codebases.
ignore: dist
env:
GH_TOKEN: ${{ github.token }}
# Attest the release with the SLSA attester: the reusable workflow gives
# the attester a dedicated job and signs the provenance with the
# slsa-framework/actions identity (the observer pattern). goreleaser
# publishes straight to the release, so the run's workflow artifact store
# is empty and the subjects come from the release assets. Only the release
# job is watched: the publish job below depends on this one, so watching
# it would deadlock.
provenance:
needs: release
permissions:
id-token: write # sigstore keyless signing
actions: read # read the run's jobs
contents: read
uses: slsa-framework/actions/.github/workflows/attest_actions.yml@3efdf6f2112b1170cb369442620788752df11bca # v0.2.0
with:
watch-jobs: release
collect-artifacts: false
release: ${{ needs.release.outputs.tag_name }}
# Run a released, provenance-verified attester rather than building
# it from source.
build-from-source: false
version: v0.1.0-rc.3
# Publish the provenance to the release. The slsa_with_provenance action
# in slsa-framework/actions verifies the downloaded binary against this
# file, so it must land on the release as attestations.intoto.jsonl
# (the name every SLSA tool publishes its release provenance under;
# releases up to v0.7.1 used sourcetool.intoto.jsonl).
publish:
needs: [release, provenance]
runs-on: ubuntu-latest
permissions:
contents: write # upload the attestation to the release
steps:
- name: Download the attestation
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: slsa-attestations
- name: Publish provenance to release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
TAG_NAME: ${{ needs.release.outputs.tag_name }}
run: |
mv provenance.intoto.json attestations.intoto.jsonl
gh release upload "${TAG_NAME}" attestations.intoto.jsonl