Skip to content

Commit

Permalink
Use goreleaser (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
superbrothers authored Nov 8, 2020
1 parent bbe0f55 commit 86bbe29
Show file tree
Hide file tree
Showing 12 changed files with 1,008 additions and 207 deletions.
53 changes: 3 additions & 50 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: CI
on:
push:
branches: [master]
tags: ["v*"]
paths-ignore: ['**.md']
pull_request:
types: [opened, synchronize]
Expand All @@ -16,7 +15,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "~1.13.10"
go-version: 1.15.x
- name: Ensure go.mod is already tidied
run: go mod tidy && git diff -s --exit-code go.sum
- uses: actions/cache@v2
Expand All @@ -25,51 +24,5 @@ jobs:
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- run: go get github.com/mitchellh/gox
- run: make test archives test-archive
- name: Create a new release
if: contains(github.ref, 'tags')
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
- name: Upload binaries to the new release
if: contains(github.ref, 'tags')
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: out/*
tag: ${{ github.ref }}
overwrite: true
file_glob: true
create-pr:
needs: [run]
if: contains(github.ref, 'tags')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
repository: kubernetes-sigs/krew-index
- run: |
git fetch --unshallow
git remote set-url origin https://${{ secrets.GH_PAT }}:[email protected]/superbrothers/krew-index.git
- run: echo ::set-env name=GIT_TAG::${GITHUB_REF##*/}
- name: Download the released krew plugin manifest file
run: |
curl -sLo plugins/sort-manifests.yaml https://github.com/superbrothers/kubectl-sort-manifests-plugin/releases/download/${{ env.GIT_TAG }}/sort-manifests.yaml
git --no-pager diff
- uses: peter-evans/create-pull-request@v2
with:
token: ${{ secrets.GH_PAT }}
committer: Kazuki Suda <[email protected]>
author: Kazuki Suda <[email protected]>
commit-message: Bump the version of sort-manifests to ${{ env.GIT_TAG }}
title: Bump the version of sort-manifests to ${{ env.GIT_TAG }}
body: This PR bumps up the version of sort-manifests to ${{ env.GIT_TAG }}.
branch: sort-manifests-${{ env.GIT_TAG }}
request-to-parent: true
- run: make test
- run: make dist
26 changes: 26 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Release

on:
push:
tags: ["v*"]

jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.15.x
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Release
run: make release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update new version in krew-index
uses: rajatjindal/[email protected]
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/out
/dist
/hack/tools/bin
27 changes: 27 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
env:
- GO111MODULE=on
- GOPROXY=https://gocenter.io
builds:
- main: ./cmd/ksort/main.go
binary: ksort
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm
- arm64
archives:
- name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}"
format: zip
files:
- LICENSE.txt
- README.md
wrap_in_directory: false
checksum:
name_template: 'checksums.txt'
changelog:
sort: asc
25 changes: 8 additions & 17 deletions hack/sort-manifests.yaml → .krew.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Plugin
metadata:
name: sort-manifests
spec:
version: KSORT_VERSION
version: {{ .TagName }}
shortDescription: Sort manifest files in a proper order by Kind
description: |
When installing manifests, they should be sorted in a proper order by Kind.
Expand All @@ -14,37 +14,28 @@ spec:
using tiller.SortByKind() in Kubernetes Helm.
homepage: https://github.com/superbrothers/ksort
platforms:
- uri: https://github.com/superbrothers/ksort/releases/download/KSORT_VERSION/ksort-darwin-amd64.zip
sha256: KSORT_DARWIN_ZIP_CHECKSUM
- {{addURIAndSha "https://github.com/superbrothers/ksort/releases/download/{{ .TagName }}/ksort-darwin-amd64.zip" .TagName }}
bin: ksort
files:
- from: ksort
to: .
- from: LICENSE.txt
- from: "*"
to: .
selector:
matchLabels:
os: darwin
arch: amd64
- uri: https://github.com/superbrothers/ksort/releases/download/KSORT_VERSION/ksort-linux-amd64.zip
sha256: KSORT_LINUX_ZIP_CHECKSUM
- {{addURIAndSha "https://github.com/superbrothers/ksort/releases/download/{{ .TagName }}/ksort-linux-amd64.zip" .TagName }}
bin: ksort
files:
- from: ksort
to: .
- from: LICENSE.txt
- from: "*"
to: .
selector:
matchLabels:
os: linux
arch: amd64
- uri: https://github.com/superbrothers/ksort/releases/download/KSORT_VERSION/ksort-windows-amd64.zip
sha256: KSORT_WINDOWS_ZIP_CHECKSUM
bin: ksort.exe
- {{addURIAndSha "https://github.com/superbrothers/ksort/releases/download/{{ .TagName }}/ksort-windows-amd64.zip" .TagName }}
bin: ksort
files:
- from: ksort.exe
to: .
- from: LICENSE.txt
- from: "*"
to: .
selector:
matchLabels:
Expand Down
43 changes: 31 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,42 @@
GO ?= GO111MODULE=on GOPROXY=https://gocenter.io go
DIST_DIR := dist

.PHONY: build
build:
@OSARCH="$(shell uname -s | tr "[:upper:]" "[:lower:]")/amd64" hack/make-binaries.sh
$(GO) build -o $(DIST_DIR)/ksort cmd/ksort/main.go

TOOLS_DIR := hack/tools
TOOLS_BIN_DIR := $(TOOLS_DIR)/bin
GORELEASER_BIN := bin/goreleaser
GORELEASER := $(TOOLS_DIR)/$(GORELEASER_BIN)

$(GORELEASER): $(TOOLS_DIR)/go.mod
cd $(TOOLS_DIR) && $(GO) build -o $(GORELEASER_BIN) github.com/goreleaser/goreleaser

.PHONY: build-cross
build-cross:
@hack/make-binaries.sh
build-cross: $(GORELEASER)
$(GORELEASER) build --snapshot --rm-dist

.PHONY: archives
archives:
@hack/make-all.sh
.PHONY: vet
vet:
$(GO) vet ./...

.PHONY: fmt
fmt:
$(GO) fmt ./...

.PHONY: test
test:
go test -v ./...
test: vet fmt
$(GO) test -v ./...

.PHONY: dist
dist: $(GORELEASER)
$(GORELEASER) release --rm-dist --skip-publish --snapshot

.PHONY: test-archive
test-archive:
@hack/test-archive.sh
.PHONY: release
release: $(GORELEASER)
$(GORELEASER) release --rm-dist

.PHONY: clean
clean:
rm -rf out
rm -rf $(DIST_DIR) $(TOOLS_BIN_DIR)
9 changes: 0 additions & 9 deletions hack/make-all.sh

This file was deleted.

49 changes: 0 additions & 49 deletions hack/make-archives.sh

This file was deleted.

37 changes: 0 additions & 37 deletions hack/make-binaries.sh

This file was deleted.

32 changes: 0 additions & 32 deletions hack/test-archive.sh

This file was deleted.

7 changes: 7 additions & 0 deletions hack/tools/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module github.com/superbrothers/kubectl-open-svc-plugin/hack/tools

go 1.15

require (
github.com/goreleaser/goreleaser v0.145.0
)
Loading

0 comments on commit 86bbe29

Please sign in to comment.