Repository navigation
187 lines (165 loc) · 6.02 KB
/
Copy pathnightly.yaml
File metadata and controls
187 lines (165 loc) · 6.02 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: nightly
# Daily experimental build of main.
#
# - Skips if main has not moved since the last nightly, or if CI has not passed on it.
# - Binaries go to one rolling "nightly" pre-release (replaced every day).
# - Container images get a dated tag plus a moving "nightly" tag.
#
# Tags/releases created here use GITHUB_TOKEN, so they do NOT trigger release.yaml.
on:
schedule:
- cron: "17 2 * * *" # 02:17 UTC daily; off the hour to avoid scheduler congestion
workflow_dispatch:
inputs:
force:
description: "Build even if main has not changed since the last nightly"
type: boolean
default: false
concurrency:
group: nightly
cancel-in-progress: false
permissions:
contents: read
jobs:
init:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-24.04
permissions:
contents: read
actions: read
outputs:
version: ${{ steps.version.outputs.version }}
proceed: ${{ steps.check.outputs.proceed }}
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Decide whether to build
id: check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FORCE: ${{ inputs.force }}
run: |
set -euo pipefail
proceed=true
# Skip if the rolling nightly already points at this commit.
last=$(gh release view nightly --json targetCommitish -q .targetCommitish 2>/dev/null || true)
if [[ "$last" == "$GITHUB_SHA" && "$FORCE" != "true" ]]; then
echo "::notice::main unchanged since last nightly ($GITHUB_SHA), skipping"
proceed=false
fi
# Only ship commits that passed CI.
ok=$(gh run list --workflow ci.yaml --commit "$GITHUB_SHA" --status success --limit 1 --json databaseId -q 'length')
if [[ "$ok" == "0" ]]; then
echo "::warning::CI has not passed on $GITHUB_SHA, skipping"
proceed=false
fi
echo "proceed=$proceed" >> "$GITHUB_OUTPUT"
- name: Compute version
id: version
run: |
set -euo pipefail
base=$(grep -m1 '^version' Cargo.toml | sed -E 's/.*"(.*)".*/\1/')
# e.g. 0.6.0-rc.1.nightly.20260926.7eb2427 (no '+': not allowed in container tags)
version="${base}.nightly.$(date -u +%Y%m%d).${GITHUB_SHA::7}"
[[ "$base" == *-* ]] || version="${base}-nightly.$(date -u +%Y%m%d).${GITHUB_SHA::7}"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "Version: $version"
build:
needs: init
if: needs.init.outputs.proceed == 'true'
uses: ./.github/workflows/build-binary.yaml
with:
version: ${{ needs.init.outputs.version }}
publish:
needs: [init, build]
runs-on: ubuntu-24.04
permissions:
contents: write
packages: write
id-token: write
attestations: write
env:
VERSION: ${{ needs.init.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/download-artifact@v8
with:
path: ${{ github.workspace }}/download
- name: Stage release
run: |
mkdir -p staging
cp -pv download/*/* staging/
- uses: actions/attest-build-provenance@v4
with:
subject-path: "staging/*"
- uses: ./.github/actions/build-container
with:
image_tag: ${{ env.VERSION }}
- name: Tag images as nightly
run: |
for img in trustd xtask gensbom; do
podman tag "$img:$VERSION" "$img:nightly"
done
- name: Push images to ghcr.io
uses: redhat-actions/push-to-registry@v3
with:
image: trustd
tags: ${{ env.VERSION }} nightly
registry: ghcr.io/${{ github.repository_owner }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push xtask
uses: redhat-actions/push-to-registry@v3
with:
image: xtask
tags: ${{ env.VERSION }} nightly
registry: ghcr.io/${{ github.repository_owner }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push gensbom
uses: redhat-actions/push-to-registry@v3
with:
image: gensbom
tags: ${{ env.VERSION }} nightly
registry: ghcr.io/${{ github.repository_owner }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Release notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
prev=$(gh release view nightly --json targetCommitish -q .targetCommitish 2>/dev/null || true)
{
echo "> [!WARNING]"
echo "> Experimental nightly build of \`main\` at ${GITHUB_SHA::7}. Not supported; may break data or migrations."
echo
echo "Version: \`$VERSION\`"
echo
echo "Images: \`ghcr.io/${{ github.repository_owner }}/trustd:$VERSION\` (also \`:nightly\`)"
echo
if [[ -n "$prev" ]] && git cat-file -e "$prev" 2>/dev/null; then
echo "### Changes since previous nightly (${prev::7})"
git log --no-merges --format='- %s (%h)' "$prev..$GITHUB_SHA"
fi
} > /tmp/notes.md
- name: Replace rolling nightly release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
mapfile -d '' -t release_assets < <(find staging -type f -print0 | sort -z)
if ((${#release_assets[@]} == 0)); then
echo "::error::No release assets were staged"
exit 1
fi
gh release delete nightly --cleanup-tag --yes 2>/dev/null || true
gh release create nightly \
--target "$GITHUB_SHA" \
--title "Nightly $VERSION" \
--notes-file /tmp/notes.md \
--prerelease --latest=false \
"${release_assets[@]}"