Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
azr committed Apr 20, 2021
0 parents commit 17eac62
Show file tree
Hide file tree
Showing 38 changed files with 2,607 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
46 changes: 46 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This GitHub action can publish assets for release when a tag is created.
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
#
# This uses an action (paultyng/ghaction-import-gpg) that assumes you set your
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
# secret. If you would rather own your own GPG handling, please fork this action
# or use an alternative one for key handling.
#
# You will need to pass the `--batch` flag to `gpg` in your signing step
# in `goreleaser` to indicate this is being used in a non-interactive mode.
#
name: release
on:
push:
tags:
- 'v*'
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Describe plugin
id: plugin_describe
run: echo "::set-output name=api_version::$(go run . describe | jq -r '.api_version')"
- name: Import GPG key
id: import_gpg
uses: paultyng/[email protected]
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.PASSPHRASE }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
API_VERSION: ${{ steps.plugin_describe.outputs.api_version }}
47 changes: 47 additions & 0 deletions .github/workflows/test-plugin-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This is a manually triggered action workflow.
# It uses Packer at latest version to init, validate and build
# an example configuration in a folder.
# This action is compatible with Packer v1.7.0 or later.
name: test plugin example

on:
workflow_dispatch:
inputs:
logs:
description: 'Set 1 to activate full logs'
required: false
default: '0'
folder:
description: 'Example folder'
required: false
default: './example'

jobs:
build:
runs-on: ubuntu-latest
name: init and build example
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Init
uses: hashicorp/packer-github-actions@master
with:
working_directory: ${{ github.event.inputs.folder }}
command: init

- name: Validate
uses: hashicorp/packer-github-actions@master
with:
working_directory: ${{ github.event.inputs.folder }}
command: validate
env:
PACKER_LOG: ${{ github.event.inputs.logs }}

- name: Build
uses: hashicorp/packer-github-actions@master
with:
working_directory: ${{ github.event.inputs.folder }}
command: build
env:
PACKER_LOG: ${{ github.event.inputs.logs }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
main
dist/*
packer-plugin-scaffolding
85 changes: 85 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# This is an example goreleaser.yaml file with some defaults.
# Make sure to check the documentation at http://goreleaser.com
env:
- CGO_ENABLED=0
before:
hooks:
# We strongly recommend running tests to catch any regression before release.
# Even though, this an optional step.
- go test ./...
# As part of the release doc files are included as a separate deliverable for
# consumption by Packer.io. To include a separate docs.zip uncomment the following command.
#- /bin/sh -c "[ -d docs ] && zip -r docs.zip docs/"
builds:
# A separated build to run the packer-plugins-check only once for a linux_amd64 binary
-
id: plugin-check
mod_timestamp: '{{ .CommitTimestamp }}'
hooks:
post:
# This will check plugin compatibility against latest version of Packer
- cmd: |
go install github.com/hashicorp/packer/cmd/packer-plugins-check@latest &&
packer-plugins-check -load={{ .Name }}
dir: "{{ dir .Path}}"
flags:
- -trimpath #removes all file system paths from the compiled executable
ldflags:
- '-s -w -X main.Version={{.Version}} -X main.VersionPrerelease= '
goos:
- linux
goarch:
- amd64
binary: '{{ .ProjectName }}_v{{ .Version }}_{{ .Env.API_VERSION }}_{{ .Os }}_{{ .Arch }}'
-
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath #removes all file system paths from the compiled executable
ldflags:
- '-s -w -X main.version={{.Version}} -X main.VersionPrerelease= '
goos:
- freebsd
- windows
- linux
- darwin
goarch:
- amd64
- '386'
- arm
- arm64
ignore:
- goos: darwin
goarch: '386'
- goos: linux
goarch: amd64
binary: '{{ .ProjectName }}_v{{ .Version }}_{{ .Env.API_VERSION }}_{{ .Os }}_{{ .Arch }}'
archives:
- format: zip
files:
- none*
name_template: '{{ .ProjectName }}_v{{ .Version }}_{{ .Env.API_VERSION }}_{{ .Os }}_{{ .Arch }}'
checksum:
name_template: '{{ .ProjectName }}_v{{ .Version }}_SHA256SUMS'
algorithm: sha256
signs:
- artifacts: checksum
args:
# if you are using this is in a GitHub action or some other automated pipeline, you
# need to pass the batch flag to indicate its not interactive.
- "--batch"
- "--local-user"
- "{{ .Env.GPG_FINGERPRINT }}"
- "--output"
- "${signature}"
- "--detach-sign"
- "${artifact}"
release:
# If you want to manually examine the release before its live, uncomment this line:
# draft: true
# As part of the release doc files are included as a separate deliverable for consumption by Packer.io.
# To include a separate docs.zip uncomment the extra_files config and the docs.zip command hook above.
#extra_files:
#- glob: ./docs.zip

changelog:
skip: true
23 changes: 23 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
NAME=scaffolding
BINARY=packer-plugin-${NAME}

COUNT?=1
TEST?=$(shell go list ./...)

.PHONY: dev

build:
@go build -o ${BINARY}

dev: build
@mkdir -p ~/.packer.d/plugins/
@mv ${BINARY} ~/.packer.d/plugins/${BINARY}

run-example: dev
@packer build ./example

test:
@go test -count $(COUNT) $(TEST) -timeout=3m

testacc: dev
@PACKER_ACC=1 go test -count $(COUNT) -v $(TEST) -timeout=120m
Loading

0 comments on commit 17eac62

Please sign in to comment.