Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 30 additions & 13 deletions .github/workflows/update-catalog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,32 @@ on:
description: Release tag to publish
required: true
type: string
allow_rollback:
description: Accept a version that is not newer than the listed one (deliberate rollback only)
required: false
type: boolean
default: false

permissions:
contents: write
# CATALOG_PUSH_TOKEN pushes the catalog, and every source repository is
# public, so the workflow token needs no permissions.
permissions: {}

# One group per plugin. GitHub keeps a single pending run per group and
# cancels any older pending run, so a shared group dropped one plugin's update
# whenever three releases landed together. A newer release of the same plugin
# supersedes an older pending one anyway; different plugins run in parallel and
# the push loop below resolves their races.
concurrency:
group: plugin-catalog-update-${{ inputs.repo || github.event.client_payload.repo }}
cancel-in-progress: false
# No concurrency group. A group keyed on the dispatch payload let anyone with
# the dispatch token cancel a plugin's pending run by sending bogus dispatches
# for it, since GitHub keeps one pending run per group. Runs instead race on the
# push: each attempt below rebuilds on the current main, and update-catalog
# re-checks the version against it, so a duplicate run becomes a no-op and an
# older release that loses to a newer one is refused.

jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
token: ${{ secrets.CATALOG_PUSH_TOKEN }}

- uses: actions/setup-go@v6
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version: "1.26"

Expand All @@ -44,19 +48,32 @@ jobs:
GITHUB_TOKEN: ${{ github.token }}
PLUGIN_REPO: ${{ inputs.repo || github.event.client_payload.repo }}
PLUGIN_TAG: ${{ inputs.tag || github.event.client_payload.tag }}
# Only a manual run can roll back; a repository_dispatch payload
# cannot set this.
ALLOW_ROLLBACK: ${{ github.event_name == 'workflow_dispatch' && inputs.allow_rollback }}
run: |
test -n "$PLUGIN_REPO"
test -n "$PLUGIN_TAG"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
args=(-repo "$PLUGIN_REPO" -tag "$PLUGIN_TAG")
if [ "$ALLOW_ROLLBACK" = "true" ]; then
args+=(-allow-rollback)
fi
# update-catalog validates the repository and tag, refuses a
# repository outside its official table, a version not newer than the
# listed one, drafts and prereleases, asset URLs outside the release,
# and an unsigned release of a plugin whose entry is signed. It
# verifies a signed release's binaries with gh attestation verify and
# reads manifest.json at the release's commit.
# A repository_dispatch run checks out main as it was when the release
# fired, and other releases may have updated the catalog since. Each
# attempt rebuilds the entry on the current main, so losing a push race
# retries instead of conflicting on manifest.json.
for attempt in 1 2 3 4 5; do
git fetch --quiet origin main
git reset --quiet --hard FETCH_HEAD
go run ./cmd/update-catalog -repo "$PLUGIN_REPO" -tag "$PLUGIN_TAG"
go run ./cmd/update-catalog "${args[@]}"
if git diff --quiet -- manifest.json; then
echo "The catalog already lists ${PLUGIN_REPO}@${PLUGIN_TAG}."
exit 0
Expand Down
67 changes: 0 additions & 67 deletions .github/workflows/update-manifest.yml

This file was deleted.

16 changes: 12 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,18 @@ gofmt -l .
none of the Go files touched by your change may appear in the output; do not add
to the output, and report what remains. For catalog output changes, inspect the
complete `manifest.json` diff and verify repository URLs, versions, platforms,
the checksum URL, capabilities, and presentation metadata against the source
release. The catalog stores a URL for `checksums.txt`, not the checksum values
themselves, so also confirm that the release asset exists and covers every
published binary.
the checksum URL, the bundle URL when the release is signed, capabilities, and
presentation metadata against the source release. The catalog stores a URL for
`checksums.txt`, not the checksum values themselves, so also confirm that the
release asset exists and covers every published binary.

Changes to `update-catalog`'s refusal rules (input validation, the plugin
table, version order, asset URLs, the commit binding, or signature policy)
need a unit test for each refusal in `catalog/catalog_test.go`.

A change to the official plugin table in `catalog/official.go` needs the same
change in Silo server's copy. Verify each entry's repository against the
`plugin_id` in that repository's `manifest.json`.

## Open the pull request

Expand Down
58 changes: 56 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,72 @@ Plugin repositories should dispatch `plugin_release_published` after publishing
a release. Set `SILO_PLUGINS_DISPATCH_TOKEN` in the plugin repository so it can
call `repository_dispatch` on `Silo-Server/silo-plugins`.

`update-catalog` refuses a release unless all of these hold:

- The repository is `owner/name` and the tag is `v<major>.<minor>.<patch>`,
optionally with a `-suffix`. Both are checked before either goes into a URL.
- The repository is bound to a plugin ID in
[`catalog/official.go`](catalog/official.go), and the release's
`manifest.json` names that ID. Adding a first-party plugin means adding it
there, and to the matching table in Silo server.
- The version is newer than the plugin's listed version. Re-running for the
listed version does nothing and succeeds. A deliberate rollback needs the
`allow_rollback` input of a manual `workflow_dispatch` run; a
`repository_dispatch` cannot set it.
- The release is published for exactly that tag and is neither a draft nor a
prerelease. There is no override for drafts or prereleases.
- Every catalogued asset URL is
`https://github.com/<repo>/releases/download/<tag>/<asset name>`.

