Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Goreleaser #22

Merged
merged 2 commits into from
Aug 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,17 @@ jobs:
release:
executor: go-build
steps:
- setup_remote_docker
- restore-workspace
- restore-go-mod-cache
# commands
- run: docker login -u "$QUAY_USER" -p "$QUAY_PASSWD" quay.io
- run: sudo apt-get -qqy update && sudo apt-get -qqy install rpm
- run: |
# ./autotag/autotag binary from the test job is not saved to the workspace with +x bit, restore it
chmod +x ./autotag/autotag
- run: GO111MODULE=off go get github.com/aktau/github-release
- run: make release
- run: ./autotag/autotag
- run: curl -sL https://git.io/goreleaser | bash -s -- --parallelism=2

workflows:
version: 2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ coverage*

vendor/**
!vendor/manifest
dist/
85 changes: 85 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
project_name: autotag
env:
- GO111MODULE=on
- GOPROXY=https://proxy.golang.org
builds:
- binary: autotag
id: macos
main: autotag/main.go
ldflags:
- -s -w -X main.version={{.Version}}+{{.ShortCommit}}
goos:
- darwin
goarch:
- amd64

- binary: autotag
id: linux
main: autotag/main.go
ldflags:
- -s -w -X main.version={{.Version}}+{{.ShortCommit}}
goos:
- linux
goarch:
- amd64

# TODO: verify windows functionality then enable windows release binaries
# - binary: autotag
# id: windows
# main: autotag/main.go
# ldflags:
# - -s -w -X main.version={{.Version}}+{{.ShortCommit}}
# goos:
# - windows
# goarch:
# - amd64

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^readme:'
- '^test:'
- Merge pull request
- Merge branch

# GPG signing
# TODO: consider implementing a "project signing key"
# sign:
# artifacts: checksum

archives:
# Binary named 'Linux' for backwards compatibility with old release format
- id: old-format-liinux
builds: ["linux"]
format: binary
name_template: "Linux"
# Binary named 'OSX' for backwards compatibility with old release format
- id: old-format-osx
builds: ["macos"]
format: binary
name_template: "OSX"

# homebrew
# brews:
# - ids:
# - archives
# github:
# owner: pantheon-systems
# name: homebrew-taps
# commit_author:
# name: pantheon releases
# email: infrastructure@pantheon.io
# folder: Formula
# homepage: "https://github.com/pantheon-systems/autotag"
# description: "Automatically add version tags to a git repo based on commit messages."

dockers:
-
dockerfile: Dockerfile
image_templates:
- "quay.io/pantheon-public/autotag:{{ .Tag }}" # v1.0.0
- "quay.io/pantheon-public/autotag:v{{ .Major }}" # v1
- "quay.io/pantheon-public/autotag:v{{ .Major }}.{{ .Minor }}" # v1.0
- "quay.io/pantheon-public/autotag:latest"
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM alpine:latest

RUN apk add --no-cache git

COPY ./autotag /autotag

ENTRYPOINT [ "/autotag" ]
8 changes: 2 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,5 @@ include scripts/make/common-go.mk
build::
go build -o $(APP)/$(APP) $(APP)/*.go

release: VERSION=$(shell $(APP)/$(APP) -n)
release:
GOOS=darwin go build -o $(APP)/$(APP)-darwin autotag/*.go
github-release release -u pantheon-systems -r $(APP) -t $(VERSION) --draft
github-release upload -u pantheon-systems -r $(APP) -n Linux -f $(APP)/$(APP) -t $(VERSION)
github-release upload -u pantheon-systems -r $(APP) -n OSX -f $(APP)/$(APP)-darwin -t $(VERSION)
snapshot:
@goreleaser --rm-dist --snapshot --debug
39 changes: 33 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,42 @@ Automatically add version tags to a git repo based on commit messages.
Dependencies
------------

* [Git 2.x](https://git-scm.com/downloads) available in PATH (version v1.0.0+)
* [Git 2.x](https://git-scm.com/downloads) available in PATH

Version v1.0.0+ depends on the Git CLI, install Git with your distribution's package management system.

Versions prior to v1.0.0 use cgo libgit or native golang Git, the binary will work standalone.

Installing
----------

On Linux the easy way to get going is to use the pre-built binary release from [GitHub Releases](https://github.com/pantheon-systems/autotag/releases).
### Pre-built binaries

Version v1.0.0+ depends on the Git CLI, install Git with your distribution's package management system.
| OS | Arch | binary |
| ----- | ----- | ------------------- |
| macOS | amd64 | [autotag][releases] |
| Linux | amd64 | [autotag][releases] |

Versions prior to v1.0.0 use cgo libgit or native golang Git, the binary will work standalone.
### Docker images

| Arch | Images |
| ----- | ---------------------------------------------------------------- |
| amd64 | `quay.io/pantheon-public/autotag:latest`, `vX.Y.Z`, `vX.Y`, `vX` |

[releases]: https://github.com/pantheon-systems/autotag/releases/latest

### One-liner

Install Linux binary at `./autotag`. For example in a `Dockerfile` or a CI/CD pipeline:

```bash
curl -s https://api.github.com/repos/pantheon-systems/autotag/releases/latest | \
grep browser_download | \
grep Linux | \
cut -d '"' -f 4 | \
xargs curl -o ./autotag -L \
&& chmod 755 ./autotag
```

Calculating Tags
----------------
Expand Down Expand Up @@ -118,6 +144,7 @@ Application Options:
-r, --repo= Path to the repo (default: ./)
-p, --pre-release-name= create a pre-release tag with this name (can be: alpha|beta|rc|pre|hotfix)
-T, --pre-release-timestamp= create a pre-release tag and append a timestamp (can be: datetime|epoch)
--version Print autotag version

Help Options:
-h, --help Show this help message
Expand All @@ -126,12 +153,12 @@ Help Options:
Build from Source
-----------------

Assuming you have Go 1.5+ installed you can checkout and run make deps build to compile the binary. It will be built as ./autotag/autotag
Assuming you have Go 1.5+ installed you can checkout and run make deps build to compile the binary. It will be built as `./autotag/autotag`.

```console
git clone git@github.com:pantheon-systems/autotag.git

cd autotag

make deps build
make build
```