From 3b23516391a86d4f059477f4f31724bc1d837f20 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Fri, 1 May 2020 23:01:13 -0700 Subject: [PATCH] Makefile,release,.gitignore: release in Docker 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. --- .github/workflows/ci.yml | 3 --- .gitignore | 29 +++++------------------------ Makefile | 21 ++++++++++++++------- release | 12 ++++++++++++ 4 files changed, 31 insertions(+), 34 deletions(-) create mode 100755 release diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7240ba0..136ab0f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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' diff --git a/.gitignore b/.gitignore index a266021..d0e4a2f 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Makefile b/Makefile index e8414b7..4ad8d58 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +SHELL=/bin/bash -o pipefail + LAST_TAG := $(shell git describe --abbrev=0 --tags) USER := github-release @@ -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): @@ -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 ./... diff --git a/release b/release new file mode 100755 index 0000000..3557211 --- /dev/null +++ b/release @@ -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 "$@"