From 088d71ba1c8df0c10e9d3683307710df3ccf7cc7 Mon Sep 17 00:00:00 2001 From: Khosrow Moossavi Date: Thu, 12 Dec 2019 16:22:53 -0500 Subject: [PATCH] Use Github Actions instead of Circle CI (#124) * Use Github Actions instead of CircleCI * Add prerelease and release workflows * Fix merge conflict * Add release-note script * Remove extra flags from build-all target on release workflows * Upgrade golang-ci to v1.18.0 --- .circleci/config.yml | 93 ------------------------------- .github/workflows/build.yaml | 66 ++++++++++++++++++++++ .github/workflows/prerelease.yaml | 35 ++++++++++++ .github/workflows/release.yaml | 42 ++++++++++++++ Makefile | 2 +- 5 files changed, 144 insertions(+), 94 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/prerelease.yaml create mode 100644 .github/workflows/release.yaml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 158c8e5..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,93 +0,0 @@ -defaults: &defaults - docker: - - image: golang:1.11 - working_directory: /go/src/github.com/segmentio/terraform-docs - -version: 2 -jobs: - checkout_code: - <<: *defaults - steps: - - checkout - - save_cache: - key: repo-{{ .Environment.CIRCLE_SHA1 }} - paths: - - /go/src/github.com/segmentio/terraform-docs - - check-dependencies: - <<: *defaults - steps: - - restore_cache: - key: repo-{{ .Environment.CIRCLE_SHA1 }} - - run: make verify - - checkfmt: - <<: *defaults - steps: - - restore_cache: - key: repo-{{ .Environment.CIRCLE_SHA1 }} - - run: make goimports checkfmt - - lint: - <<: *defaults - steps: - - restore_cache: - key: repo-{{ .Environment.CIRCLE_SHA1 }} - - run: make tools lint - - test: - <<: *defaults - steps: - - restore_cache: - key: repo-{{ .Environment.CIRCLE_SHA1 }} - - run: make test - - build: - <<: *defaults - steps: - - restore_cache: - key: repo-{{ .Environment.CIRCLE_SHA1 }} - - run: make build - - save_cache: - key: terraform-docs-{{ .Revision }} - paths: - - /go/src/github.com/segmentio/terraform-docs - -workflows: - version: 2 - build: - jobs: - - checkout_code: - filters: - tags: - only: /v.*/ - - check-dependencies: - requires: - - checkout_code - filters: - tags: - only: /v.*/ - - checkfmt: - requires: - - checkout_code - filters: - tags: - only: /v.*/ - - lint: - requires: - - checkout_code - filters: - tags: - only: /v.*/ - - test: - requires: - - checkout_code - filters: - tags: - only: /v.*/ - - build: - requires: - - checkout_code - filters: - tags: - only: /v.*/ diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..14aa084 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,66 @@ +name: build + +on: + push: + branches: + - master + pull_request: + +jobs: + validate: + name: Validate + runs-on: ubuntu-latest + steps: + - name: Set up Go 1.12 + uses: actions/setup-go@v1 + with: + go-version: 1.12 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + + - name: Verify 'vendor' dependencies + run: make verify + + - name: Check formatting of go files + run: | + export PATH=$PATH:$(go env GOPATH)/bin + make goimports checkfmt + + - name: Run linters + run: | + export PATH=$PATH:$(go env GOPATH)/bin + make golangci lint + + test: + name: Test + runs-on: ubuntu-latest + steps: + - name: Set up Go 1.12 + uses: actions/setup-go@v1 + with: + go-version: 1.12 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + + - name: Run tests + run: make test + + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Set up Go 1.12 + uses: actions/setup-go@v1 + with: + go-version: 1.12 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + + - name: Build binary for current OS/ARCH + run: make build diff --git a/.github/workflows/prerelease.yaml b/.github/workflows/prerelease.yaml new file mode 100644 index 0000000..cbea084 --- /dev/null +++ b/.github/workflows/prerelease.yaml @@ -0,0 +1,35 @@ +name: prerelease + +on: + push: + tags: + - 'v*.*.*-*' + +jobs: + prerelease: + name: Pre-Release + runs-on: ubuntu-latest + steps: + - name: Set up Go 1.12 + uses: actions/setup-go@v1 + with: + go-version: 1.12 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + + - name: Build binaries for all OS/ARCH platforms + run: | + export PATH=$PATH:$(go env GOPATH)/bin + make gox build-all + + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: bin/terraform-docs-v* + draft: false + prerelease: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..ed6fbaa --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,42 @@ +name: release + +on: + push: + tags: + - 'v*.*.*' + - '!v*.*.*-*' + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Set up Go 1.12 + uses: actions/setup-go@v1 + with: + go-version: 1.12 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + + - name: Build binaries for all OS/ARCH platforms + run: | + export PATH=$PATH:$(go env GOPATH)/bin + make gox build-all + + - name: Generate Changelog + run: | + export PATH=$PATH:$(go env GOPATH)/bin + ./scripts/release/release-note.sh + + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + body_path: CURRENT-RELEASE-CHANGELOG.md + files: bin/terraform-docs-v* + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Makefile b/Makefile index 2ae73d2..6d66670 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ GORUN ?= GOOS=$(GOOS) GOARCH=$(GOARCH) $(GOCMD) run $(MODVENDOR) # Binary versions GITCHGLOG_VERSION := 0.8.0 -GOLANGCI_VERSION := v1.17.1 +GOLANGCI_VERSION := v1.18.0 .PHONY: all all: clean deps lint test build