Skip to content

Commit 7df9384

Browse files
authored
ci: Add Terraform Registry release procedure (#42)
1 parent b864855 commit 7df9384

File tree

2 files changed

+87
-68
lines changed

2 files changed

+87
-68
lines changed

.github/workflows/release.yml

Lines changed: 32 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,43 @@
1+
# This GitHub action can publish assets for release when a tag is created.
2+
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
3+
#
4+
# This uses an action (paultyng/ghaction-import-gpg) that assumes you set your
5+
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
6+
# secret. If you would rather own your own GPG handling, please fork this action
7+
# or use an alternative one for key handling.
8+
#
9+
# You will need to pass the `--batch` flag to `gpg` in your signing step
10+
# in `goreleaser` to indicate this is being used in a non-interactive mode.
11+
#
12+
name: Release Provider
113
on:
214
push:
315
tags:
416
- 'v*'
5-
6-
name: Release provider
7-
817
jobs:
9-
create-release:
10-
name: Create release
18+
goreleaser:
1119
runs-on: ubuntu-latest
12-
outputs:
13-
upload_url: ${{ steps.create_release.outputs.upload_url }}
1420
steps:
15-
- name: Create Release
16-
id: create_release
17-
uses: actions/create-release@v1
21+
- name: Checkout
22+
uses: actions/checkout@v2
23+
- name: Unshallow
24+
run: git fetch --prune --unshallow
25+
- name: Set up Go
26+
uses: actions/setup-go@v2
27+
with:
28+
go-version: 1.14
29+
- name: Import GPG key
30+
id: import_gpg
31+
uses: paultyng/ghaction-import-gpg@v2.1.0
1832
env:
19-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
34+
PASSPHRASE: ${{ secrets.PASSPHRASE }}
35+
- name: Run GoReleaser
36+
uses: goreleaser/goreleaser-action@v2
2037
with:
21-
tag_name: ${{ github.ref }}
22-
release_name: ${{ github.ref }}
23-
draft: true
24-
prerelease: false
25-
body: |
26-
### Major Changes
27-
### Minor Changes
28-
### Bug Fixes
29-
30-
build:
31-
name: Build provider
32-
runs-on: ubuntu-latest
33-
needs: [create-release]
34-
strategy:
35-
matrix:
36-
include:
37-
- os: darwin
38-
arch: amd64
39-
- os: freebsd
40-
arch: 386
41-
- os: freebsd
42-
arch: amd64
43-
- os: freebsd
44-
arch: arm
45-
- os: linux
46-
arch: 386
47-
- os: linux
48-
arch: amd64
49-
- os: linux
50-
arch: arm
51-
- os: openbsd
52-
arch: 386
53-
- os: openbsd
54-
arch: amd64
55-
- os: solaris
56-
arch: amd64
57-
- os: windows
58-
arch: 386
59-
- os: windows
60-
arch: amd64
61-
steps:
62-
- name: Checkout code
63-
uses: actions/checkout@v2
64-
65-
- name: Build project
66-
run: |
67-
VERSION=$([ -z "`git tag -l --contains HEAD`" ] && git rev-parse --short HEAD || git tag -l --contains HEAD)
68-
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o terraform-provider-sysdig_$VERSION
69-
tar -czf "terraform-provider-sysdig-${{ matrix.os }}-${{ matrix.arch }}.tar.gz" terraform-provider-sysdig_$VERSION --remove-files
70-
71-
- name: Upload Release Asset
72-
uses: actions/upload-release-asset@v1
38+
version: latest
39+
args: release --rm-dist
7340
env:
41+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
7442
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75-
with:
76-
upload_url: ${{ needs.create-release.outputs.upload_url }}
77-
asset_path: ./terraform-provider-sysdig-${{ matrix.os }}-${{ matrix.arch }}.tar.gz
78-
asset_name: terraform-provider-sysdig-${{ matrix.os }}-${{ matrix.arch }}.tar.gz
79-
asset_content_type: application/tar+gzip
43+

.goreleaser.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Visit https://goreleaser.com for documentation on how to customize this
2+
# behavior.
3+
before:
4+
hooks:
5+
# this is just an example and not a requirement for provider building/publishing
6+
- go mod tidy
7+
builds:
8+
- env:
9+
# goreleaser does not work with CGO, it could also complicate
10+
# usage by users in CI/CD systems like Terraform Cloud where
11+
# they are unable to install libraries.
12+
- CGO_ENABLED=0
13+
mod_timestamp: '{{ .CommitTimestamp }}'
14+
flags:
15+
- -trimpath
16+
ldflags:
17+
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
18+
goos:
19+
- freebsd
20+
- windows
21+
- linux
22+
- darwin
23+
goarch:
24+
- amd64
25+
- '386'
26+
- arm
27+
- arm64
28+
ignore:
29+
- goos: darwin
30+
goarch: '386'
31+
binary: '{{ .ProjectName }}_v{{ .Version }}'
32+
archives:
33+
- format: zip
34+
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
35+
checksum:
36+
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
37+
algorithm: sha256
38+
signs:
39+
- artifacts: checksum
40+
args:
41+
# if you are using this is a GitHub action or some other automated pipeline, you
42+
# need to pass the batch flag to indicate its not interactive.
43+
- "--batch"
44+
- "--local-user"
45+
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
46+
- "--output"
47+
- "${signature}"
48+
- "--detach-sign"
49+
- "${artifact}"
50+
release:
51+
# If you want to manually examine the release before its live, uncomment this line:
52+
# draft: true
53+
changelog:
54+
skip: false
55+

0 commit comments

Comments
 (0)