From f16d64faf4dca3b9dfd164c96bdcfaa735213f16 Mon Sep 17 00:00:00 2001 From: Sam Lai Date: Thu, 3 Jan 2019 11:20:39 +0000 Subject: [PATCH 1/4] Use goreleaser goreleaser is a tool for releasing go projects - https://goreleaser.com/ It will package things up for multiple platforms, and even publish to Github. --- .gitignore | 2 ++ .goreleaser.yml | 38 ++++++++++++++++++++++++++++++++++++++ main.go | 9 +++++++++ 3 files changed, 49 insertions(+) create mode 100644 .gitignore create mode 100644 .goreleaser.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a0dd528 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +go-minipypi +dist/ diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..582aea3 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,38 @@ +# This is an example goreleaser.yaml file with some sane defaults. +# Make sure to check the documentation at http://goreleaser.com +before: + hooks: + # you may remove this if you don't use vgo + - go mod download + # you may remove this if you don't need go generate + - go generate ./... +builds: +- env: + - CGO_ENABLED=0 + goos: + - darwin + - linux + - freebsd + - windows + goarch: + - amd64 +archive: + replacements: + darwin: Darwin + linux: Linux + windows: Windows + 386: i386 + amd64: x86_64 + format_overrides: + - goos: windows + format: zip +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ .Tag }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' diff --git a/main.go b/main.go index afd3b5e..0bbd533 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "flag" + "fmt" "io/ioutil" "log" "os" @@ -16,6 +17,12 @@ type Configs struct { S3configs S3configs } +var ( + version = "dev" + commit = "none" + date = "unknown" +) + func genConfig(filename string) { cfg := &Configs{ WebConfigs: WebServerConfigs{ @@ -38,6 +45,8 @@ func genConfig(filename string) { } func main() { + fmt.Printf("go-minipypi - %v, commit %v, built at %v\n", version, commit, date) + cfg := Configs{} var configFile = flag.String("config", "config.yml", "config file") From 2ab5616782231ed3b30debd12ae3d25df4344839 Mon Sep 17 00:00:00 2001 From: Sam Lai Date: Thu, 3 Jan 2019 11:35:31 +0000 Subject: [PATCH 2/4] Add release instructions to README --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 01cf0d6..ed9155f 100644 --- a/README.md +++ b/README.md @@ -28,3 +28,28 @@ Installation Notes: ------ It requires a config file, see `config.yml`. Drop the `credentialsfile` parameter to use the [default AWS credentials chain](https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html#specifying-credentials). + +Release +------- + +go-minipypi uses [goreleaser](https://github.com/goreleaser/goreleaser) locally for releases. + +1. Install [goreleaser](https://goreleaser.com/install/) + +2. Ensure you're on a clean master, and tag the current commit for release - + + ```sh + git tag -a "v0.4.0" + ``` + +3. Do a dry-run of the release if necessary and check the artifacts in `dist/` - + + ```sh + goreleaser --skip-publish + ``` + +4. Using your GitHub token, complete the release - + + ```sh + GITHUB_TOKEN=your_github_token_with_release_privileges goreleaser + ``` From 270e98adc31d157ff038434b2753881b9087b3b3 Mon Sep 17 00:00:00 2001 From: Sam Lai Date: Thu, 3 Jan 2019 11:38:54 +0000 Subject: [PATCH 3/4] Just write binaries instead This is the closest we can get to the existing gzipped binary format --- .goreleaser.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 582aea3..d60ebcd 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -23,9 +23,7 @@ archive: windows: Windows 386: i386 amd64: x86_64 - format_overrides: - - goos: windows - format: zip + format: binary checksum: name_template: 'checksums.txt' snapshot: From e6f3063e0f55e44beb4d91bf1bae73405c9a4a9c Mon Sep 17 00:00:00 2001 From: Sam Lai Date: Thu, 3 Jan 2019 11:48:17 +0000 Subject: [PATCH 4/4] include version metadata in CI builds too --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f638e3a..c68dee5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,7 +17,7 @@ jobs: name: Run unit tests command: gotestsum --junitfile ${TEST_RESULTS}/go-test-report.xml - - run: go build + - run: go build -ldflags "-X main.date=`date -u +%Y-%m-%dT%H:%M:%SZ` -X main.commit=${CIRCLE_SHA1}" - run: name: Create build artifact