Skip to content

Commit

Permalink
Merge pull request #257 from CircleCI-Public/fix-deploy
Browse files Browse the repository at this point in the history
Ensure packr builds static assets before goreleaser runs
  • Loading branch information
Zachary Scott authored Jan 5, 2019
2 parents f930292 + 8ddf3cc commit 070247d
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 3 deletions.
50 changes: 50 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,50 @@ jobs:
- run: gometalinter ./...
- slack-notify-on-failure

deploy-test:
executor: go
environment:
GORELEASER_URL: https://github.com/goreleaser/goreleaser/releases/download/v0.94.0/goreleaser_amd64.deb
PACKR_URL: https://github.com/gobuffalo/packr/releases/download/v2.0.0-rc.13/packr_2.0.0-rc.13_linux_amd64.tar.gz
steps:
- checkout
- restore_cache:
keys: [v3-goreleaser-]
- run:
name: Install GoReleaser
command: |
[ -f ~/goreleaser_amd64.db ] || curl --silent --location --fail --retry 3 $GORELEASER_URL > ~/goreleaser_amd64.deb
sudo apt install ~/goreleaser_amd64.deb
- gomod
- run:
name: Install packr2 to build packrd data before goreleaser builds final binary
command: |
cd $(mktemp -d)
curl -SL $PACKR_URL | tar -xzv
sudo mv packr2 /usr/local/bin/packr2
- run:
name: Release
command: goreleaser --skip-publish --skip-validate
- setup_remote_docker:
docker_layer_caching: true
- run:
name: Build Latest Docker Image
command: |
docker build -t circleci/circleci-cli:0.1.$CIRCLE_BUILD_NUM .
docker run --rm circleci/circleci-cli:0.1.$CIRCLE_BUILD_NUM circleci update check
- run:
name: Build Alpine Docker Image
command: |
docker build -t circleci/circleci-cli:0.1.$CIRCLE_BUILD_NUM-alpine --file Dockerfile.alpine .
docker run --rm circleci/circleci-cli:0.1.$CIRCLE_BUILD_NUM-alpine update check
- save_cache:
key: v3-goreleaser-{{ checksum "~/goreleaser_amd64.deb" }}
paths: [~/goreleaser_amd64.deb]
- store_artifacts:
path: ./dist
destination: dist
- slack-notify-on-failure

deploy:
executor: go
environment:
Expand All @@ -106,6 +150,9 @@ jobs:
git tag -a "v0.1.$CIRCLE_BUILD_NUM" -m "Release v0.1.$CIRCLE_BUILD_NUM"
git push origin "v0.1.$CIRCLE_BUILD_NUM"
- gomod
- run:
name: Install packr2 to build packrd data before goreleaser builds final binary
command: GO111MODULE=off go get -u github.com/gobuffalo/packr/v2/packr2
- run:
name: Release
command: goreleaser
Expand All @@ -118,6 +165,7 @@ jobs:
name: Build Latest Docker Image
command: |
docker build -t circleci/circleci-cli:0.1.$CIRCLE_BUILD_NUM .
docker run --rm circleci/circleci-cli:0.1.$CIRCLE_BUILD_NUM update check
docker push circleci/circleci-cli:0.1.$CIRCLE_BUILD_NUM
docker tag circleci/circleci-cli:0.1.$CIRCLE_BUILD_NUM circleci/circleci-cli:latest
docker push circleci/circleci-cli:latest
Expand Down Expand Up @@ -188,6 +236,7 @@ workflows:
- test
- coverage
- lint
- deploy-test
- docs:
requires:
- deploy
Expand All @@ -199,6 +248,7 @@ workflows:
- test
- coverage
- lint
- deploy-test
- shellcheck/check
filters:
branches:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ prime/
snap/.snapcraft/
stage/
*.snap

# packr related
*/*-packr.go
packrd/
5 changes: 5 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ archive:
- client/LICENSE
- md_docs/LICENSE

before:
hooks:
- make pack

builds:
- binary: circleci
env:
- CGO_ENABLED=0
- GO111MODULE=on
goos:
- windows
- darwin
Expand Down
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ GOOS=$(shell go env GOOS)
GOARCH=$(shell go env GOARCH)

build: always
GO111MODULE=on packr2 build
GO111MODULE=on packr2
go build -o build/$(GOOS)/$(GOARCH)/circleci

build-all: build/linux/amd64/circleci build/darwin/amd64/circleci
Expand All @@ -14,9 +14,9 @@ build/%/amd64/circleci: always

.PHONY: clean
clean:
go clean -i
GO111MODULE=off go clean -i
rm -rf build out docs dist
GO111MODULE=on packr2 clean
packr2 clean

.PHONY: test
test:
Expand Down Expand Up @@ -45,5 +45,9 @@ doc:
dev:
go get golang.org/x/tools/cmd/godoc

.PHONY: pack
pack:
GO111MODULE=on packr2 build

.PHONY: always
always:

0 comments on commit 070247d

Please sign in to comment.