Skip to content

Commit

Permalink
ci: migrate to Sage-based semantic release
Browse files Browse the repository at this point in the history
  • Loading branch information
odsod committed Jul 15, 2024
1 parent acdba12 commit 5a3f009
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ jobs:

- name: Make
run: make

- name: Dry-run semantic-release
run: make semantic-release repo=${{ github.repository }} dry=true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 4 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ jobs:
- name: Make
run: make

- name: Release
uses: go-semantic-release/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
allow-initial-development-versions: true
- name: Run semantic-release
run: make semantic-release repo=${{ github.repository }} dry=false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.idea
.vscode

# Go workspace files
go.work
go.work.sum
.semrel
16 changes: 16 additions & 0 deletions .sage/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"go.einride.tech/sage/tools/sggo"
"go.einride.tech/sage/tools/sggolangcilint"
"go.einride.tech/sage/tools/sggolines"
"go.einride.tech/sage/tools/sggosemanticrelease"
"go.einride.tech/sage/tools/sgmdformat"
"go.einride.tech/sage/tools/sgyamlfmt"
)
Expand Down Expand Up @@ -91,3 +92,18 @@ func GoGenerate(ctx context.Context) error {
sg.Logger(ctx).Println("generating Go code...")
return sg.Command(ctx, "go", "generate", "./...").Run()
}

func SemanticRelease(ctx context.Context, repo string, dry bool) error {
sg.Logger(ctx).Println("triggering release...")
args := []string{
"--allow-initial-development-versions",
"--allow-no-changes",
"--ci-condition=default",
"--provider=github",
"--provider-opt=slug=" + repo,
}
if dry {
args = append(args, "--dry")
}
return sggosemanticrelease.Command(ctx, args...).Run()
}
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ go-mod-tidy: $(sagefile)
go-test: $(sagefile)
@$(sagefile) GoTest

.PHONY: semantic-release
semantic-release: $(sagefile)
ifndef repo
$(error missing argument repo="...")
endif
ifndef dry
$(error missing argument dry="...")
endif
@$(sagefile) SemanticRelease "$(repo)" "$(dry)"

.PHONY: stringer
stringer: $(sagefile)
@$(sagefile) Stringer
Expand Down

0 comments on commit 5a3f009

Please sign in to comment.