Skip to content

Commit

Permalink
Merge pull request #3 from BESTSELLER/terraform-registry
Browse files Browse the repository at this point in the history
Terraform registry
  • Loading branch information
Lasse G authored Aug 20, 2020
2 parents b2a946d + e397811 commit 404ca5b
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 47 deletions.
75 changes: 29 additions & 46 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,67 +1,50 @@
version: 2
version: 2.1

orbs:
secret-injector: bestsellerit/secret-injector@0.2.32


jobs:
test:
docker:
- image: circleci/golang:1.14
steps:
- checkout
- run: go get -v ./...
build:
docker:
- image: circleci/golang:1.14
steps:
- checkout
- run:
name: update n upgrade
command: |
sudo apt update
sudo apt upgrade -y
- run: go get -v ./...
- attach_workspace:
at: /tmp
- run:
name: Build terraform provider for multiple platforms
name: go get
command: |
package_name=terraform-provider-netbox
platforms=(
"darwin/amd64"
"linux/amd64"
"windows/amd64" )
for platform in "${platforms[@]}"
do
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}
output_name=$package_name
if [ $GOOS = "windows" ]; then
output_name+='.exe'
fi
env CGO_ENABLED=0 GOOS=$GOOS GOARCH=$GOARCH go build -o $output_name
zip -v terraform-provider-netbox-$GOOS-$GOARCH $output_name
rm $output_name
done
cat /etc/*release
ls -lh
go get -v ./...
- run:
name: Upload release assets
name: Go Releaser
command: |
id=$(curl https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/releases -H "authorization: token $GH_TOKEN" | jq -r --arg tag $CIRCLE_TAG '.[] | select(.tag_name == $tag) | .id')
FILES=$(ls -l terraform-provider-netbox* | awk '{print $9}')
for f in $FILES
do
GH_ASSET="https://uploads.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/releases/$id/assets?name=$(basename $f)"
source /tmp/secrets.env
curl --data-binary @"$f" -H "authorization: token $GH_TOKEN" -H "Content-Type: application/zip" $GH_ASSET | jq
done
echo -e "$GPG_PRIVATE_KEY" | base64 --decode > $HOME/private.key
gpg --pinentry-mode loopback --batch --yes --import $HOME/private.key
curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh
sudo mv ./bin/goreleaser /usr/bin/goreleaser
rm -rf ./bin
goreleaser release --rm-dist
workflows:
version: 2
build-n-release:
jobs:
- secret-injector/dump-secrets:
vault-path: ES/terraform-stuff/dev
output-type: env
context: es02-dev
filters:
branches:
ignore: /.*/
tags:
only: /v[0-9]+.[0-9]+.[0-9]+/
- build:
requires:
- secret-injector/dump-secrets
filters:
branches:
ignore: /.*/
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ override.tf.json
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# End of https://www.toptal.com/developers/gitignore/api/terraform
# End of https://www.toptal.com/developers/gitignore/api/terraform

dist
54 changes: 54 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Visit https://goreleaser.com for documentation on how to customize this
# behavior.
before:
hooks:
# this is just an example and not a requirement for provider building/publishing
- go mod tidy
builds:
- env:
# goreleaser does not work with CGO, it could also complicate
# usage by users in CI/CD systems like Terraform Cloud where
# they are unable to install libraries.
- CGO_ENABLED=0
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath
ldflags:
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
goos:
- freebsd
- windows
- linux
- darwin
goarch:
- amd64
- '386'
- arm
- arm64
ignore:
- goos: darwin
goarch: '386'
binary: '{{ .ProjectName }}_{{ .Version }}'
archives:
- format: zip
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
checksum:
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
algorithm: sha256
signs:
- artifacts: checksum
args:
# if you are using this is 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 }}" # set this environment variable for your signing key
- "--output"
- "${signature}"
- "--detach-sign"
- "${artifact}"
release:
# If you want to manually examine the release before its live, uncomment this line:
# draft: true
changelog:
skip: true

0 comments on commit 404ca5b

Please sign in to comment.