Skip to content

Commit

Permalink
Makefile,release,.gitignore: release in Docker
Browse files Browse the repository at this point in the history
This allows us to standardize release instructions and should make it
easier for end users to release in a standard way, regardless of the
Go version or dependency versions running on their machine.

Remove "download dependencies" step since we should be using the
vendor directory for changes.
  • Loading branch information
kevinburke committed May 2, 2020
1 parent 55a192c commit 3b23516
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 34 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ jobs:
# staticcheck needs this for GOPATH
- run: echo "::set-env name=GOPATH::$GITHUB_WORKSPACE"
- run: echo "::set-env name=PATH::$GITHUB_WORKSPACE/bin:$PATH"
- name: Download dependencies
run: go get -t -v ./...
working-directory: './src/github.com/github-release/github-release'
- name: Run tests
run: make test
working-directory: './src/github.com/github-release/github-release'
29 changes: 5 additions & 24 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,7 @@
github-release
go-app
bin/

# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go
/github-release
/go-app

*.exe

/bin
/var/cache
21 changes: 14 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
SHELL=/bin/bash -o pipefail

LAST_TAG := $(shell git describe --abbrev=0 --tags)

USER := github-release
Expand All @@ -21,7 +23,7 @@ all: $(EXECUTABLE)

# the executable used to perform the upload, dogfooding and all...
bin/tmp/$(EXECUTABLE):
go build -o "$@"
go build -v -o "$@"

# arm
bin/linux/arm/5/$(EXECUTABLE):
Expand Down Expand Up @@ -60,12 +62,17 @@ ifndef GITHUB_TOKEN
@echo "Please set GITHUB_TOKEN in the environment to perform a release"
exit 1
endif
$(MAKE) bin/tmp/$(EXECUTABLE) $(COMPRESSED_EXECUTABLE_TARGETS)
git push && git push --tags
git log --format=%B $(LAST_TAG) -1 | \
bin/tmp/$(EXECUTABLE) release -u $(USER) -r $(EXECUTABLE) \
-t $(LAST_TAG) -n $(LAST_TAG) -d - || true
$(foreach FILE,$(COMPRESSED_EXECUTABLES),$(UPLOAD_CMD);)
docker run --rm --volume $(PWD)/var/cache:/root/.cache/go-build \
--env GITHUB_TOKEN=$(GITHUB_TOKEN) \
--volume "$(PWD)":/go/src/github.com/github-release/github-release \
--workdir /go/src/github.com/github-release/github-release \
meterup/ubuntu-golang:latest \
./release \
"$(MAKE) bin/tmp/$(EXECUTABLE) $(COMPRESSED_EXECUTABLE_TARGETS) && \
git log --format=%B $(LAST_TAG) -1 | \
bin/tmp/$(EXECUTABLE) release -u $(USER) -r $(EXECUTABLE) \
-t $(LAST_TAG) -n $(LAST_TAG) -d - || true && \
$(foreach FILE,$(COMPRESSED_EXECUTABLES),$(UPLOAD_CMD);)"

# install and/or update all dependencies, run this from the project directory
# go get -u ./...
Expand Down
12 changes: 12 additions & 0 deletions release
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -euo pipefail

main() {
apt-get update && apt-get install zip
git branch --set-upstream-to=origin/master release
set -x
exec /bin/bash -c "$@"
}

main "$@"

0 comments on commit 3b23516

Please sign in to comment.