Skip to content

Commit

Permalink
snap
Browse files Browse the repository at this point in the history
Includes snapcraft.yaml to build [snap](https://snapcraft.io/).
  • Loading branch information
mikeroyal committed Jun 11, 2019
1 parent da07cf4 commit 9bf098d
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions snap/snapcraft.yaml
@@ -0,0 +1,54 @@
name: terraformer
summary: CLI tool.
description:| CLI tool to generate terraform files from existing infrastructure (reverse Terraform).

adopt-info:terraformer

grade: stable
confinement: strict

architectures:
- build-on: amd64
- build-on: armhf
- build-on: arm64

apps:
terraformer:
command: bin/terraformer
plugs:
- home
- network
- removable-media

parts:
terraformer:
plugin: nil
source: https://github.com/GoogleCloudPlatform/terraformer.git
source-type: git
override-pull: |
git clone https://github.com/GoogleCloudPlatform/terraformer.git src/github.com/GoogleCloudPlatform/terraformer
cd src/github.com/GoogleCloudPlatform/terraformer
last_committed_tag="$(git describe --tags --abbrev=0)"
last_committed_tag_ver="$(echo ${last_committed_tag} | sed 's/v//')"
last_released_tag="$(snap info $SNAPCRAFT_PROJECT_NAME | awk '$1 == "beta:" { print $2 }')"
# If the latest tag from the upstream project has not been released to
# beta, build that tag instead of master.
if [ "${last_committed_tag_ver}" != "${last_released_tag}" ]; then
git fetch
git checkout "${last_committed_tag}"
fi
snapcraftctl set-version "$(git describe --tags | sed 's/v//')"
override-build: |
export GOPATH=$PWD
cd src/github.com/GoogleCloudPlatform/terraformer
env CGO_ENABLED=0 GOOS=linux \
go build --ldflags "-s -w \
-X 'github.com/GoogleCloudPlatform/terraformer/version.GitCommit=$(git rev-list -1 HEAD)' \
-X 'github.com/GoogleCloudPlatform/terraformer/version.Version=$(git describe --tags --abbrev=0)'" \
-a -installsuffix cgo -o $SNAPCRAFT_PART_INSTALL/bin/terraformer
build-snaps:
- go
build-packages:
- git
- sed

0 comments on commit 9bf098d

Please sign in to comment.