Skip to content

Commit

Permalink
Merge pull request #4 from Ouest-France/CI
Browse files Browse the repository at this point in the history
Add goreleaser, upgrade go to 1.14 and golangci-lint to 1.30.0
  • Loading branch information
pablo-ruth authored Aug 12, 2020
2 parents 0ac0dc5 + 49f1af4 commit f165533
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 30 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.13
uses: actions/setup-go@v1
- name: Checkout
uses: actions/checkout@v2
with:
go-version: 1.13
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: CGO_ENABLED=0 go build -ldflags="-w -s" -o terraform-provider-ldap_${GITHUB_REF}
run: go build

- name: Setup Lint
run: curl -LO https://github.com/golangci/golangci-lint/releases/download/v1.19.1/golangci-lint-1.19.1-linux-amd64.tar.gz && tar -xf golangci-lint-1.19.1-linux-amd64.tar.gz
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.19.1-linux-amd64/golangci-lint run
run: golangci-lint-1.30.0-linux-amd64/golangci-lint run
48 changes: 26 additions & 22 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.13
uses: actions/setup-go@v1
- name: Checkout
uses: actions/checkout@v2
with:
go-version: 1.13
id: go
fetch-depth: 0

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

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

- name: Build
run: CGO_ENABLED=0 go build -ldflags="-w -s" -o terraform-provider-ldap_${{ 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.19.1/golangci-lint-1.19.1-linux-amd64.tar.gz && tar -xf golangci-lint-1.19.1-linux-amd64.tar.gz
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.19.1-linux-amd64/golangci-lint run
run: golangci-lint-1.30.0-linux-amd64/golangci-lint run

- 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: Upload binaries to release
uses: svenstaro/upload-release-action@v1-release
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: terraform-provider-ldap_${{ steps.get_version.outputs.VERSION }}
asset_name: terraform-provider-ldap_${{ 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

0 comments on commit f165533

Please sign in to comment.