From dacfe26650f9a0908d43d183f5d1e2189effb45e Mon Sep 17 00:00:00 2001 From: jolheiser Date: Thu, 2 Jun 2022 22:23:14 -0500 Subject: [PATCH 1/4] Add goreleaser Signed-off-by: jolheiser --- .gitignore | 3 ++- .goreleaser.yaml | 25 ++++++++++++++++++++++++ .woodpecker.yml | 49 +++++++++--------------------------------------- 3 files changed, 36 insertions(+), 41 deletions(-) create mode 100644 .goreleaser.yaml diff --git a/.gitignore b/.gitignore index afb63d4..c0c7cc9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ # Binaries /tmpl -/tmpl.exe \ No newline at end of file +/tmpl.exe +dist/ \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..a672de5 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,25 @@ +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + ldflags: + - "-s -w -X go.jolheiser.com/tmpl/cmd.Version={{.Version}}" +archives: + - replacements: + 386: i386 + amd64: x86_64 + format_overrides: + - goos: windows + format: zip +checksum: + name_template: 'checksums.txt' +release: + gitea: + owner: jolheiser + name: tmpl +gitea_urls: + api: https://git.jojodev.com/api/v1/ + download: https://git.jojodev.com diff --git a/.woodpecker.yml b/.woodpecker.yml index 2d9dbb0..73e9ceb 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -1,10 +1,6 @@ -clone: - git: - image: woodpeckerci/plugin-git:next - pipeline: compliance: - image: golang:1.17 + image: golang:1.18 commands: - go test -race ./... - go vet ./... @@ -13,47 +9,20 @@ pipeline: when: event: pull_request - build: - image: golang:1.17 + release: + image: goreleaser/goreleaser commands: - - GOOS="windows" go build - - GOOS="linux" go build + - goreleaser release + secrets: [ gitea_token ] when: event: [ push, tag ] branch: main - release-main: - image: jolheiser/drone-gitea-main:latest - secrets: - - source: gitea_token - target: plugin_token - base: https://git.jojodev.com - files: - - "tmpl" - - "tmpl.exe" - when: - event: push - branch: main - - release-tag: - image: plugins/gitea-release:1 - secrets: - - source: gitea_token - target: plugin_api_key - base_url: https://git.jojodev.com - files: - - "tmpl" - - "tmpl.exe" - when: - event: tag - tag: v* - prune: image: jolheiser/drone-gitea-prune - secrets: - - source: gitea_token - target: plugin_token - base: https://git.jojodev.com + settings: + base: https://git.jojodev.com + token: + from_secret: gitea_token when: event: tag - tag: v* -- 2.41.0 From d49adbf18e1313391103f82bd1e8c411468fb580 Mon Sep 17 00:00:00 2001 From: jolheiser Date: Thu, 2 Jun 2022 22:52:33 -0500 Subject: [PATCH 2/4] Test build in CI Signed-off-by: jolheiser --- .woodpecker.yml | 10 ++++++++-- go.sum | 3 --- tools.go | 8 -------- 3 files changed, 8 insertions(+), 13 deletions(-) delete mode 100644 tools.go diff --git a/.woodpecker.yml b/.woodpecker.yml index 73e9ceb..af3e782 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -4,8 +4,14 @@ pipeline: commands: - go test -race ./... - go vet ./... - - go run github.com/rs/zerolog/cmd/lint go.jolheiser.com/tmpl - - go build + - go run github.com/rs/zerolog/cmd/lint@latest go.jolheiser.com/tmpl + when: + event: pull_request + + build: + image: goreleaser/goreleaser + commands: + - goreleaser build --snapshot when: event: pull_request diff --git a/go.sum b/go.sum index e9c797a..2901739 100644 --- a/go.sum +++ b/go.sum @@ -120,7 +120,6 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9 h1:umElSU9WZirRdgu2yFHY0ayQkEnKiOC1TtM3fWXFnoU= golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -147,11 +146,9 @@ golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.7 h1:6j8CgantCy3yc8JGBqkDLMKWqZ0RDU2g1HVgacojGWQ= golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/tools.go b/tools.go deleted file mode 100644 index 048b2fa..0000000 --- a/tools.go +++ /dev/null @@ -1,8 +0,0 @@ -//go:build tools -// +build tools - -package main - -import ( - _ "github.com/rs/zerolog/cmd/lint" -) -- 2.41.0 From d6137644f69ac36d7dd99ef28d7e33b984e3ea4a Mon Sep 17 00:00:00 2001 From: jolheiser Date: Thu, 2 Jun 2022 23:02:14 -0500 Subject: [PATCH 3/4] Fetch tags Signed-off-by: jolheiser --- .woodpecker.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.woodpecker.yml b/.woodpecker.yml index af3e782..eaeb241 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -1,3 +1,9 @@ +clone: + git: + image: woodpeckerci/plugin-git + settings: + tags: true + pipeline: compliance: image: golang:1.18 -- 2.41.0 From 033e9c02878e5c9fa6c1d500f65a3981e56d0da1 Mon Sep 17 00:00:00 2001 From: jolheiser Date: Thu, 2 Jun 2022 23:07:32 -0500 Subject: [PATCH 4/4] Only tag Signed-off-by: jolheiser --- .woodpecker.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index eaeb241..d46ebfc 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -27,8 +27,7 @@ pipeline: - goreleaser release secrets: [ gitea_token ] when: - event: [ push, tag ] - branch: main + event: tag prune: image: jolheiser/drone-gitea-prune -- 2.41.0