Repository navigation
101 lines (97 loc) · 3.93 KB
/
Copy pathrelease.yml
File metadata and controls
101 lines (97 loc) · 3.93 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
name: Release
on:
push:
tags: ["v*.*.*"]
permissions: {}
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
build:
name: build and attest source release
uses: nix-forge/ci/.github/workflows/slsa-source-release.yml@f596a2048ecae462a7cea8f882461ea884445ea0 # reviewed SLSA builder
with:
project_name: nix-forge-ci
release_notes_directory: docs/releases
permissions:
contents: read # Read the tagged source for the release archive.
id-token: write # Request a short-lived Sigstore signing identity.
attestations: write # Publish provenance to GitHub's attestation store.
publish:
name: publish source release
needs: build
runs-on: ubuntu-24.04
timeout-minutes: 15
environment: release
permissions:
actions: read # Download the immutable builder output.
contents: write # Publish the verified tagged release.
steps:
- name: Check out the tagged source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
ref: ${{ github.ref }}
persist-credentials: false
- name: Validate release metadata
env:
TAG: ${{ github.ref_name }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
run: |
set -euo pipefail
[[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]
git merge-base --is-ancestor "$GITHUB_SHA" "origin/$DEFAULT_BRANCH"
notes="docs/releases/$TAG.md"
test -s "$notes"
grep -q '^## Changelog$' "$notes"
- name: Download the builder output
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: nix-forge-ci-slsa-release
path: release
- name: Verify release bytes and provenance
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.ref_name }}
run: |
set -euo pipefail
SLSA_BUILDER_SHA=$(bash scripts/release-builder-sha.sh .github/workflows/release.yml)
archive="release/nix-forge-ci-$TAG.tar.gz"
checksum="$archive.sha256"
provenance="release/nix-forge-ci-$TAG.intoto.jsonl"
manifest="release/release-manifest.txt"
test -s "$archive"
test -s "$checksum"
test -s "$provenance"
test -s "$manifest"
# The checksum names the archive by basename; both files are under
# release/ after download-artifact, not in the checkout root.
(cd release && sha256sum -c "$(basename "$checksum")")
grep -Fx "repository=$GITHUB_REPOSITORY" "$manifest"
grep -Fx "source_ref=$GITHUB_REF" "$manifest"
grep -Fx "source_commit=$GITHUB_SHA" "$manifest"
grep -Fx "archive=$(basename "$archive")" "$manifest"
grep -Fx "builder_workflow=nix-forge/ci/.github/workflows/slsa-source-release.yml" "$manifest"
tag_commit="$(git rev-parse "${GITHUB_REF}^{commit}")"
[[ "$tag_commit" == "$GITHUB_SHA" ]]
for subject in "$archive" "$checksum" "$manifest"; do
gh attestation verify "$subject" \
--repo "$GITHUB_REPOSITORY" \
--bundle "$provenance" \
--signer-workflow nix-forge/ci/.github/workflows/slsa-source-release.yml \
--signer-digest "$SLSA_BUILDER_SHA" \
--source-ref "$GITHUB_REF"
done
- name: Publish the verified release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.ref_name }}
run: >-
gh release create "$TAG"
"release/nix-forge-ci-$TAG.tar.gz"
"release/nix-forge-ci-$TAG.tar.gz.sha256"
"release/nix-forge-ci-$TAG.intoto.jsonl"
release/release-manifest.txt
--verify-tag --draft --notes-file "docs/releases/$TAG.md"
--title "nix-forge CI $TAG"
&& gh release edit "$TAG" --draft=false