-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Publish the k0s_sort binary Signed-off-by: Kimmo Lehto <[email protected]> * Dont rename main.go * Remove check-latest Signed-off-by: Kimmo Lehto <[email protected]> * Copy-paste fail Signed-off-by: Kimmo Lehto <[email protected]> --------- Signed-off-by: Kimmo Lehto <[email protected]>
- Loading branch information
Showing
7 changed files
with
180 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,25 @@ | ||
name: Go | ||
|
||
on: [push, pull_request] | ||
on: [pull_request] | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
if: github.ref != 'refs/heads/main' | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.17 | ||
|
||
- name: Go modules cache | ||
uses: actions/cache@v2 | ||
if: github.ref != 'refs/heads/main' | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
go-version-file: go.mod | ||
|
||
- name: Run golangci-lint | ||
if: github.ref != 'refs/heads/main' | ||
uses: golangci/[email protected] | ||
with: | ||
version: v1.44.0 | ||
skip-go-installation: true | ||
uses: golangci/golangci-lint-action@v3 | ||
|
||
- name: Build | ||
if: github.ref != 'refs/heads/main' | ||
run: go build -v ./... | ||
run: make k0s_sort | ||
|
||
- name: Test | ||
if: github.ref != 'refs/heads/main' | ||
run: go test -v ./... | ||
run: make test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | ||
|
||
jobs: | ||
release: | ||
name: release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v4 | ||
|
||
- name: Tag name | ||
id: tag-name | ||
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT" | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: go.mod | ||
|
||
- name: Build binaries | ||
id: build_bins | ||
env: | ||
TAG_NAME: ${{ steps.tag-name.outputs.tag }} | ||
run: make build-all | ||
|
||
- name: Create release and upload binaries | ||
uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
files: | | ||
bin/k0s_sort-* | ||
bin/checksums.txt | ||
tag_name: ${{ steps.tag-name.outputs.tag }} | ||
name: ${{ steps.tag-name.outputs.tag }} | ||
generate_release_notes: true | ||
prerelease: ${{ contains(steps.tag-name.outputs.tag, '-') }} # v0.1.2-beta1, 1.2.3-rc1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bin/ | ||
k0s_sort |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
GO_SRCS := $(shell find . -type f -name '*.go' -a ! \( -name 'zz_generated*' -o -name '*_test.go' \)) | ||
TAG_NAME = $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null || echo "dev") | ||
PREFIX = /usr/local | ||
LD_FLAGS = -s -w -X github.com/k0sproject/version/internal/version.Version=$(TAG_NAME) | ||
BUILD_FLAGS = -trimpath -a -tags "netgo,osusergo,static_build" -installsuffix netgo -ldflags "$(LD_FLAGS) -extldflags '-static'" | ||
|
||
k0s_sort: $(GO_SRCS) | ||
CGO_ENABLED=0 go build $(BUILD_FLAGS) -o $@ ./cmd/k0s_sort | ||
|
||
PLATFORMS := linux-amd64 linux-arm64 linux-arm darwin-amd64 darwin-arm64 windows-amd64 | ||
bins := $(foreach platform, $(PLATFORMS), bin/$(BIN_PREFIX)$(platform)) | ||
$(bins): | ||
$(eval temp := $(subst -, ,$(subst $(BIN_PREFIX),,$(notdir $@)))) | ||
$(eval OS := $(word 1, $(subst -, ,$(temp)))) | ||
$(eval ARCH := $(word 2, $(subst -, ,$(temp)))) | ||
GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go build $(BUILD_FLAGS) -o $@ ./cmd/k0s_sort | ||
|
||
bin/sha256sums.txt: $(bins) | ||
sha256sum -b $(bins) | sed 's|bin/||' > $@ | ||
|
||
build-all: $(bins) bin/sha256sums.txt | ||
|
||
.PHONY: install | ||
install: k0s_sort | ||
install -d $(DESTDIR)$(PREFIX)/bin/ | ||
install -m 755 k0s_sort $(DESTDIR)$(PREFIX)/bin/ | ||
|
||
.PHONY: test | ||
test: | ||
go clean -testcache && go test -count=1 -v ./... | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf k0s_sort bin | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package version | ||
|
||
var Version = "dev" |