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
62 changes: 62 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: goreleaser

on:
pull_request:
paths:
- .github/workflows/release.yml
- .goreleaser.yaml
push:
tags:
- 'v*'

permissions:
contents: read

jobs:
release:
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-go@v5
with:
go-version: v1.22.10

- name: Delete non-semver tags
run: 'git tag -d $(git tag -l | grep -v "^v")'

- name: Set LDFLAGS
run: echo LDFLAGS="$(make ldflags)" >> $GITHUB_ENV

- name: Run GoReleaser on tag
if: github.event_name != 'pull_request'
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release --timeout 60m
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser on pull request
if: github.event_name == 'pull_request'
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release --timeout 60m --snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/upload-artifact@v4
if: github.event_name == 'pull_request'
with:
name: binaries
path: dist/*.tar.gz
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/_build/
/dist/
/_tools/
/vendor/
/.kcp.e2e/
Expand Down
37 changes: 37 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2025 The KCP Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

builds:
- id: "api-syncagent"
main: ./cmd/api-syncagent
binary: api-syncagent
ldflags:
- "{{ .Env.LDFLAGS }}"
goos:
- linux
- darwin
goarch:
- amd64
- arm64
env:
- CGO_ENABLED=0

archives:
- id: api-syncagent
builds:
- api-syncagent

release:
draft: true
mode: keep-existing
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ GOOS ?= $(shell go env GOOS)
.PHONY: all
all: build test

ldflags:
@echo $(LDFLAGS)

.PHONY: build
build: $(CMD)

Expand Down
Loading