Skip to content

Commit 385adfa

Browse files
author
Karl Sorensen
committed
Create github action to build release
1 parent 736276e commit 385adfa

File tree

2 files changed

+146
-0
lines changed

2 files changed

+146
-0
lines changed

.github/workflows/release.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
name: Build
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
include:
18+
- goos: linux
19+
goarch: amd64
20+
- goos: linux
21+
goarch: arm64
22+
- goos: darwin
23+
goarch: amd64
24+
- goos: darwin
25+
goarch: arm64
26+
- goos: windows
27+
goarch: amd64
28+
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v4
32+
33+
- name: Set up Go
34+
uses: actions/setup-go@v5
35+
with:
36+
go-version: '1.23'
37+
38+
- name: Get version from tag
39+
id: version
40+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
41+
42+
- name: Build binary
43+
env:
44+
GOOS: ${{ matrix.goos }}
45+
GOARCH: ${{ matrix.goarch }}
46+
run: |
47+
BINARY_NAME="terraform-provider-axonops_v${{ steps.version.outputs.VERSION }}_${{ matrix.goos }}_${{ matrix.goarch }}"
48+
if [ "${{ matrix.goos }}" = "windows" ]; then
49+
BINARY_NAME="${BINARY_NAME}.exe"
50+
fi
51+
go build -o "${BINARY_NAME}" -ldflags="-s -w"
52+
zip "${BINARY_NAME}.zip" "${BINARY_NAME}"
53+
54+
- name: Upload artifact
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: terraform-provider-axonops_${{ matrix.goos }}_${{ matrix.goarch }}
58+
path: "*.zip"
59+
60+
release:
61+
name: Create Release
62+
needs: build
63+
runs-on: ubuntu-latest
64+
steps:
65+
- name: Checkout code
66+
uses: actions/checkout@v4
67+
68+
- name: Download all artifacts
69+
uses: actions/download-artifact@v4
70+
with:
71+
path: artifacts
72+
merge-multiple: true
73+
74+
- name: Generate checksums
75+
run: |
76+
cd artifacts
77+
sha256sum *.zip > checksums.txt
78+
79+
- name: Create Release
80+
uses: softprops/action-gh-release@v1
81+
with:
82+
files: |
83+
artifacts/*.zip
84+
artifacts/checksums.txt
85+
generate_release_notes: true
86+
draft: false
87+
prerelease: false

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,65 @@ provider_installation {
3838
}
3939
```
4040

41+
### Install to Local Plugin Directory
42+
43+
To install the provider to your local Terraform plugin cache, you can either download a pre-built release or build from source.
44+
45+
#### Option 1: Download from GitHub Releases
46+
47+
```bash
48+
# Set variables for your platform
49+
OS="linux" # or "darwin" for macOS, "windows" for Windows
50+
ARCH="amd64" # or "arm64" for ARM-based systems
51+
VERSION="1.0.0"
52+
53+
# Download the release
54+
curl -LO "https://github.com/axonops/axonops-kafka-tf/releases/download/v${VERSION}/terraform-provider-axonops_v${VERSION}_${OS}_${ARCH}.zip"
55+
56+
# Create the plugin directory
57+
mkdir -p ~/.terraform.d/plugins/registry.terraform.io/hashicorp/axonops/${VERSION}/${OS}_${ARCH}/
58+
59+
# Unzip to the plugin directory
60+
unzip "terraform-provider-axonops_v${VERSION}_${OS}_${ARCH}.zip" -d ~/.terraform.d/plugins/registry.terraform.io/hashicorp/axonops/${VERSION}/${OS}_${ARCH}/
61+
```
62+
63+
#### Option 2: Build from Source
64+
65+
```bash
66+
# Set variables for your platform
67+
OS="linux" # or "darwin" for macOS, "windows" for Windows
68+
ARCH="amd64" # or "arm64" for ARM-based systems
69+
VERSION="1.0.0"
70+
71+
# Clone and build
72+
git clone https://github.com/axonops/axonops-kafka-tf.git
73+
cd axonops-kafka-tf
74+
go build -o terraform-provider-axonops
75+
76+
# Create the plugin directory
77+
mkdir -p ~/.terraform.d/plugins/registry.terraform.io/hashicorp/axonops/${VERSION}/${OS}_${ARCH}/
78+
79+
# Copy the binary
80+
cp terraform-provider-axonops ~/.terraform.d/plugins/registry.terraform.io/hashicorp/axonops/${VERSION}/${OS}_${ARCH}/
81+
```
82+
83+
#### Configure Terraform
84+
85+
Reference the provider in your Terraform configuration:
86+
87+
```hcl
88+
terraform {
89+
required_providers {
90+
axonops = {
91+
source = "hashicorp/axonops"
92+
version = "1.0.0"
93+
}
94+
}
95+
}
96+
```
97+
98+
Run `terraform init` to initialize the provider.
99+
41100
## Provider Configuration
42101

43102
```hcl

0 commit comments

Comments
 (0)