Skip to content

Commit beed3e9

Browse files
authored
Update plugin release procedure (#25)
Update tooling Update GPG key as the old one no longer works Allow the workflow to be run manually for testing Introduce a version module similarly to the packer scaffolding example
1 parent 484cbda commit beed3e9

File tree

5 files changed

+34
-13
lines changed

5 files changed

+34
-13
lines changed

.github/workflows/release.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Unshallow
2525
run: git fetch --prune --unshallow
2626
- name: Set up Go
27-
uses: actions/setup-go@v2
27+
uses: actions/setup-go@v3
2828
with:
2929
go-version: 1.16
3030
- name: Describe plugin
@@ -34,10 +34,10 @@ jobs:
3434
id: import_gpg
3535
uses: crazy-max/ghaction-import-gpg@v5.0.0
3636
with:
37-
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
38-
passphrase: ${{ secrets.GPG_PASSPHRASE }}
37+
gpg_private_key: ${{ secrets.NEW_GPG_PRIVATE_KEY }}
38+
passphrase: ${{ secrets.NEW_PASSPHRASE }}
3939
- name: Run GoReleaser
40-
uses: goreleaser/goreleaser-action@v2
40+
uses: goreleaser/goreleaser-action@v3
4141
with:
4242
version: latest
4343
args: release --rm-dist

.goreleaser.yml

+5-8
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,14 @@ before:
99
- go test ./...
1010
# As part of the release doc files are included as a separate deliverable for
1111
# consumption by Packer.io. To include a separate docs.zip uncomment the following command.
12-
#- /bin/sh -c "[ -d docs ] && zip -r docs.zip docs/"
12+
#- make ci-release-docs
13+
# Check plugin compatibility with required version of the Packer SDK
14+
- make plugin-check
1315
builds:
1416
# A separated build to run the packer-plugins-check only once for a linux_amd64 binary
1517
-
1618
id: plugin-check
1719
mod_timestamp: '{{ .CommitTimestamp }}'
18-
hooks:
19-
post:
20-
# This will check plugin compatibility against latest version of Packer
21-
- cmd: |
22-
go install github.com/hashicorp/packer/cmd/packer-plugins-check@latest &&
23-
packer-plugins-check -load={{ .Name }}
24-
dir: "{{ dir .Path}}"
2520
flags:
2621
- -trimpath #removes all file system paths from the compiled executable
2722
ldflags:
@@ -48,6 +43,8 @@ builds:
4843
- arm
4944
- arm64
5045
ignore:
46+
- goos: windows
47+
goarch: arm64
5148
- goos: darwin
5249
goarch: '386'
5350
- goos: linux

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PREFIX := github.com/macstadium/packer-plugin-macstadium-orka
22
VERSION := $(shell git describe --tags --candidates=1 --dirty 2>/dev/null || echo "dev")
3-
FLAGS := -X main.Version=$(VERSION)
3+
FLAGS := -X version/version.Version=$(VERSION)
44
BIN := packer-plugin-macstadium-orka
55
SOURCES := $(shell find . -name '*.go')
66
GOOS ?= darwin
@@ -27,6 +27,9 @@ packer-build-example:
2727
packer-build-example-non-debug:
2828
packer build examples/orka.pkr.hcl
2929

30+
plugin-check: build
31+
PATH=$(shell pwd):${PATH} packer-sdc plugin-check $(BIN)
32+
3033
fresh: clean build install packer-build-example-non-debug clean
3134

3235
rebuild: build install clean

main.go

+2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import (
66

77
"github.com/hashicorp/packer-plugin-sdk/plugin"
88
"github.com/macstadium/packer-plugin-macstadium-orka/builder/orka"
9+
builderVersion "github.com/macstadium/packer-plugin-macstadium-orka/version"
910
)
1011

1112
func main() {
1213
pps := plugin.NewSet()
1314
pps.RegisterBuilder(plugin.DEFAULT_NAME, new(orka.Builder))
15+
pps.SetVersion(builderVersion.PluginVersion)
1416
err := pps.Run()
1517

1618
if err != nil {

version/version.go

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package version
2+
3+
import (
4+
"github.com/hashicorp/packer-plugin-sdk/version"
5+
)
6+
7+
var (
8+
// Version is the main version number that is being run at the moment.
9+
Version = "0.0.1"
10+
11+
// VersionPrerelease is A pre-release marker for the Version. If this is ""
12+
// (empty string) then it means that it is a final release. Otherwise, this
13+
// is a pre-release such as "dev" (in development), "beta", "rc1", etc.
14+
VersionPrerelease = "dev"
15+
16+
// PluginVersion is used by the plugin set to allow Packer to recognize
17+
// what version this plugin is.
18+
PluginVersion = version.InitializePluginVersion(Version, VersionPrerelease)
19+
)

0 commit comments

Comments
 (0)