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
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
timeout-minutes: 15
permissions:
contents: write
# task release asks proven whether the gate passed on the commit, which reads its runs.
actions: read
id-token: write
attestations: write
steps:
Expand Down Expand Up @@ -82,13 +84,14 @@ jobs:
with:
subject-path: _output/release/*.tar.gz

# The task every repository releases with: it asks the gate again, names the release as the
# step above did - no tag has been made since - and publishes the files, which tags it.
- name: The release
if: steps.name.outputs.new == 'true'
env:
GH_TOKEN: ${{ github.token }}
SHA: ${{ github.event.workflow_run.head_sha }}
VERSION: ${{ steps.name.outputs.version }}
run: task release:publish
run: task release

# On every run, a commit released already included: what a failed run left untagged is
# tagged by the next.
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ their `go.mod`; each fails CI with a specific finding and says how to resolve it
| [`exposure`](https://spin-stack.github.io/go-tools/exposure/) | what a repository would show if made public: secrets and private values in every ref's commits, pull request heads included, and in its issues, comments and releases |
| [`planguard`](https://spin-stack.github.io/go-tools/planguard/) | an OpenTofu plan that takes something away - a delete, a replacement, a forget - which an installation applying on a schedule leaves to a person, and applies the rest |
| [`task`](https://spin-stack.github.io/go-tools/start/) | not a check: Task at the version `versions.yaml` pins, with every other go-tools command on its `PATH`, the tools at their latest release - both downloaded as binaries; the one command a repository's `go.mod` takes, so neither Task's modules nor the tools' are compiled or cached |
| [the common tasks](https://spin-stack.github.io/go-tools/tasks/) | not a check: `versions`, `bump`, `release`, `lint:workflows` and `consumers`, written once and included by every repository's Taskfile from the release `go tool task` unpacks - the same names, arguments and meaning in each |
| [`release`](https://spin-stack.github.io/go-tools/release/) | not a check: the name of a repository's next release, `v<YYYYMMDD>.<NN>`, and a refusal for a commit already released |
| [`consumers`](https://spin-stack.github.io/go-tools/consumers/) | not a check: which commit of a repository each place that copies from it is on, whether its copies are that commit's, and whether its npm packages are the ones pinned there |
| [`gencache`](https://spin-stack.github.io/go-tools/gencache/) | not a check: `go generate` with each mockgen directive answered from a cache when nothing its mock is made from has changed |
| [`ghatrace`](https://spin-stack.github.io/go-tools/ghatrace/) | not a check: where a GitHub Actions run's time went - the critical path, each job's wait for a runner, its steps and the spans inside them - as the run's summary, an HTML page and a Perfetto trace, with nothing hosted |
| [`provenance`, `sbom`, `attestgate`, `trustroot`, `sigcheck`, `catalog`](https://spin-stack.github.io/go-tools/supply-chain/) | releases published without SLSA provenance or an SBOM; a signature by any workflow but the one named; a Spin OS image catalog its release did not sign |
Expand All @@ -36,8 +39,8 @@ go tool task mutate # a task that runs `mutat

[Getting started](https://spin-stack.github.io/go-tools/start/) has the `versions.yaml` entry.

`versions`, `versions/upstream`, `versions/gate`, `provenance`, `attestgate`, `sbom`, `ghatrace`, `sigcheck`, `catalog` and
`trustroot` are also packages another repository imports; the rest is `internal/`.
`versions`, `versions/upstream`, `versions/gate`, `provenance`, `attestgate`, `sbom`, `ghatrace`, `sigcheck`, `catalog`,
`consumers` and `trustroot` are also packages another repository imports; the rest is `internal/`.

## Working here

Expand All @@ -48,6 +51,9 @@ task mutate # break what the change against BASE (origin/main) touched, and a
task site # the documentation site (site/), built
```

`versions`, `bump`, `release`, `lint:workflows` and `consumers` are `cmd/task/tasks.yml`'s, the
file every repository includes: this one includes its tree's copy, with its tree's commands.

The site is Astro Starlight under `site/`, styled as [spin-stack/website](https://github.com/spin-stack/website),
and published to GitHub Pages from `main`. The example on its mutate page is
`cmd/mutate/testdata/example`, which `TestTheExampleTheSiteShows` runs on every CI run.
Expand Down
82 changes: 31 additions & 51 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,37 @@
# task coverage coverage.out's numbers, to the terminal or the workflow run's summary
# task trace where a workflow run's time went (ghatrace), to its summary and _output/ghatrace
# task versions which pins in versions.yaml are behind; task bump NAME=... moves one
# task release what release.yml runs once the binaries are built: the next v<YYYYMMDD>.<NN>
#
# versions, bump, release, lint:workflows and consumers are cmd/task/tasks.yml's, which every
# repository includes: none of them is written here.
# task site the documentation site under site/, built into site/dist

version: '3'

silent: true

# The Task this runs under, for the tests that run cmd/task/tasks.yml under Task itself.
env:
TASK_EXE: '{{.TASK_EXE}}'

includes:
# The tree's file, as another repository includes the released one ({{.GO_TOOLS_TASKS}}), and
# with the tree's commands: a change to a task or to what it calls is held to this repository
# before any release carries it.
common:
taskfile: cmd/task/tasks.yml
flatten: true
vars:
GO_TOOLS: 'go run ./cmd/'
GATE_WORKFLOW: ci.yml
GATE_JOBS: Gate
RELEASE_FILES: _output/release/*.tar.gz _output/release/checksums.txt
# The others are the pins go tool sfw and go tool exposure embed for every repository.
VERSIONS_FILES: versions.yaml cmd/sfw/versions.yaml cmd/exposure/versions.yaml
# The site's CI page shows this workflow for a repository to copy.
WORKFLOWS_ALSO: site/examples/github/.github

vars:
OUT: '{{.ROOT_DIR}}/_output'
VERSIONS: go run ./cmd/versions
Expand Down Expand Up @@ -68,21 +93,6 @@ tasks:
- go run ./cmd/trustroot -check
- task: lint:workflows

lint:workflows:
desc: actionlint over .github/, and every action pinned by its commit.
cmds:
# -shellcheck= because actionlint runs whatever shellcheck is on PATH: a runner has one and
# a laptop may not, and a gate whose answer depends on the machine is not a gate.
- go run github.com/rhysd/actionlint/cmd/actionlint@$({{.VERSIONS}} version actionlint) -shellcheck=
# The site's CI page shows this workflow for a repository to copy.
- go run github.com/rhysd/actionlint/cmd/actionlint@$({{.VERSIONS}} version actionlint) -shellcheck= site/examples/github/.github/workflows/*.yml
# A tag is whatever its owner points it at; the comment is the version Dependabot moves.
- cmd: |
if grep -rnE '^\s*(- )?uses: [^./][^ ]*@' .github site/examples/github/.github | grep -vE '@[0-9a-f]{40} # v[0-9]'; then
echo "an action above is used by a tag its owner can move: pin it by commit SHA, with '# vX.Y.Z' after it"
exit 1
fi

mutate:
desc: Break what the change against BASE touched and fail on an edit no test refuses (BASE=origin/main; in CI, what the run's event diffs against).
cmds:
Expand Down Expand Up @@ -115,13 +125,14 @@ tasks:
- go run ./cmd/ghatrace run -spans "${RUNNER_TEMP:-}"

release:build:
desc: Every command, for each platform a repository runs them on, as _output/release/go-tools_<os>_<arch>.tar.gz.
desc: Every command and the tasks every repository includes, for each platform a repository runs them on, as _output/release/go-tools_<os>_<arch>.tar.gz.
# What a repository's `go tool task` (cmd/task) unpacks onto Task's PATH, so that no repository
# compiles these commands or takes their modules. Stripped and without cgo: a program that runs
# on any machine of its platform, the same bytes from the same commit. The archive's members
# are sorted, owned by nobody and dated by the commit, for the same reason. cmd/task is not in
# it: it is the command a repository compiles, and its directory is first on Task's PATH, where
# a second task would stand in front of Task.
# a second task would stand in front of Task. Its tasks.yml is: the tasks a repository includes
# are of the release their commands are from.
vars:
PLATFORMS: linux/amd64 linux/arm64 darwin/amd64 darwin/arm64
COMMANDS:
Expand All @@ -145,6 +156,8 @@ tasks:
--ignore github.com/spin-stack/go-tools {{.COMMANDS}} \
| go run ./internal/release/cmd/notices -go "$(go env GOVERSION)" -goroot "$(go env GOROOT)" \
> {{.OUT}}/release/{{replace "/" "_" .ITEM}}/THIRD_PARTY_NOTICES
- for: {var: PLATFORMS, split: ' '}
cmd: cp cmd/task/tasks.yml {{.OUT}}/release/{{replace "/" "_" .ITEM}}/
- for: {var: PLATFORMS, split: ' '}
cmd: >-
tar --sort=name --owner=0 --group=0 --numeric-owner --mtime="@$(git show -s --format=%ct HEAD)"
Expand All @@ -157,19 +170,7 @@ tasks:
requires:
vars: [SHA]
cmds:
- go run ./internal/release/cmd/releasename {{.SHA}} >> "${GITHUB_OUTPUT:-/dev/stdout}"

release:publish:
desc: Publish _output/release as the GitHub release VERSION of SHA, which tags it (GH_TOKEN).
# The tag is made by the release, last: a release that failed to publish is no tag that names a
# commit with no files.
requires:
vars: [SHA, VERSION]
cmds:
- >-
gh release create {{.VERSION}} {{.OUT}}/release/*.tar.gz {{.OUT}}/release/checksums.txt
--target {{.SHA}} --title {{.VERSION}}
--notes "Every go-tools command at {{.SHA}}, attested as built by release.yml. A repository's \`go tool task\` runs the latest."
- go run ./cmd/release -outputs {{.SHA}} >> "${GITHUB_OUTPUT:-/dev/stdout}"

release:module:
desc: Tag SHA as MODULE, its release's module version, unless it is already (GH_TOKEN).
Expand Down Expand Up @@ -199,24 +200,3 @@ tasks:
cmds:
- go run ./cmd/sfw pnpm --dir site install --frozen-lockfile
- pnpm --dir site dev

versions:
desc: Say which of versions.yaml's pins are behind their upstream, and of those cmd/sfw and cmd/exposure carry (exits 1 when any is).
cmds:
# Every file, whichever is behind: the others are the pins go tool sfw and go tool exposure
# embed for every repository.
- |
status=0
{{.VERSIONS}} check || status=1
{{.VERSIONS}} check -file cmd/sfw/versions.yaml || status=1
{{.VERSIONS}} check -file cmd/exposure/versions.yaml || status=1
exit $status

bump:
desc: Pin one entry of versions.yaml at a version, the newest by default (task bump NAME=golangci-lint [VERSION=v2.14.0]; FILE=cmd/sfw/versions.yaml or cmd/exposure/versions.yaml for what those commands embed).
requires:
vars: [NAME]
vars:
FILE: '{{.FILE | default "versions.yaml"}}'
cmds:
- '{{.VERSIONS}} bump -file {{.FILE}} {{.NAME}} {{.VERSION}}'
Loading