Skip to content

Commit 9baefc8

Browse files
authored
feat(terraform): move code into the release repo (#8)
Moves the code from our internal repo into this public repo. Also updated the build and release system to use this repo. With this, all the terraform development happens in this repo. This is required for OpenTofu (and is also the common practice for many terraform projects in general)
1 parent 0f3059e commit 9baefc8

27 files changed

+2619
-6
lines changed

.github/images/logo-full.svg

Lines changed: 89 additions & 0 deletions
Loading

.github/workflows/lint.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Go Lint and Format
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- "main"
8+
- "master"
9+
10+
env:
11+
GO_VERSION: stable
12+
GOLANGCI_LINT_VERSION: v1.60
13+
14+
jobs:
15+
golangci-lint:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-go@v5
20+
with:
21+
go-version: ${{ env.GO_VERSION }}
22+
- name: golangci-lint Action
23+
uses: golangci/golangci-lint-action@v6
24+
with:
25+
args: --timeout=3m
26+
27+
terraform-tests:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
- uses: hashicorp/setup-terraform@v3.1.2
32+
- name: Terraform Accepatance Tests
33+
run: |
34+
DFCLOUD_API_KEY=${{ secrets.DFCLOUD_API_KEY }} make test

.github/workflows/release.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Terraform Provider release workflow.
2+
name: Release
3+
4+
# This GitHub action creates a release when a tag that matches the pattern
5+
# "v*" (e.g. v0.1.0) is created.
6+
on:
7+
push:
8+
tags:
9+
- 'v*'
10+
workflow_dispatch:
11+
inputs:
12+
version:
13+
description: "The version of the release"
14+
type: string
15+
required: false
16+
17+
# Releases need permissions to read and write the repository contents.
18+
# GitHub considers creating releases and uploading assets as writing contents.
19+
permissions:
20+
contents: write
21+
22+
env:
23+
GO_VERSION: stable
24+
25+
jobs:
26+
goreleaser:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: actions/setup-go@v5
31+
with:
32+
cache: true
33+
go-version: ${{ env.GO_VERSION }}
34+
35+
- name: Import GPG key
36+
uses: crazy-max/ghaction-import-gpg@v6
37+
id: import_gpg
38+
with:
39+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
40+
passphrase: ${{ secrets.PASSPHRASE }}
41+
42+
- name: Run GoReleaser
43+
uses: goreleaser/goreleaser-action@v6
44+
with:
45+
args: release --clean
46+
env:
47+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
48+
VERSION: ${{ github.event.inputs.version || github.ref }}
49+

.goreleaser.yml

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

0 commit comments

Comments
 (0)