Skip to content

Commit

Permalink
add goreleaser as a github workflow task
Browse files Browse the repository at this point in the history
  • Loading branch information
displague committed Aug 12, 2020
1 parent 91e4250 commit c53d799
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 54 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bin/docker-machine-driver-*
checksums
.idea/

51 changes: 51 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
- go mod download
builds:
- env:
- CGO_ENABLED=0
- GO111MODULE=on
binary: docker-machine-driver-packet
goos:
- windows
- darwin
- linux
goarch:
- amd64
- arm
- arm64
goarm:
- 6
- 7
ignore:
- goos: windows
goarch: arm
- goos: windows
goarch: arm64
- goos: darwin
goarch: arm64
- goos: darwin
goarch: arm
archives:
- name_template: "{{ .Binary }}_{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
format: zip
# replacements:
# darwin: Darwin
# linux: Linux
# windows: Windows
# 386: i386
# amd64: x86_64
checksum:
name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt"
release:
name_template: "{{.ProjectName}}-v{{.Version}}"
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
57 changes: 3 additions & 54 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
default: build

version := v0.2.2
version_description := "Docker Machine Driver Plugin to Provision on Packet"
human_name := "$(version) - Docker Machine v0.8.2+"
version := "$(version)"

mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
current_dir := $(notdir $(patsubst %/,%,$(dir $(mkfile_path))))
github_user := "packethost"
Expand All @@ -21,26 +16,17 @@ containerbuild:
$(current_dir) \
make build

containerrelease:
docker build -t $(current_dir) .
docker run \
-v $(shell pwd):/go/src/$(project) \
-e GOOS \
-e GOARCH \
-e GITHUB_TOKEN \
-e GO15VENDOREXPERIMENT=1 \
$(current_dir) \
make release

clean:
rm -r bin/docker-machine*

compile:
GO111MODULE=on GOGC=off CGOENABLED=0 go build -ldflags "-s" -o bin/$(current_dir)$(BIN_SUFFIX)/$(current_dir) ./bin/...

# deprecated in favor of goreleaser
pack: cross
find ./bin -mindepth 1 -type d -exec zip -r -j {}.zip {} \;

# deprecated in favor of goreleaser
checksums: pack
for file in $(shell find bin -type f -name '*.zip'); do \
( \
Expand All @@ -61,6 +47,7 @@ print-success:

build: compile print-success

# deprecated in favor of goreleaser
cross:
for os in darwin windows linux; do \
for arch in amd64; do \
Expand All @@ -72,46 +59,8 @@ cross:
install:
cp bin/$(current_dir)/$(current_dir) /usr/local/bin/$(current_dir)

cleanrelease:
github-release delete \
--user $(github_user) \
--repo $(current_dir) \
--tag $(version)
git tag -d $(version)
git push origin :refs/tags/$(version)

tag:
if ! git tag | grep -q $(version); then \
git tag -m $(version) $(version); \
git push --tags; \
fi

checktoken:
@if [[ -z $$GITHUB_TOKEN ]]; then \
echo "GITHUB_TOKEN is not set, exiting" >&2; \
exit 1; \
fi

release: checktoken tag pack checksums
github-release release \
--user $(github_user) \
--repo $(current_dir) \
--tag $(version) \
--name $(human_name) \
--description $(version_description)
for os in darwin windows linux; do \
for arch in amd64; do \
github-release upload \
--user $(github_user) \
--repo $(current_dir) \
--tag $(version) \
--name $(current_dir)_$$os-$$arch.zip \
--file bin/$(current_dir)_$$os-$$arch.zip; \
done; \
done
github-release upload \
--user $(github_user) \
--repo $(current_dir) \
--tag $(version) \
--name checksums \
--file checksums
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,12 @@ $ sudo make install
```

Now you will now be able to specify a `-driver` of `packet` to `docker-machine` commands.

### Release

Releases are handled by [GitHub Workflows](.github/workflows/release.yml) and [goreleaser](.goreleaser.yml).

To push a new release, checkout the commit that you want released and: `make tag version=v0.2.3`. Robots handle the rest.

Releases are archived at <https://github.com/packethost/docker-machine-driver-packet/releases>

0 comments on commit c53d799

Please sign in to comment.