`manifest.json` is read at a commit SHA, never at the tag name: the commit the
signature names for a signed release, or the commit the tag points at
(following an annotated tag) for an unsigned one.

A signed release also carries `plugin.sigstore.json`: a Sigstore bundle with
one SLSA provenance attestation covering every `plugin-<os>-<arch>` binary,
produced by the shared `plugin-release.yml` workflow in `Silo-Server/.github`.
The catalog entry then gains a package-level `bundle_url` beside
`checksums_url`. Before writing the entry, `update-catalog` checks each binary
with `gh attestation verify`, requiring the certificate identity
`https://github.com/Silo-Server/.github/.github/workflows/plugin-release.yml@refs/heads/main`,
the issuer `https://token.actions.githubusercontent.com`, the plugin's bound
repository, the source ref `refs/tags/v<version>`, a GitHub-hosted runner, a
Sigstore public-good transparency-log entry, and the same source commit for
every binary. Any failure refuses the release. Unsigned releases are still
accepted for a plugin until its catalog entry has a `bundle_url`; after that,
an unsigned release of that plugin is refused.

The workflow has no concurrency group. Runs race on the push, and each retry
rebuilds the entry on the current `main`, so a duplicate run is a no-op and an
older release that loses the race to a newer one is refused.

`silo-plugins` uses `CATALOG_PUSH_TOKEN` to push catalog updates. Reading a
plugin's release metadata and its tagged `manifest.json` needs no extra
credential: every catalogued plugin repository is public, so the workflow's own
`github.token` is enough. A plugin has to be public before it dispatches.

To exercise ingestion locally against an existing tagged release, pass the
repository in `owner/name` form and the exact release tag:
repository in `owner/name` form and the exact release tag. Verifying a signed
release needs the `gh` CLI on `PATH`:

```sh
go run ./cmd/update-catalog \
-repo Silo-Server/silo-plugin-metadata-tmdb \
-tag vX.Y.Z
```

`vX.Y.Z` must be a published release newer than the listed version. The listed
version does nothing and an older one is refused. To try the tool against a
release the catalog already lists, rebuild that entry in a copy of the catalog:

```sh
catalog_copy="$(mktemp)"
cp manifest.json "$catalog_copy"
go run ./cmd/update-catalog \
-repo Silo-Server/silo-plugin-metadata-tmdb \
-tag v1.2.23
-tag v1.2.29 \
-allow-rollback \
-manifest "$catalog_copy"
```

For a private source repository, provide `GITHUB_TOKEN` through your normal
Expand Down
32 changes: 15 additions & 17 deletions catalog/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ type Asset struct {
}

type Release struct {
TagName string `json:"tag_name"`
Assets []Asset `json:"assets"`
TagName string `json:"tag_name"`
Draft bool `json:"draft"`
Prerelease bool `json:"prerelease"`
Assets []Asset `json:"assets"`
}

type PlatformBinary struct {
Expand All @@ -31,6 +33,7 @@ type CatalogPackage struct {
Manifest *pluginv1.PluginManifest `json:"manifest"`
RepoURL string `json:"repo_url,omitempty"`
ChecksumsURL string `json:"checksums_url,omitempty"`
BundleURL string `json:"bundle_url,omitempty"`
Binaries map[string]PlatformBinary `json:"binaries,omitempty"`
}

Expand Down Expand Up @@ -69,22 +72,16 @@ func BuildPackageFromRelease(repo string, source *SourceManifest, release Releas
return CatalogPackage{}, fmt.Errorf("release tag_name is required")
}

checksumsURL := ""
binaries := map[string]PlatformBinary{}
for _, asset := range release.Assets {
switch {
case asset.Name == "checksums.txt":
checksumsURL = asset.BrowserDownloadURL
case strings.HasPrefix(asset.Name, "plugin-"):
platform, ok := platformKeyFromAssetName(asset.Name)
if !ok {
continue
}
binaries[platform] = PlatformBinary{URL: asset.BrowserDownloadURL}
}
assets, err := ParseReleaseAssets(repo, release)
if err != nil {
return CatalogPackage{}, err
}
binaries := make(map[string]PlatformBinary, len(assets.Binaries))
for platform, url := range assets.Binaries {
binaries[platform] = PlatformBinary{URL: url}
}

if checksumsURL == "" {
if assets.ChecksumsURL == "" {
return CatalogPackage{}, fmt.Errorf("release %q is missing checksums.txt", release.TagName)
}
if len(binaries) == 0 {
Expand All @@ -106,7 +103,8 @@ func BuildPackageFromRelease(repo string, source *SourceManifest, release Releas
return CatalogPackage{
Manifest: manifest,
RepoURL: repositoryURL,
ChecksumsURL: checksumsURL,
ChecksumsURL: assets.ChecksumsURL,
BundleURL: assets.BundleURL,
Binaries: binaries,
}, nil
}
Expand Down
Loading
Loading