Skip to content

Commit

Permalink
(+semver: fix) Add debian distribution packages (#8)
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Benjamin <[email protected]>
  • Loading branch information
annymsMthd authored Sep 8, 2018
1 parent 3bd8218 commit d2b2437
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 2 deletions.
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ language: go
go:
- 1.11.x
go_import_path: github.com/annymsMthd/gogitver
sudo: true

script:
- env GO111MODULE=on make build
- sudo apt-get --yes install snapd
- sudo snap install gogitver
- env GO111MODULE=on PATH=$PATH:/snap/bin make package

deploy:
provider: releases
api_key:
Expand Down
29 changes: 28 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,45 @@ LINUX_BUILD_PATH = $(BUILD_PATH)_linux
LINUX_ARM_BUILD_PATH = $(LINUX_BUILD_PATH)-arm
WINDOWS_BUILD_PATH = $(BUILD_PATH)_windows.exe
MAC_BUILD_PATH = $(BUILD_PATH)_darwin
export VERSION=$(shell gogitver)

.PHONY: version
version: build
$(LINUX_BUILD_PATH)

.PHONY: clean
clean:
rm -Rf ./artifacts

.PHONY: test
test:
go test -v ./...

.PHONY: build
build: test
build: clean test
GOOS=linux GOARCH=amd64 go build -o $(LINUX_BUILD_PATH) cmd/gogitver/main.go
GOOS=linux GOARCH=arm go build -o $(LINUX_ARM_BUILD_PATH) cmd/gogitver/main.go
GOOS=darwin GOARCH=amd64 go build -o $(MAC_BUILD_PATH) cmd/gogitver/main.go
GOOS=windows GOARCH=amd64 go build -o $(WINDOWS_BUILD_PATH) cmd/gogitver/main.go

.PHONY: build-debian-package
build-debian-package: build
mkdir -p artifacts/debian/DEBIAN
mkdir -p artifacts/debian/usr/local/bin/
cat ./build/debian/control.template | envsubst > ./artifacts/debian/DEBIAN/control
cp $(LINUX_BUILD_PATH) artifacts/debian/usr/local/bin/gogitver
dpkg-deb --build ./artifacts/debian ./artifacts/gogitver_amd64.deb
rm -R ./artifacts/debian

.PHONY: build-snap
build-snap: build
mkdir -p artifacts/snap/snap
mkdir -p artifacts/snap/source
cp $(LINUX_BUILD_PATH) artifacts/snap/source/gogitver
cat ./build/snap/snapcraft.yaml | envsubst > ./artifacts/snap/snap/snapcraft.yaml
cd ./artifacts/snap && snapcraft clean gogitver -s pull
cd ./artifacts/snap && snapcraft
mv ./artifacts/snap/gogitver*.snap ./artifacts
rm -R ./artifacts/snap

package: build-debian-package
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ gogitver is a tool to determine the semantic version of a project based on keywo

### Installing

#### Snap
```snap install gogitver```

#### Binaries

To install download the latest release from the [releases](https://github.com/annymsMthd/gogitver/releases) page for your machine architecture and place the binary in your path. You can then run the executable while in the path of your project and it should output the current version. You can then use this version to tag container images, helm charts, etc.

### Usage
Expand Down
5 changes: 5 additions & 0 deletions build/debian/control.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Package: gogitver
Version: ${VERSION}
Maintainer: Joshua Benjamin <[email protected]>
Architecture: amd64
Description: gogitver is a tool to determine the semantic version of a project based on keywords used in the commit history.
25 changes: 25 additions & 0 deletions build/snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: gogitver
version: '${VERSION}'
summary: Provides semantic versioning through git history
description: |
gogitver is a tool to determine the semantic version of a
project based on keywords used in the commit history. gogitver
draws a lot of inspiration from GitVersion but with the benefit
of go's single binary executable. With the work done by go-git
the binary produced can run on Linux, Windows, and Mac.
grade: stable
confinement: strict

architectures:
- build-on: amd64

parts:
gogitver:
source: ./source
plugin: dump

apps:
gogitver:
command: gogitver
plugs: [home]

0 comments on commit d2b2437

Please sign in to comment.