mirror of
https://github.com/terraform-docs/terraform-docs.git
synced 2026-03-27 12:58:35 +07:00
Use goreleaser for release workflow and tasks
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
This commit is contained in:
146
.github/workflows/build.yaml
vendored
146
.github/workflows/build.yaml
vendored
@@ -6,115 +6,93 @@ on:
|
||||
- master
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
GO_VERSION: "1.15"
|
||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.15.6
|
||||
id: go
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
|
||||
- name: Build binary
|
||||
run: make build
|
||||
- name: Build binary
|
||||
run: make build
|
||||
|
||||
darwin:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.15.6
|
||||
id: go
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
|
||||
- name: Build binary
|
||||
env:
|
||||
GOOS: darwin
|
||||
GOARCH: amd64
|
||||
run: make build
|
||||
- name: Run tests
|
||||
run: make test
|
||||
|
||||
freebsd:
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v1
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
file: ./coverage.out
|
||||
|
||||
validate:
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.15.6
|
||||
id: go
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
|
||||
- name: Build binary
|
||||
env:
|
||||
GOOS: freebsd
|
||||
GOARCH: amd64
|
||||
run: make build
|
||||
- name: Verify dependencies
|
||||
run: make verify
|
||||
|
||||
openbsd:
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.15.6
|
||||
id: go
|
||||
- name: Check formatting
|
||||
run: make goimports checkfmt
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
- name: Run linters
|
||||
run: make golangci lint
|
||||
|
||||
- name: Build binary
|
||||
env:
|
||||
GOOS: openbsd
|
||||
GOARCH: amd64
|
||||
run: make build
|
||||
|
||||
windows:
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.15.6
|
||||
id: go
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Build binary
|
||||
env:
|
||||
GOOS: windows
|
||||
GOARCH: amd64
|
||||
run: make build
|
||||
- name: Run Staticcheck
|
||||
run: make staticcheck
|
||||
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
||||
steps:
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Build 'dev' Docker image
|
||||
if: "!contains(github.ref, 'refs/heads/master')"
|
||||
run: DOCKER_TAG=${{ github.sha }} make docker
|
||||
- name: Login to Docker
|
||||
uses: docker/login-action@v1
|
||||
if: env.REGISTRY_USERNAME != ''
|
||||
with:
|
||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Build and push 'edge' Docker image
|
||||
if: "contains(github.ref, 'refs/heads/master')"
|
||||
run: |
|
||||
echo ${REGISTRY_PASSWORD} | docker login -u ${REGISTRY_USERNAME} --password-stdin quay.io
|
||||
DOCKER_TAG=edge make docker push
|
||||
env:
|
||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
- name: Build 'dev' Docker image
|
||||
if: "env.REGISTRY_USERNAME != '' && !contains(github.ref, 'refs/heads/master')"
|
||||
run: make docker
|
||||
env:
|
||||
DOCKER_TAG: ${{ github.sha }}
|
||||
|
||||
- name: Build and push 'edge' Docker image
|
||||
if: env.REGISTRY_USERNAME != '' && contains(github.ref, 'refs/heads/master')
|
||||
run: make docker push
|
||||
env:
|
||||
DOCKER_TAG: edge
|
||||
|
||||
81
.github/workflows/prerelease.yaml
vendored
81
.github/workflows/prerelease.yaml
vendored
@@ -3,52 +3,67 @@ name: prerelease
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*.*.*-*'
|
||||
- "v*.*.*-*"
|
||||
|
||||
env:
|
||||
GO_VERSION: "1.15"
|
||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||
|
||||
jobs:
|
||||
prerelease:
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.15.6
|
||||
id: go
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
|
||||
- name: Build binaries for all OS/ARCH platforms
|
||||
run: |
|
||||
export PATH=$PATH:$(go env GOPATH)/bin
|
||||
make gox build-all
|
||||
- name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v2
|
||||
if: env.REGISTRY_USERNAME != ''
|
||||
with:
|
||||
version: latest
|
||||
args: release --rm-dist --skip-publish --skip-sign
|
||||
|
||||
- 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 }}
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
files: dist/terraform-docs-v*
|
||||
draft: false
|
||||
prerelease: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
||||
steps:
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set version output
|
||||
id: vars
|
||||
run: echo ::set-output name=tag::${GITHUB_REF:11} # tag name without leading 'v'
|
||||
- name: Set version output
|
||||
id: vars
|
||||
run: echo ::set-output name=tag::${GITHUB_REF:11} # tag name without leading 'v'
|
||||
|
||||
- name: Build and push Docker image
|
||||
run: |
|
||||
echo ${REGISTRY_PASSWORD} | docker login -u ${REGISTRY_USERNAME} --password-stdin quay.io
|
||||
DOCKER_TAG=${{ steps.vars.outputs.tag }} make docker push
|
||||
env:
|
||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
- name: Login to Docker
|
||||
uses: docker/login-action@v1
|
||||
if: env.REGISTRY_USERNAME != ''
|
||||
with:
|
||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
run: make docker push
|
||||
env:
|
||||
DOCKER_TAG: ${{ steps.vars.outputs.tag }}
|
||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
91
.github/workflows/release.yaml
vendored
91
.github/workflows/release.yaml
vendored
@@ -3,63 +3,62 @@ name: release
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
- '!v*.*.*-*'
|
||||
- "v*.*.*"
|
||||
- "!v*.*.*-*"
|
||||
|
||||
env:
|
||||
GO_VERSION: "1.15"
|
||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||
|
||||
jobs:
|
||||
release:
|
||||
assets:
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.15.6
|
||||
id: go
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
|
||||
- name: Build binaries for all OS/ARCH platforms
|
||||
run: |
|
||||
export PATH=$PATH:$(go env GOPATH)/bin
|
||||
make gox build-all
|
||||
- name: Login to Docker
|
||||
uses: docker/login-action@v1
|
||||
if: env.REGISTRY_USERNAME != ''
|
||||
with:
|
||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Generate Changelog
|
||||
run: |
|
||||
export PATH=$PATH:$(go env GOPATH)/bin
|
||||
./scripts/release/release-note.sh
|
||||
- name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v2
|
||||
if: env.REGISTRY_USERNAME != ''
|
||||
with:
|
||||
version: latest
|
||||
args: release --rm-dist --skip-sign
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.COMMITTER_TOKEN }}
|
||||
|
||||
- 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 }}
|
||||
- name: Set version output
|
||||
id: vars
|
||||
run: echo ::set-output name=tag::${GITHUB_REF:11} # tag name without leading 'v'
|
||||
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
||||
steps:
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
- name: Update Chocolatey package
|
||||
run: ./scripts/release/update-choco.sh "${{ env.GITHUB_REF }}"
|
||||
|
||||
- name: Set version output
|
||||
id: vars
|
||||
run: echo ::set-output name=tag::${GITHUB_REF:11} # tag name without leading 'v'
|
||||
|
||||
- name: Build and push Docker image
|
||||
run: |
|
||||
echo ${REGISTRY_PASSWORD} | docker login -u ${REGISTRY_USERNAME} --password-stdin quay.io
|
||||
DOCKER_TAG=${{ steps.vars.outputs.tag }} make docker push
|
||||
DOCKER_TAG=latest make docker push
|
||||
env:
|
||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
- name: Update Chocolatey package
|
||||
uses: drud/action-cross-commit@master
|
||||
with:
|
||||
source-folder: scripts/release/chocolatey-package
|
||||
destination-repository: https://${{ secrets.COMMITTER_USERNAME }}:${{ secrets.COMMITTER_TOKEN }}@github.com/terraform-docs/chocolatey-package
|
||||
destination-folder: .
|
||||
destination-branch: main
|
||||
git-user: ${{ secrets.COMMITTER_USERNAME }}
|
||||
git-user-email: ${{ secrets.COMMITTER_EMAIL }}
|
||||
git-commit-message: Chocolatey update for terraform-docs version v${{ env.GITHUB_REF }}
|
||||
excludes: README.md:LICENSE:.git:.github
|
||||
|
||||
homebrew:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
98
.github/workflows/validate.yaml
vendored
98
.github/workflows/validate.yaml
vendored
@@ -1,98 +0,0 @@
|
||||
name: validate
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
verify:
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.15.6
|
||||
id: go
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Verify 'vendor' dependencies
|
||||
run: make verify
|
||||
|
||||
checkfmt:
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.15.6
|
||||
id: go
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Check formatting of go files
|
||||
run: |
|
||||
export PATH=$PATH:$(go env GOPATH)/bin
|
||||
make goimports checkfmt
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.15.6
|
||||
id: go
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Run linters
|
||||
run: |
|
||||
export PATH=$PATH:$(go env GOPATH)/bin
|
||||
make golangci lint
|
||||
|
||||
staticcheck:
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.15.6
|
||||
id: go
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Run staticcheck
|
||||
run: make staticcheck
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.15.6
|
||||
id: go
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Run tests
|
||||
run: make test
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v1
|
||||
if: always()
|
||||
with:
|
||||
file: ./coverage.out
|
||||
Reference in New Issue
Block a user