chore(make): refactoring of the distribution task

This commit is contained in:
Nicolas Carlier 2019-01-09 10:25:51 +00:00
parent 5c01d87aa3
commit 7cb6140c1b
3 changed files with 28 additions and 23 deletions

View File

@ -9,10 +9,10 @@ deploy:
api_key:
secure: VATbHmgR1DDXlIHEMpupuTggPU6wgtZk3BFK/eT5L+qqhnfSal1z+ZsypgWMGZN2Ch6WTRFaXqUhpV7N2oo+pQoXAYcDFWTd3BiTUied+pKVoUa8VuZFF2TW1cNcVJ3fnFPMFnpJPTYkld//+8s8zJQitTabE1QZdXNYPU1uUiY=
file:
- release/webhookd-linux-amd64.gz
- release/webhookd-linux-arm64.gz
- release/webhookd-linux-arm.gz
- release/webhookd-darwin-amd64.gz
- release/webhookd-linux-amd64.tgz
- release/webhookd-linux-arm64.tgz
- release/webhookd-linux-arm.tgz
- release/webhookd-darwin-amd64.tgz
skip_cleanup: true
on:
repo: ncarlier/webhookd

View File

@ -39,7 +39,7 @@ RUN apk add --no-cache git openssh-client jq bash
RUN mkdir -p /var/opt/webhookd/scripts /var/opt/webhookd/work
# Install binary and default scripts
COPY --from=builder /go/src/$REPOSITORY/$ARTIFACT/release/$ARTIFACT-linux-amd64 /usr/local/bin/$ARTIFACT
COPY --from=builder /go/src/$REPOSITORY/$ARTIFACT/release/$ARTIFACT /usr/local/bin/$ARTIFACT
COPY --from=builder /go/src/$REPOSITORY/$ARTIFACT/scripts /var/opt/webhookd/scripts
COPY docker-entrypoint.sh /

View File

@ -13,8 +13,11 @@ GOARCH?=amd64
is_windows:=$(filter windows,$(GOOS))
EXT:=$(if $(is_windows),".exe","")
# Artefact name
ARTEFACT=release/$(APPNAME)-$(GOOS)-$(GOARCH)$(EXT)
# Archive name
ARCHIVE=$(APPNAME)-$(GOOS)-$(GOARCH).tgz
# Executable name
EXECUTABLE=$(APPNAME)$(EXT)
# Extract version infos
VERSION:=`git describe --tags`
@ -35,11 +38,11 @@ clean:
## Build executable
build:
-mkdir -p release
echo "Building: $(ARTEFACT) $(VERSION) ..."
GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(LDFLAGS) -o $(ARTEFACT)
echo "Building: $(EXECUTABLE) $(VERSION) for $(GOOS)-$(GOARCH) ..."
GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(LDFLAGS) -o release/$(EXECUTABLE)
.PHONY: build
$(ARTEFACT): build
release/$(EXECUTABLE): build
## Run tests
test:
@ -47,14 +50,14 @@ test:
.PHONY: test
## Install executable
install: $(ARTEFACT)
echo "Installing $(ARTEFACT) to ${HOME}/.local/bin/$(APPNAME) ..."
cp $(ARTEFACT) ${HOME}/.local/bin/$(APPNAME)
install: release/$(EXECUTABLE)
echo "Installing $(EXECUTABLE) to ${HOME}/.local/bin/$(EXECUTABLE) ..."
cp release/$(EXECUTABLE) ${HOME}/.local/bin/$(EXECUTABLE)
.PHONY: install
## Create Docker image
image:
echo "Building Docker inage ..."
echo "Building Docker image ..."
docker build --rm -t ncarlier/$(APPNAME) .
.PHONY: image
@ -63,16 +66,18 @@ changelog:
standard-changelog --first-release
.PHONY: changelog
## GZIP executable
gzip:
gzip $(ARTEFACT)
.PHONY: gzip
## Create archive
archive: release/$(EXECUTABLE)
echo "Creating release/$(ARCHIVE) archive..."
tar czf release/$(ARCHIVE) README.md LICENSE CHANGELOG.md -C release/ $(EXECUTABLE)
rm release/$(EXECUTABLE)
.PHONY: archive
## Create distribution binaries
distribution:
GOARCH=amd64 make build gzip
GOARCH=arm64 make build gzip
GOARCH=arm make build gzip
GOOS=darwin make build gzip
distribution: changelog
GOARCH=amd64 make build archive
GOARCH=arm64 make build archive
GOARCH=arm make build archive
GOOS=darwin make build archive
.PHONY: distribution