Skip to content

Commit 988af30

Browse files
authored
Makefile: Add update-embedded-root rule (#1301)
* Makefile: Add update-embedded-root rule This uses the "plumbing" command to ensure the newest root has been downloaded and verified. Then it copies the newest TUF root and the trusted_root.json into the sources. The benefit here is that one does not need to manually find the cache directories when an update should be done. This hard codes XDG_DATA_HOME and XDG_CACHE_HOME for simplicity. We could later add a workflow that runs this on cron and files an issue if the sources changed as a result. Signed-off-by: Jussi Kukkonen <jkukkonen@google.com> * workflows: Create issue if TUF root is not up-to-date Creates a new issue once a week if * the embedded TUF root (or trusted_root.json) differs from the current one served by root-signing * and there is no open issue with same label already This does add a new CI-dependency (github-script) but I believe the currently used actions do not provide the capabilities needed here. The "embedded-root-update" label likely needs to be created by a maintainer manually. Signed-off-by: Jussi Kukkonen <jkukkonen@google.com> --------- Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
1 parent e5c31a0 commit 988af30

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Check embedded root
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '13 13 * * 3'
7+
8+
jobs:
9+
check-embedded-root:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
issues: write
13+
14+
steps:
15+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
16+
with:
17+
persist-credentials: false
18+
19+
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
20+
with:
21+
python-version: "3.x"
22+
cache: "pip"
23+
cache-dependency-path: pyproject.toml
24+
25+
- name: Setup environment
26+
run: make dev
27+
28+
- name: Check if embedded root is up-to-date
29+
run: |
30+
make update-embedded-root
31+
git diff --exit-code
32+
33+
34+
- if: failure()
35+
name: Create an issue if embedded root is not up-to-date
36+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
37+
with:
38+
script: |
39+
const repo = context.repo.owner + "/" + context.repo.repo
40+
const body = `
41+
The Sigstore [TUF repository](https://tuf-repo-cdn.sigstore.dev/) contents have changed: the data embedded
42+
in sigstore-python sources can be updated. This is not urgent but will improve cold-cache performance.
43+
44+
Run \`make update-embedded-root\` to update the embedded data.
45+
46+
This issue was filed by _${context.workflow}_ [workflow run](${context.serverUrl}/${repo}/actions/runs/${context.runId}).
47+
`
48+
49+
const issues = await github.rest.search.issuesAndPullRequests({
50+
q: "label:embedded-root-update+state:open+type:issue+repo:" + repo,
51+
})
52+
if (issues.data.total_count > 0) {
53+
console.log("Issue for embedded root update exists already.")
54+
} else {
55+
github.rest.issues.create({
56+
owner: context.repo.owner,
57+
repo: context.repo.repo,
58+
title: "Embedded TUF root is not up-to-date",
59+
labels: ["embedded-root-update"],
60+
body: body,
61+
})
62+
console.log("New issue created.")
63+
}

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,11 @@ check-readme:
172172
.PHONY: edit
173173
edit:
174174
$(EDITOR) $(ALL_PY_SRCS)
175+
176+
update-embedded-root: $(VENV)/pyvenv.cfg
177+
. $(VENV_BIN)/activate && \
178+
python -m sigstore plumbing update-trust-root
179+
cp ~/.local/share/sigstore-python/tuf/https%3A%2F%2Ftuf-repo-cdn.sigstore.dev/root.json \
180+
sigstore/_store/prod/root.json
181+
cp ~/.cache/sigstore-python/tuf/https%3A%2F%2Ftuf-repo-cdn.sigstore.dev/trusted_root.json \
182+
sigstore/_store/prod/trusted_root.json

0 commit comments

Comments
 (0)