From be216df37e74466becd95f9cb370a6371fc23aa1 Mon Sep 17 00:00:00 2001 From: Andrzej Rehmann Date: Wed, 1 Jul 2020 10:55:51 +0100 Subject: [PATCH] Switch to Go Modules and GH actions --- .circleci/config.yml | 39 ------------------------------- .github/workflows/release.yml | 28 ++++++++++++++++++++++ .github/workflows/test.yml | 30 ++++++++++++++++++++++++ .goreleaser.yml | 43 ++++++++++++++++++++++------------ Gopkg.lock | 44 ----------------------------------- Gopkg.toml | 30 ------------------------ Makefile | 22 +++++++++++------- README.md | 2 +- go.mod | 8 +++++++ go.sum | 13 +++++++++++ 10 files changed, 121 insertions(+), 138 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml delete mode 100644 Gopkg.lock delete mode 100644 Gopkg.toml create mode 100644 go.mod create mode 100644 go.sum diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 12f09ca..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,39 +0,0 @@ ---- -version: 2 - -jobs: - test: - docker: - - image: circleci/golang:1.11.3 - working_directory: /go/src/github.com/hoto/jenkins-credentials-decryptor - steps: - - checkout - - run: make dependencies - - run: make test - github-release: - docker: - - image: circleci/golang:1.11.3 - working_directory: /go/src/github.com/hoto/jenkins-credentials-decryptor - steps: - - checkout - - run: make github-release - -workflows: - version: 2 - untagged-workflow: - jobs: - - test - tagged-workflow: - jobs: - - test: - filters: - branches: - ignore: /.*/ - tags: - only: /[0-9]+(\.[0-9]+)*(-.*)*/ - - github-release: - filters: - branches: - ignore: /.*/ - tags: - only: /[0-9]+(\.[0-9]+)*(-.*)*/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..4be04a5 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,28 @@ +name: Release - github, brew + +on: + push: + tags: + - '*' + +jobs: + release: + name: GitHub release + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.14 + id: go + + - name: Unshallow git repo + run: git fetch --prune --unshallow + + - name: Run goreleaser + env: + GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }} + run: make goreleaser-release diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..14a0922 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,30 @@ +name: Test + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + release: + name: Build and test + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.14 + id: go + + - name: Build + run: make build + + - name: Test + run: make test + + - name: Dry run goreleaser + run: make goreleaser-dry-run diff --git a/.goreleaser.yml b/.goreleaser.yml index 719adc8..9b13d0f 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,15 +1,25 @@ --- builds: - - env: + - main: ./cmd/jenkins-credentials-decryptor/main.go + env: - CGO_ENABLED=0 - main: ./cmd/jenkins-credentials-decryptor/main.go -archive: - format: binary - replacements: - darwin: Darwin - linux: Linux - 386: i386 - amd64: x86_64 + ignore: + - goos: darwin + goarch: 386 +archives: + - format: binary + replacements: + darwin: Darwin + linux: Linux + 386: i386 + amd64: x86_64 + - id: homebrew + name_template: "{{ .Binary }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" + replacements: + darwin: Darwin + linux: Linux + amd64: x86_64 + format: zip checksum: name_template: 'checksums.txt' snapshot: @@ -18,9 +28,12 @@ release: prerelease: auto changelog: sort: asc - filters: - exclude: - - '^Docs:' - - '^Test:' - - '^Update readme' - - '^Update readme.*' +brews: + - github: + owner: hoto + name: homebrew-repo + folder: Formula + homepage: https://github.com/hoto/jenkins-credentials-decryptor + description: Navigitae locally cloned repos. + test: | + system "#{bin}/jenkins-credentials-decryptor --version" diff --git a/Gopkg.lock b/Gopkg.lock deleted file mode 100644 index dbcfb4e..0000000 --- a/Gopkg.lock +++ /dev/null @@ -1,44 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - digest = "1:bd8bc15ce3a9929e2777651cbc271fca5561c0d5f42187edb4720e638d24662d" - name = "github.com/beevik/etree" - packages = ["."] - pruneopts = "UT" - revision = "8aee6516be3b1163bb6450c35c50e4969e3a3aa8" - version = "v1.1.0" - -[[projects]] - digest = "1:ffe9824d294da03b391f44e1ae8281281b4afc1bdaa9588c9097785e3af10cec" - name = "github.com/davecgh/go-spew" - packages = ["spew"] - pruneopts = "UT" - revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73" - version = "v1.1.1" - -[[projects]] - digest = "1:0028cb19b2e4c3112225cd871870f2d9cf49b9b4276531f03438a88e94be86fe" - name = "github.com/pmezard/go-difflib" - packages = ["difflib"] - pruneopts = "UT" - revision = "792786c7400a136282c1664665ae0a8db921c6c2" - version = "v1.0.0" - -[[projects]] - digest = "1:972c2427413d41a1e06ca4897e8528e5a1622894050e2f527b38ddf0f343f759" - name = "github.com/stretchr/testify" - packages = ["assert"] - pruneopts = "UT" - revision = "ffdc059bfe9ce6a4e144ba849dbedead332c6053" - version = "v1.3.0" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - input-imports = [ - "github.com/beevik/etree", - "github.com/stretchr/testify/assert", - ] - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml deleted file mode 100644 index d7072c2..0000000 --- a/Gopkg.toml +++ /dev/null @@ -1,30 +0,0 @@ -# Gopkg.toml example -# -# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html -# for detailed Gopkg.toml documentation. -# -# required = ["github.com/user/thing/cmd/thing"] -# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] -# -# [[constraint]] -# name = "github.com/user/project" -# version = "1.0.0" -# -# [[constraint]] -# name = "github.com/user/project2" -# branch = "dev" -# source = "github.com/myfork/project2" -# -# [[override]] -# name = "github.com/x/y" -# version = "2.4.0" -# -# [prune] -# non-go = false -# go-tests = true -# unused-packages = true - - -[prune] - go-tests = true - unused-packages = true diff --git a/Makefile b/Makefile index be45e80..55aac32 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,13 @@ -.PHONY: clean dependencies build test all - -all: clean build test +.PHONY: clean dependencies build test run install github-release github-release-dry-run goreleaser-dry-run clean: go clean rm -rf bin/ dist/ dependencies: - go get -v -t -d ./... - go get -u github.com/golang/dep/cmd/dep - dep ensure + go mod download + go mod tidy + go mod verify build: dependencies go build -o bin/jenkins-credentials-decryptor cmd/jenkins-credentials-decryptor/main.go @@ -17,11 +15,17 @@ build: dependencies test: go test -v ./... +run: clean build + ./bin/jenkins-credentials-decryptor $(arg) + install: clean build go install -v ./... -github-release: dependencies - curl -sL https://git.io/goreleaser | bash +goreleaser-release: clean dependencies + curl -sL https://git.io/goreleaser | VERSION=v0.137.0 bash + +goreleaser-dry-run: clean dependencies + curl -sL https://git.io/goreleaser | VERSION=v0.137.0 bash -s -- --skip-publish --snapshot --rm-dist -github-release-dry-run: dependencies +goreleaser-dry-run-local: dependencies goreleaser release --skip-publish --snapshot --rm-dist diff --git a/README.md b/README.md index fa19130..955d328 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ I've tested this on Jenkins 1.625.1 and 2.141 Download binary from [releases](https://github.com/hoto/jenkins-credentials-decryptor/releases), Linux and Mac only: curl -L \ - "https://github.com/hoto/jenkins-credentials-decryptor/releases/download/0.0.7/jenkins-credentials-decryptor_0.0.7_$(uname -s)_$(uname -m)" \ + "https://github.com/hoto/jenkins-credentials-decryptor/releases/download/0.0.8/jenkins-credentials-decryptor_0.0.8_$(uname -s)_$(uname -m)" \ -o jenkins-credentials-decryptor chmod +x jenkins-credentials-decryptor diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..3c9ca80 --- /dev/null +++ b/go.mod @@ -0,0 +1,8 @@ +module github.com/hoto/jenkins-credentials-decryptor + +go 1.14 + +require ( + github.com/beevik/etree v1.1.0 + github.com/stretchr/testify v1.6.1 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..e561a77 --- /dev/null +++ b/go.sum @@ -0,0 +1,13 @@ +github.com/beevik/etree v1.1.0 h1:T0xke/WvNtMoCqgzPhkX2r4rjY3GDZFi+FjpRZY2Jbs= +github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=