-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathworkflow_release.go
More file actions
55 lines (47 loc) · 1.71 KB
/
workflow_release.go
File metadata and controls
55 lines (47 loc) · 1.71 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
// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company
// SPDX-License-Identifier: Apache-2.0
package ghworkflow
import "github.com/sapcc/go-makefile-maker/internal/core"
func releaseWorkflow(cfg core.Configuration) {
// https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#publishing-a-package-using-an-action
ghwCfg := cfg.GitHubWorkflow
w := newWorkflow("goreleaser", ghwCfg.Global.DefaultBranch, nil)
if w.deleteIf(ghwCfg.Release.Enabled.UnwrapOr(cfg.GoReleaser.ShouldCreateConfig())) {
return
}
w.Permissions.Contents = tokenScopeWrite
w.Permissions.Packages = tokenScopeWrite
w.On.Push.Branches = nil
w.On.PullRequest.Branches = nil
w.On.Push.Tags = []string{"*"} // goreleaser uses semver to decide if this is a prerelease or not
j := baseJobWithGo("goreleaser", cfg)
// This is needed because: https://goreleaser.com/ci/actions/#fetch-depthness
j.Steps[0].With = map[string]any{
"fetch-depth": 0,
}
j.addStep(jobStep{
Name: "Install syft",
Uses: core.DownloadSyftAction,
})
j.addStep(jobStep{
Name: "Generate release info",
Run: makeMultilineYAMLString([]string{
"go install github.com/sapcc/go-bits/tools/release-info@latest",
"mkdir -p build",
`release-info CHANGELOG.md "$(git describe --tags --abbrev=0)" > build/release-info`,
}),
})
j.addStep(jobStep{
Name: "Run GoReleaser",
Uses: core.GoreleaserAction,
With: map[string]any{
"version": "latest",
"args": "release --clean --release-notes=./build/release-info",
},
Env: map[string]string{
"GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}",
},
})
w.Jobs = map[string]job{"release": j}
writeWorkflowToFile(w)
}