Skip to content

Commit

Permalink
Add Goreleaser to CI (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo-ruth committed Aug 11, 2020
1 parent bad9be1 commit 970e826
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 27 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v1
- name: Checkout
uses: actions/checkout@v2
with:
go-version: 1.14
id: go
fetch-depth: 0

- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14

- name: Build
run: go build -o terraform-provider-fortiadc_${GITHUB_REF}
run: go build

- name: Setup Lint
run: curl -LO https://github.com/golangci/golangci-lint/releases/download/v1.30.0/golangci-lint-1.30.0-linux-amd64.tar.gz && tar -xf golangci-lint-1.30.0-linux-amd64.tar.gz
Expand Down
44 changes: 24 additions & 20 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,37 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v1
- name: Checkout
uses: actions/checkout@v2
with:
go-version: 1.14
id: go

- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
fetch-depth: 0

- name: Check out code into the Go module directory
uses: actions/checkout@v1

- name: Build
run: go build -o terraform-provider-fortiadc_${{ steps.get_version.outputs.VERSION }}
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14

- name: Setup Lint
run: curl -LO https://github.com/golangci/golangci-lint/releases/download/v1.30.0/golangci-lint-1.30.0-linux-amd64.tar.gz && tar -xf golangci-lint-1.30.0-linux-amd64.tar.gz

- name: Lint
run: golangci-lint-1.30.0-linux-amd64/golangci-lint run

- name: Upload binaries to release
uses: svenstaro/upload-release-action@v1-release
- name: Clean Lint
run: rm -rf golangci-lint-*

- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v2
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.PASSPHRASE }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: terraform-provider-fortiadc_${{ steps.get_version.outputs.VERSION }}
asset_name: terraform-provider-fortiadc_${{ steps.get_version.outputs.VERSION }}
tag: ${{ github.ref }}
overwrite: true
version: v0.141.0
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
47 changes: 47 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Visit https://goreleaser.com for documentation on how to customize this
# behavior.
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
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:
- format: zip
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
checksum:
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}"
changelog:
skip: true
8 changes: 8 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ The FortiADC provider is used to interact with the resources supported by [Forti

```hcl
# Provider configuration
terraform {
required_providers {
fortiadc = {
source = "Ouest-France/fortiadc"
}
}
}
provider "fortiadc" {
address = "https://fortiadc.mydomain.com"
user = "myuser"
Expand Down

0 comments on commit 970e826

Please sign in to comment.