Skip to content

Commit 6e038ea

Browse files
Initial commit
0 parents  commit 6e038ea

39 files changed

+2935
-0
lines changed

.github/dependabot.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "gomod" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "daily"

.github/workflows/release.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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 (hashicorp/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
13+
on:
14+
push:
15+
tags:
16+
- 'v*'
17+
jobs:
18+
goreleaser:
19+
runs-on: ubuntu-latest
20+
steps:
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.16
29+
- name: Describe plugin
30+
id: plugin_describe
31+
run: echo "::set-output name=api_version::$(go run . describe | jq -r '.api_version')"
32+
- name: Import GPG key
33+
id: import_gpg
34+
uses: hashicorp/[email protected]
35+
env:
36+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
37+
PASSPHRASE: ${{ secrets.PASSPHRASE }}
38+
- name: Run GoReleaser
39+
uses: goreleaser/goreleaser-action@v2
40+
with:
41+
version: latest
42+
args: release --rm-dist
43+
env:
44+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
API_VERSION: ${{ steps.plugin_describe.outputs.api_version }}
+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# This is a manually triggered action workflow.
2+
# It uses Packer at latest version to init, validate and build
3+
# an example configuration in a folder.
4+
# This action is compatible with Packer v1.7.0 or later.
5+
name: test plugin example
6+
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
logs:
11+
description: 'Set 1 to activate full logs'
12+
required: false
13+
default: '0'
14+
folder:
15+
description: 'Example folder'
16+
required: false
17+
default: './example'
18+
19+
jobs:
20+
build:
21+
runs-on: ubuntu-latest
22+
name: init and build example
23+
steps:
24+
- name: Checkout Repository
25+
uses: actions/checkout@v2
26+
27+
- name: Init
28+
uses: hashicorp/packer-github-actions@master
29+
with:
30+
working_directory: ${{ github.event.inputs.folder }}
31+
command: init
32+
33+
- name: Validate
34+
uses: hashicorp/packer-github-actions@master
35+
with:
36+
working_directory: ${{ github.event.inputs.folder }}
37+
command: validate
38+
env:
39+
PACKER_LOG: ${{ github.event.inputs.logs }}
40+
41+
- name: Build
42+
uses: hashicorp/packer-github-actions@master
43+
with:
44+
working_directory: ${{ github.event.inputs.folder }}
45+
command: build
46+
env:
47+
PACKER_LOG: ${{ github.event.inputs.logs }}

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
main
2+
dist/*
3+
packer-plugin-scaffolding

.goreleaser.yml

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# This is an example goreleaser.yaml file with some defaults.
2+
# Make sure to check the documentation at http://goreleaser.com
3+
env:
4+
- CGO_ENABLED=0
5+
before:
6+
hooks:
7+
# We strongly recommend running tests to catch any regression before release.
8+
# Even though, this an optional step.
9+
- go test ./...
10+
# As part of the release doc files are included as a separate deliverable for
11+
# consumption by Packer.io. To include a separate docs.zip uncomment the following command.
12+
#- make ci-release-docs
13+
builds:
14+
# A separated build to run the packer-plugins-check only once for a linux_amd64 binary
15+
-
16+
id: plugin-check
17+
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}}"
25+
flags:
26+
- -trimpath #removes all file system paths from the compiled executable
27+
ldflags:
28+
- '-s -w -X {{ .ModulePath }}/version.Version={{.Version}} -X {{ .ModulePath }}/version.VersionPrerelease= '
29+
goos:
30+
- linux
31+
goarch:
32+
- amd64
33+
binary: '{{ .ProjectName }}_v{{ .Version }}_{{ .Env.API_VERSION }}_{{ .Os }}_{{ .Arch }}'
34+
-
35+
mod_timestamp: '{{ .CommitTimestamp }}'
36+
flags:
37+
- -trimpath #removes all file system paths from the compiled executable
38+
ldflags:
39+
- '-s -w -X {{ .ModulePath }}/version.Version={{.Version}} -X {{ .ModulePath }}/version.VersionPrerelease= '
40+
goos:
41+
- freebsd
42+
- windows
43+
- linux
44+
- darwin
45+
goarch:
46+
- amd64
47+
- '386'
48+
- arm
49+
- arm64
50+
ignore:
51+
- goos: darwin
52+
goarch: '386'
53+
- goos: linux
54+
goarch: amd64
55+
binary: '{{ .ProjectName }}_v{{ .Version }}_{{ .Env.API_VERSION }}_{{ .Os }}_{{ .Arch }}'
56+
archives:
57+
- format: zip
58+
files:
59+
- none*
60+
name_template: '{{ .ProjectName }}_v{{ .Version }}_{{ .Env.API_VERSION }}_{{ .Os }}_{{ .Arch }}'
61+
checksum:
62+
name_template: '{{ .ProjectName }}_v{{ .Version }}_SHA256SUMS'
63+
algorithm: sha256
64+
signs:
65+
- artifacts: checksum
66+
args:
67+
# if you are using this is in a GitHub action or some other automated pipeline, you
68+
# need to pass the batch flag to indicate its not interactive.
69+
- "--batch"
70+
- "--local-user"
71+
- "{{ .Env.GPG_FINGERPRINT }}"
72+
- "--output"
73+
- "${signature}"
74+
- "--detach-sign"
75+
- "${artifact}"
76+
release:
77+
# If you want to manually examine the release before its live, uncomment this line:
78+
# draft: true
79+
# As part of the release doc files are included as a separate deliverable for consumption by Packer.io.
80+
# To include a separate docs.zip uncomment the extra_files config and the docs.zip command hook above.
81+
#extra_files:
82+
#- glob: ./docs.zip
83+
84+
changelog:
85+
skip: true

GNUmakefile

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
NAME=scaffolding
2+
BINARY=packer-plugin-${NAME}
3+
4+
COUNT?=1
5+
TEST?=$(shell go list ./...)
6+
7+
.PHONY: dev
8+
9+
build:
10+
@go build -o ${BINARY}
11+
12+
generate:
13+
@go install github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc@latest
14+
@go generate -v ./...
15+
16+
ci-release-docs:
17+
@go install github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc@latest
18+
@packer-sdc renderdocs -src docs -partials docs-partials/ -dst docs/
19+
@/bin/sh -c "[ -d docs ] && zip -r docs.zip docs/"
20+
21+
dev: build
22+
@mkdir -p ~/.packer.d/plugins/
23+
@mv ${BINARY} ~/.packer.d/plugins/${BINARY}
24+
25+
run-example: dev
26+
@packer build ./example
27+
28+
test:
29+
@go test -count $(COUNT) $(TEST) -timeout=3m
30+
31+
testacc: dev
32+
@PACKER_ACC=1 go test -count $(COUNT) -v $(TEST) -timeout=120m

0 commit comments

Comments
 (0)