From e1109d033457d42c01e64984af349ddd1d90a233 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sun, 19 Dec 2021 03:19:14 +0100 Subject: [PATCH 1/7] s/DRONE_/CI_/g --- Makefile | 6 +++--- README.md | 30 +++++++++++++++--------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index d5a4e96..b1a346b 100644 --- a/Makefile +++ b/Makefile @@ -5,14 +5,14 @@ TARGETOS ?= linux TARGETARCH ?= amd64 VERSION ?= next -ifneq ($(DRONE_TAG),) - VERSION := $(DRONE_TAG:v%=%) +ifneq ($(CI_TAG),) + VERSION := $(CI_TAG:v%=%) endif # append commit-sha to next version BUILD_VERSION := $(VERSION) ifeq ($(BUILD_VERSION),next) - BUILD_VERSION := $(shell echo "next-$(shell echo ${DRONE_COMMIT_SHA} | head -c 8)") + BUILD_VERSION := $(shell echo "next-$(shell echo ${CI_COMMIT_SHA} | head -c 8)") endif LDFLAGS := -s -w -extldflags "-static" -X main.version=${BUILD_VERSION} diff --git a/README.md b/README.md index 71d2707..78e4426 100644 --- a/README.md +++ b/README.md @@ -53,11 +53,11 @@ Clone a commit: ```console docker run --rm \ - -e DRONE_REMOTE_URL=https://github.com/garyburd/redigo.git \ - -e DRONE_WORKSPACE=/go/src/github.com/garyburd/redigo \ - -e DRONE_BUILD_EVENT=push \ - -e DRONE_COMMIT_SHA=d8dbe4d94f15fe89232e0402c6e8a0ddf21af3ab \ - -e DRONE_COMMIT_REF=refs/heads/master \ + -e CI_REMOTE_URL=https://github.com/garyburd/redigo.git \ + -e CI_WORKSPACE=/go/src/github.com/garyburd/redigo \ + -e CI_BUILD_EVENT=push \ + -e CI_COMMIT_SHA=d8dbe4d94f15fe89232e0402c6e8a0ddf21af3ab \ + -e CI_COMMIT_REF=refs/heads/master \ woodpeckerci/plugin-git ``` @@ -65,11 +65,11 @@ Clone a pull request: ```console docker run --rm \ - -e DRONE_REMOTE_URL=https://github.com/garyburd/redigo.git \ - -e DRONE_WORKSPACE=/go/src/github.com/garyburd/redigo \ - -e DRONE_BUILD_EVENT=pull_request \ - -e DRONE_COMMIT_SHA=3b4642018d177bf5fecc5907e7f341a2b5c12b8a \ - -e DRONE_COMMIT_REF=refs/pull/74/head \ + -e CI_REMOTE_URL=https://github.com/garyburd/redigo.git \ + -e CI_WORKSPACE=/go/src/github.com/garyburd/redigo \ + -e CI_BUILD_EVENT=pull_request \ + -e CI_COMMIT_SHA=3b4642018d177bf5fecc5907e7f341a2b5c12b8a \ + -e CI_COMMIT_REF=refs/pull/74/head \ woodpeckerci/plugin-git ``` @@ -77,10 +77,10 @@ Clone a tag: ```console docker run --rm \ - -e DRONE_REMOTE_URL=https://github.com/garyburd/redigo.git \ - -e DRONE_WORKSPACE=/go/src/github.com/garyburd/redigo \ - -e DRONE_BUILD_EVENT=tag \ - -e DRONE_COMMIT_SHA=3b4642018d177bf5fecc5907e7f341a2b5c12b8a \ - -e DRONE_COMMIT_REF=refs/tags/74/head \ + -e CI_REMOTE_URL=https://github.com/garyburd/redigo.git \ + -e CI_WORKSPACE=/go/src/github.com/garyburd/redigo \ + -e CI_BUILD_EVENT=tag \ + -e CI_COMMIT_SHA=3b4642018d177bf5fecc5907e7f341a2b5c12b8a \ + -e CI_COMMIT_REF=refs/tags/74/head \ woodpeckerci/plugin-git ``` From 6714e2b59bd2a9f16145dc476fc79909a7163c25 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sun, 19 Dec 2021 03:36:21 +0100 Subject: [PATCH 2/7] fix version gen alg --- Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index b1a346b..b87b908 100644 --- a/Makefile +++ b/Makefile @@ -4,14 +4,18 @@ GO_PACKAGES ?= $(shell go list ./... | grep -v /vendor/) TARGETOS ?= linux TARGETARCH ?= amd64 +# rm once https://github.com/woodpecker-ci/woodpecker/pull/624 got merged +CI_COMMIT_TAG ?= $(CI_TAG) + VERSION ?= next -ifneq ($(CI_TAG),) - VERSION := $(CI_TAG:v%=%) +ifneq ($(CI_COMMIT_TAG),) + VERSION := $(CI_COMMIT_TAG:v%=%) endif # append commit-sha to next version BUILD_VERSION := $(VERSION) ifeq ($(BUILD_VERSION),next) + CI_COMMIT_SHA ?= $(shell git rev-parse HEAD) BUILD_VERSION := $(shell echo "next-$(shell echo ${CI_COMMIT_SHA} | head -c 8)") endif @@ -48,4 +52,4 @@ build: .PHONY: version version: - @echo ${VERSION} + @echo ${BUILD_VERSION} From 560d73bc076f4003e5c73f527c07a8668fc82659 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sun, 19 Dec 2021 03:38:22 +0100 Subject: [PATCH 3/7] pipeline print version --- .woodpecker.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.woodpecker.yml b/.woodpecker.yml index 5bd4867..75fb93f 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -12,6 +12,11 @@ pipeline: commands: - make test + version: + image: golang:1.16 + commands: + - make version + build-dryrun: image: woodpeckerci/plugin-docker-buildx:latest settings: From a36b3f77655c914fc8a09a4dce7042b047ddbd8c Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sun, 19 Dec 2021 03:51:31 +0100 Subject: [PATCH 4/7] CI_REMOTE_URL -> CI_REPO_REMOTE --- README.md | 6 +++--- main.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 78e4426..381817d 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Clone a commit: ```console docker run --rm \ - -e CI_REMOTE_URL=https://github.com/garyburd/redigo.git \ + -e CI_REPO_REMOTE=https://github.com/garyburd/redigo.git \ -e CI_WORKSPACE=/go/src/github.com/garyburd/redigo \ -e CI_BUILD_EVENT=push \ -e CI_COMMIT_SHA=d8dbe4d94f15fe89232e0402c6e8a0ddf21af3ab \ @@ -65,7 +65,7 @@ Clone a pull request: ```console docker run --rm \ - -e CI_REMOTE_URL=https://github.com/garyburd/redigo.git \ + -e CI_REPO_REMOTE=https://github.com/garyburd/redigo.git \ -e CI_WORKSPACE=/go/src/github.com/garyburd/redigo \ -e CI_BUILD_EVENT=pull_request \ -e CI_COMMIT_SHA=3b4642018d177bf5fecc5907e7f341a2b5c12b8a \ @@ -77,7 +77,7 @@ Clone a tag: ```console docker run --rm \ - -e CI_REMOTE_URL=https://github.com/garyburd/redigo.git \ + -e CI_REPO_REMOTE=https://github.com/garyburd/redigo.git \ -e CI_WORKSPACE=/go/src/github.com/garyburd/redigo \ -e CI_BUILD_EVENT=tag \ -e CI_COMMIT_SHA=3b4642018d177bf5fecc5907e7f341a2b5c12b8a \ diff --git a/main.go b/main.go index 6f20ea9..0186aed 100644 --- a/main.go +++ b/main.go @@ -23,7 +23,7 @@ func main() { &cli.StringFlag{ Name: "remote", Usage: "git remote url", - EnvVars: []string{"PLUGIN_REMOTE", "CI_REMOTE_URL"}, + EnvVars: []string{"PLUGIN_REMOTE", "CI_REPO_REMOTE", "CI_REMOTE_URL"}, }, &cli.StringFlag{ Name: "path", From 01a6c052cf2556501e9d71f0be622175099bb622 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sun, 19 Dec 2021 03:55:44 +0100 Subject: [PATCH 5/7] nits --- .editorconfig | 19 +++++++++++++++++++ .gitignore | 2 ++ 2 files changed, 21 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..34f6015 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +tab_width = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.go] +indent_style = tab + +[*.md] +trim_trailing_whitespace = false + +[Makefile] +indent_style = tab diff --git a/.gitignore b/.gitignore index f254909..1f65b39 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,5 @@ vendor/ coverage.out plugin-git + +.vscode From 1f56522b6289e6a505c41373da5df9c9bd50cb6f Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sun, 19 Dec 2021 03:57:38 +0100 Subject: [PATCH 6/7] cleanup & format --- .dockerignore | 1 - docker/Dockerfile.multiarch | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 985c9a9..0000000 --- a/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -!release/ diff --git a/docker/Dockerfile.multiarch b/docker/Dockerfile.multiarch index f539936..1dd018f 100644 --- a/docker/Dockerfile.multiarch +++ b/docker/Dockerfile.multiarch @@ -12,4 +12,4 @@ RUN apk add --no-cache ca-certificates git openssh curl ENV GODEBUG=netdns=go COPY --from=build src/release/plugin-git /bin/ -ENTRYPOINT ["/bin/plugin-git"] \ No newline at end of file +ENTRYPOINT ["/bin/plugin-git"] From 2eaeb0d4cd449ea42d11cae5d4b3e08180106fcc Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Mon, 20 Dec 2021 02:27:03 +0100 Subject: [PATCH 7/7] Update Makefile --- Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Makefile b/Makefile index b87b908..db152eb 100644 --- a/Makefile +++ b/Makefile @@ -4,9 +4,6 @@ GO_PACKAGES ?= $(shell go list ./... | grep -v /vendor/) TARGETOS ?= linux TARGETARCH ?= amd64 -# rm once https://github.com/woodpecker-ci/woodpecker/pull/624 got merged -CI_COMMIT_TAG ?= $(CI_TAG) - VERSION ?= next ifneq ($(CI_COMMIT_TAG),) VERSION := $(CI_COMMIT_TAG:v%=%)