From 3c50f42536dc59fc8078629a905e8adfa41853e6 Mon Sep 17 00:00:00 2001 From: Bishwa Shrestha Date: Mon, 14 Sep 2020 16:12:18 +0200 Subject: [PATCH 1/4] Goreleaser + GH workflows --- .circleci/config.yml | 28 -------------------------- .github/workflows/main.yml | 26 ++++++++++++++++++++++++ .goreleaser.yml | 41 ++++++++++++++++++++++++++++++++++++++ README.md | 26 ++++++++++++------------ go.sum | 1 + 5 files changed, 81 insertions(+), 41 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/main.yml create mode 100644 .goreleaser.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 3a5744e..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,28 +0,0 @@ -# Golang CircleCI 2.0 configuration file -# -# Check https://circleci.com/docs/2.0/language-go/ for more details -version: 2 -jobs: - build: - docker: - # specify the version - - image: circleci/golang:1.11 - environment: - GO111MODULE: "on" - - # Specify service dependencies here if necessary - # CircleCI maintains a library of pre-built images - # documented at https://circleci.com/docs/2.0/circleci-images/ - # - image: circleci/postgres:9.4 - - #### TEMPLATE_NOTE: go expects specific checkout path representing url - #### expecting it in the form of - #### /go/src/github.com/circleci/go-tool - #### /go/src/bitbucket.org/circleci/go-tool - working_directory: /go/src/github.com/armory-io/terraform-provider-spinnaker - steps: - - checkout - - # specify any bash command here prefixed with `run: ` - - run: go get -v -t -d ./... - - run: go test -v ./... diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..9721557 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,26 @@ +name: goreleaser + +on: + push: + tags: + - "*" + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.14 + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..5e311cd --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,41 @@ +# This is an example goreleaser.yaml file with some sane defaults. +# Make sure to check the documentation at http://goreleaser.com +before: + hooks: + # You may remove this if you don't use go modules. + - go mod download + # you may remove this if you don't need go generate + - go generate ./... +builds: + - env: + - CGO_ENABLED=0 +release: + prerelease: auto +archives: + - name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" + + replacements: + darwin: Darwin + linux: Linux + windows: Windows + 386: i386 + amd64: x86_64 + + # Archive format. Valid options are `tar.gz`, `gz`, `zip` and `binary`. + format: binary + + # Additional files/globs to add to the archive. + files: + - LICENSE* + - README* + - CHANGELOG* +checksum: + name_template: "checksums.txt" +snapshot: + name_template: "{{ .Tag }}-next" +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" diff --git a/README.md b/README.md index ad881c1..44ef368 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -[![CircleCI](https://circleci.com/gh/armory-io/terraform-provider-spinnaker/tree/master.svg?style=svg)](https://circleci.com/gh/armory-io/terraform-provider-spinnaker/tree/master) - # terraform-provider-spinnaker Manage [Spinnaker](https://spinnaker.io) applications and pipelines with Terraform. @@ -58,10 +56,10 @@ provider "spinnaker" { #### Argument Reference -* `server` - The Gate API Url -* `config` - (Optional) - Path to Gate config file. See the [Spin CLI](https://github.com/spinnaker/spin/blob/master/config/example.yaml) for an example config. -* `ignore_cert_errors` - (Optional) - Set this to `true` to ignore certificate errors from Gate. Defaults to `false`. -* `default_headers` - (Optional) - Pass through a comma separated set of key value pairs to set default headers for the gate client when sending requests to your gate endpoint e.g. "header1=value1,header2=value2". Defaults to "". +- `server` - The Gate API Url +- `config` - (Optional) - Path to Gate config file. See the [Spin CLI](https://github.com/spinnaker/spin/blob/master/config/example.yaml) for an example config. +- `ignore_cert_errors` - (Optional) - Set this to `true` to ignore certificate errors from Gate. Defaults to `false`. +- `default_headers` - (Optional) - Pass through a comma separated set of key value pairs to set default headers for the gate client when sending requests to your gate endpoint e.g. "header1=value1,header2=value2". Defaults to "". ## Resources @@ -75,9 +73,11 @@ resource "spinnaker_application" "my_app" { email = "ethan@armory.io" } ``` + #### Argument Reference -* `application` - Application name -* `email` - Owner email + +- `application` - Application name +- `email` - Owner email ### `spinnaker_pipeline` @@ -93,9 +93,9 @@ resource "spinnaker_pipeline" "terraform_example" { #### Argument Reference -* `application` - Application name -* `name` - Pipeline name -* `pipeline` - Pipeline JSON in string format, example `file(pipelines/example.json)` +- `application` - Application name +- `name` - Pipeline name +- `pipeline` - Pipeline JSON in string format, example `file(pipelines/example.json)` ### `spinnaker_pipeline_template` @@ -113,7 +113,7 @@ resource "spinnaker_pipeline_template" "terraform_example" { #### Argument Reference -* `template` - A yaml formated [DCD Spec pipeline template](https://github.com/spinnaker/dcd-spec/blob/master/PIPELINE_TEMPLATES.md#templates) +- `template` - A yaml formated [DCD Spec pipeline template](https://github.com/spinnaker/dcd-spec/blob/master/PIPELINE_TEMPLATES.md#templates) ### `spinnaker_pipeline_template_config` @@ -131,4 +131,4 @@ resource "spinnaker_pipeline_template_config" "terraform_example" { #### Argument Reference -* `pipeline_config` - A yaml formated [DCD Spec pipeline configuration](https://github.com/spinnaker/dcd-spec/blob/master/PIPELINE_TEMPLATES.md#configurations) +- `pipeline_config` - A yaml formated [DCD Spec pipeline configuration](https://github.com/spinnaker/dcd-spec/blob/master/PIPELINE_TEMPLATES.md#configurations) diff --git a/go.sum b/go.sum index c3b4160..1d7fa71 100644 --- a/go.sum +++ b/go.sum @@ -110,6 +110,7 @@ github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/googleapis/gax-go v2.0.0+incompatible h1:j0GKcs05QVmm7yesiZq2+9cxHkNK9YM6zKx4D2qucQU= github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= github.com/googleapis/gax-go/v2 v2.0.4 h1:hU4mGcQI4DaAYW+IbTun+2qEZVFxK0ySjQLTbS0VQKc= From bbe2fbba8f84c6e44b855ee4d40508d1af831569 Mon Sep 17 00:00:00 2001 From: Bishwa Shrestha Date: Mon, 14 Sep 2020 16:34:10 +0200 Subject: [PATCH 2/4] PR builds --- .github/workflows/main.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9721557..cb8342c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,6 +4,11 @@ on: push: tags: - "*" + branches: + - master + pull_request: + branches: + - master jobs: goreleaser: From de1f6e99e26bd9e640391ad69d3513f5613150ff Mon Sep 17 00:00:00 2001 From: Bishwa Shrestha Date: Mon, 14 Sep 2020 21:28:42 +0200 Subject: [PATCH 3/4] terraform registry scaffolding --- .github/workflows/main.yml | 13 +++++-- .goreleaser.yml | 79 ++++++++++++++++++++++---------------- 2 files changed, 56 insertions(+), 36 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cb8342c..d43d22b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,7 +3,7 @@ name: goreleaser on: push: tags: - - "*" + - "v*" branches: - master pull_request: @@ -16,16 +16,23 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - with: - fetch-depth: 0 + - name: Unshallow + run: git fetch --prune --unshallow - name: Set up Go uses: actions/setup-go@v2 with: go-version: 1.14 + - name: Import GPG key + id: import_gpg + uses: paultyng/ghaction-import-gpg@v2.1.0 + env: + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + PASSPHRASE: ${{ secrets.PASSPHRASE }} - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 with: version: latest args: release --rm-dist env: + GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml index 5e311cd..92f80f6 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,41 +1,54 @@ -# This is an example goreleaser.yaml file with some sane defaults. -# Make sure to check the documentation at http://goreleaser.com +# Visit https://goreleaser.com for documentation on how to customize this +# behavior. before: hooks: - # You may remove this if you don't use go modules. - - go mod download - # you may remove this if you don't need go generate - - go generate ./... + # this is just an example and not a requirement for provider building/publishing + - go mod tidy builds: - env: + # goreleaser does not work with CGO, it could also complicate + # usage by users in CI/CD systems like Terraform Cloud where + # they are unable to install libraries. - CGO_ENABLED=0 -release: - prerelease: auto + mod_timestamp: "{{ .CommitTimestamp }}" + flags: + - -trimpath + ldflags: + - "-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}" + goos: + - freebsd + - windows + - linux + - darwin + goarch: + - amd64 + - "386" + - arm + - arm64 + ignore: + - goos: darwin + goarch: "386" + binary: "{{ .ProjectName }}_v{{ .Version }}" archives: - - name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" - - replacements: - darwin: Darwin - linux: Linux - windows: Windows - 386: i386 - amd64: x86_64 - - # Archive format. Valid options are `tar.gz`, `gz`, `zip` and `binary`. - format: binary - - # Additional files/globs to add to the archive. - files: - - LICENSE* - - README* - - CHANGELOG* + - format: zip + name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" checksum: - name_template: "checksums.txt" -snapshot: - name_template: "{{ .Tag }}-next" + name_template: "{{ .ProjectName }}_{{ .Version }}_SHA256SUMS" + algorithm: sha256 +signs: + - artifacts: checksum + args: + # if you are using this is a GitHub action or some other automated pipeline, you + # need to pass the batch flag to indicate its not interactive. + - "--batch" + - "--local-user" + - "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key + - "--output" + - "${signature}" + - "--detach-sign" + - "${artifact}" +release: + # If you want to manually examine the release before its live, uncomment this line: + # draft: true changelog: - sort: asc - filters: - exclude: - - "^docs:" - - "^test:" + skip: true From 4f707e3610107bbd0bb8c95e8301fc6bec1dc440 Mon Sep 17 00:00:00 2001 From: Bishwa Shrestha Date: Mon, 14 Sep 2020 21:53:17 +0200 Subject: [PATCH 4/4] Separate workflows for branches and tags --- .github/workflows/main.yml | 2 -- .github/workflows/release.yml | 33 +++++++++++++++++++++++++++++++++ .gitignore | 4 +++- .goreleaser.yml | 5 ----- 4 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d43d22b..22888d7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,8 +2,6 @@ name: goreleaser on: push: - tags: - - "v*" branches: - master pull_request: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b992402 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,33 @@ +name: goreleaser + +on: + push: + tags: + - "*" + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Unshallow + run: git fetch --prune --unshallow + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.14 + - name: Import GPG key + id: import_gpg + uses: paultyng/ghaction-import-gpg@v2.1.0 + env: + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + PASSPHRASE: ${{ secrets.PASSPHRASE }} + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist --skip-publish --snapshot + env: + GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index ac3bf30..f2bd371 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ terraform-provider-spinnaker *.tf *.log pipelines -vendor/* \ No newline at end of file +vendor/* +/dist/ +*.key diff --git a/.goreleaser.yml b/.goreleaser.yml index 92f80f6..1f38dfc 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -16,15 +16,10 @@ builds: ldflags: - "-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}" goos: - - freebsd - - windows - linux - darwin goarch: - amd64 - - "386" - - arm - - arm64 ignore: - goos: darwin goarch: "386"