Skip to content

Commit 52642f9

Browse files
authored
Merge pull request #36 from xmudrii/release-action
✨ Add GoReleaser config and Release GitHub Action
2 parents 525e44a + c4a8864 commit 52642f9

File tree

4 files changed

+103
-0
lines changed

4 files changed

+103
-0
lines changed

Diff for: .github/workflows/release.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: goreleaser
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- .github/workflows/release.yml
7+
- .goreleaser.yaml
8+
push:
9+
tags:
10+
- 'v*'
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
release:
17+
runs-on: ubuntu-latest
18+
19+
permissions:
20+
contents: write
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v3
25+
with:
26+
fetch-depth: 0
27+
28+
- uses: actions/setup-go@v5
29+
with:
30+
go-version: v1.22.10
31+
32+
- name: Delete non-semver tags
33+
run: 'git tag -d $(git tag -l | grep -v "^v")'
34+
35+
- name: Set LDFLAGS
36+
run: echo LDFLAGS="$(make ldflags)" >> $GITHUB_ENV
37+
38+
- name: Run GoReleaser on tag
39+
if: github.event_name != 'pull_request'
40+
uses: goreleaser/goreleaser-action@v6
41+
with:
42+
distribution: goreleaser
43+
version: latest
44+
args: release --timeout 60m
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
48+
- name: Run GoReleaser on pull request
49+
if: github.event_name == 'pull_request'
50+
uses: goreleaser/goreleaser-action@v6
51+
with:
52+
distribution: goreleaser
53+
version: latest
54+
args: release --timeout 60m --snapshot
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
58+
- uses: actions/upload-artifact@v4
59+
if: github.event_name == 'pull_request'
60+
with:
61+
name: binaries
62+
path: dist/*.tar.gz

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/_build/
2+
/dist/
23
/_tools/
34
/vendor/
45
/.kcp.e2e/

Diff for: .goreleaser.yaml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2025 The KCP Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
builds:
16+
- id: "api-syncagent"
17+
main: ./cmd/api-syncagent
18+
binary: api-syncagent
19+
ldflags:
20+
- "{{ .Env.LDFLAGS }}"
21+
goos:
22+
- linux
23+
- darwin
24+
goarch:
25+
- amd64
26+
- arm64
27+
env:
28+
- CGO_ENABLED=0
29+
30+
archives:
31+
- id: api-syncagent
32+
builds:
33+
- api-syncagent
34+
35+
release:
36+
draft: true
37+
mode: keep-existing

Diff for: Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ GOOS ?= $(shell go env GOOS)
3030
.PHONY: all
3131
all: build test
3232

33+
ldflags:
34+
@echo $(LDFLAGS)
35+
3336
.PHONY: build
3437
build: $(CMD)
3538

0 commit comments

Comments
 (0)