diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-10-01 15:21:27 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-10-01 15:39:23 +0900 |
| commit | a356dceedf0be29ae584866e540872ec1c048f59 (patch) | |
| tree | 45a85d0514fd60d923dd780caf2204f562d33e28 | |
| parent | b0fa39b560d2caaaf0708c0828ae191311aee971 (diff) | |
internal/workflows: migrate release workflowstaging
This also migrates from the unmaintained release action and improves
configuration so the new release is created as a draft, and the tag
annotation is automatically added as the release body.
Signed-off-by: Ophestra <cat@gensokyo.uk>
| -rw-r--r-- | .gitea/workflows/release.yml | 2 | ||||
| -rw-r--r-- | internal/workflows/main.go | 10 | ||||
| -rw-r--r-- | internal/workflows/release.go | 41 | ||||
| -rw-r--r-- | internal/workflows/step.go | 6 | ||||
| -rw-r--r-- | internal/workflows/test.go | 14 |
5 files changed, 44 insertions, 29 deletions
diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index d4eb0de8..a91e3c67 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -1 +1 @@ -{"name":"Release","on":[{"K":"push","V":[{"K":"tags","V":"v*"}]}],"jobs":{"release":{"name":"Create release","runs-on":"nix","steps":[{"name":"Checkout","uses":"actions/checkout@v4"},{"name":"Build for release","run":"nix build --print-out-paths --print-build-logs ./test#dist"},{"name":"Release","uses":"https://gitea.com/actions/release-action@main","with":{"files":"result/hakurei-**","api_key":"${{secrets.RELEASE_TOKEN}}"}}]}}} +{"name":"Release","on":{"push":{"tags":["v*"]}},"jobs":{"release":{"name":"Create release","runs-on":"rosa","steps":[{"name":"Fix container filesystem","run":"rm /var/run \u0026\u0026 ln -sf ../run /var"},{"name":"Checkout","uses":"actions/checkout@v4","with":{"fetch-depth":0,"fetch-tags":true}},{"name":"Request distribution","id":"dist","run":"/rosa/bin/mbf ci dist -o result . \"$(cat cmd/dist/VERSION)-act\" \u0026\u0026 git tag --list --format='%(contents:body)' \"$(cat cmd/dist/VERSION)\" \u003e\u003e \"/tmp/release-body\""},{"name":"Create release","uses":"https://gitea.com/actions/gitea-release-action@v1.3.7","with":{"files":"result/hakurei-**","body_path":"/tmp/release-body","draft":true}}]}}} diff --git a/internal/workflows/main.go b/internal/workflows/main.go index 46f7e054..dca480a5 100644 --- a/internal/workflows/main.go +++ b/internal/workflows/main.go @@ -21,16 +21,16 @@ type KV[T any] struct { type Map[T any] []KV[T] // MarshalJSON encodes m as a key-value pair in JSON. -func (m *Map[T]) MarshalJSON() ([]byte, error) { - if m == nil || len(*m) == 0 { +func (m Map[T]) MarshalJSON() ([]byte, error) { + if m == nil || len(m) == 0 { return []byte("{}"), nil } - buf := bytes.NewBuffer(make([]byte, 0, len(*m)<<5)) + buf := bytes.NewBuffer(make([]byte, 0, len(m)<<5)) buf.WriteByte('{') - last := len(*m) - 1 - for i, pair := range *m { + last := len(m) - 1 + for i, pair := range m { p, err := json.Marshal(pair.K) if err != nil { return nil, fmt.Errorf("key %q: %w", pair.K, err) diff --git a/internal/workflows/release.go b/internal/workflows/release.go index 6322a0e0..f220c0f7 100644 --- a/internal/workflows/release.go +++ b/internal/workflows/release.go @@ -4,31 +4,46 @@ package main var _ = (&Workflow{ Name: "Release", - On: Map[any]{{K: "push", V: Map[string]{{K: "tags", V: "v*"}}}}, + On: Map[any]{{"push", Map[[]string]{{"tags", []string{"v*"}}}}}, Jobs: []KV[Job]{ - {K: "release", V: Job{ + {"release", Job{ Name: "Create release", - On: "nix", + On: "rosa", Steps: []Step{ - checkout, + fixup, { - Name: "Build for release", - Run: "nix build " + - "--print-out-paths " + - "--print-build-logs " + - "./test#dist", + Name: "Checkout", + Uses: "actions/checkout@v4", + + With: []KV[any]{ + {"fetch-depth", 0}, + {"fetch-tags", true}, + }, + }, + + { + Name: "Request distribution", + ID: "dist", + Run: "/rosa/bin/mbf ci dist -o result " + + ". \"$(cat cmd/dist/VERSION)-act\" && " + + "git tag " + + "--list " + + "--format='%(contents:body)' " + + "\"$(cat cmd/dist/VERSION)\" >> " + + "\"/tmp/release-body\"", }, { - Name: "Release", - Uses: "https://gitea.com/actions/release-action@main", + Name: "Create release", + Uses: "https://gitea.com/actions/gitea-release-action@v1.3.7", With: []KV[any]{ - {K: "files", V: "result/hakurei-**"}, - {K: "api_key", V: "${{secrets.RELEASE_TOKEN}}"}, + {"files", "result/hakurei-**"}, + {"body_path", "/tmp/release-body"}, + {"draft", true}, }, }, }, diff --git a/internal/workflows/step.go b/internal/workflows/step.go index c0138926..423a48ff 100644 --- a/internal/workflows/step.go +++ b/internal/workflows/step.go @@ -20,10 +20,10 @@ func newUploadArtifact(display, name string) Step { Uses: "actions/upload-artifact@v3", With: Map[any]{ - {K: "name", V: name}, - {K: "path", V: "result/*"}, + {"name", name}, + {"path", "result/*"}, - {K: "retention-days", V: 1}, + {"retention-days", 1}, }, } } diff --git a/internal/workflows/test.go b/internal/workflows/test.go index 9ccea1dc..88e91a22 100644 --- a/internal/workflows/test.go +++ b/internal/workflows/test.go @@ -7,7 +7,7 @@ var _ = (&Workflow{ On: []any{"push"}, Jobs: Map[Job]{ - {K: "hakurei", V: Job{ + {"hakurei", Job{ Name: "Hakurei", On: "nix", @@ -18,7 +18,7 @@ var _ = (&Workflow{ }, }}, - {K: "race", V: Job{ + {"race", Job{ Name: "Hakurei (race detector)", On: "nix", @@ -29,7 +29,7 @@ var _ = (&Workflow{ }, }}, - {K: "sandbox", V: Job{ + {"sandbox", Job{ Name: "Sandbox", On: "nix", @@ -40,7 +40,7 @@ var _ = (&Workflow{ }, }}, - {K: "sandbox-race", V: Job{ + {"sandbox-race", Job{ Name: "Sandbox (race detector)", On: "nix", @@ -51,7 +51,7 @@ var _ = (&Workflow{ }, }}, - {K: "sharefs", V: Job{ + {"sharefs", Job{ Name: "ShareFS", On: "nix", @@ -62,7 +62,7 @@ var _ = (&Workflow{ }, }}, - {K: "check", V: Job{ + {"check", Job{ Name: "Flake checks", On: "nix", @@ -87,7 +87,7 @@ var _ = (&Workflow{ }, }}, - {K: "dist", V: Job{ + {"dist", Job{ Name: "Create distribution", On: "rosa", |
