Skip to content

Commit

Permalink
Do get version with Makefile so we can use the buildx cache properly
Browse files Browse the repository at this point in the history
  • Loading branch information
primeroz committed Dec 17, 2020
1 parent 52da30b commit 89a613d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/on-push-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ jobs:
--cache-from "type=local,src=/tmp/.buildx-cache" \
--cache-to "type=local,dest=/tmp/.buildx-cache" \
--platform linux/arm64,linux/amd64,linux/arm/v7 \
--build-arg VERSION=$SHORTSHA \
--tag ${{ secrets.DOCKER_USERNAME }}/$DOCKER_HUB_REPO:master-$SHORTSHA \
--output "type=registry" .
Expand All @@ -74,6 +73,5 @@ jobs:
--cache-from "type=local,src=/tmp/.buildx-cache" \
--cache-to "type=local,dest=/tmp/.buildx-cache" \
--platform linux/arm64,linux/amd64,linux/arm/v7 \
--build-arg VERSION=$SHORTSHA \
--tag ${{ secrets.DOCKER_USERNAME }}/$DOCKER_HUB_REPO:latest \
--output "type=registry" .
2 changes: 0 additions & 2 deletions .github/workflows/on-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ jobs:
docker buildx build \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--cache-to "type=local,dest=/tmp/.buildx-cache" \
--build-arg VERSION=$TAG \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
--tag ${{ secrets.DOCKER_USERNAME }}/$DOCKER_HUB_REPO:$TAG \
--output "type=registry" .
Expand All @@ -64,7 +63,6 @@ jobs:
docker buildx build \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--cache-to "type=local,dest=/tmp/.buildx-cache" \
--build-arg VERSION=$TAG \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
--tag ${{ secrets.DOCKER_USERNAME }}/$DOCKER_HUB_REPO:latest \
--output "type=registry" .
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
FROM golang:1.15-buster as build

ARG VERSION
ENV VERSION $VERSION

WORKDIR /workspace
COPY . /workspace

Expand Down
13 changes: 6 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

var result = orderResult{}
var log = logrus.New()
var version string
var Version string

func init() {
// Setup Logging
Expand All @@ -23,14 +23,13 @@ func init() {
//log.SetLevel(logrus.InfoLevel)
log.SetLevel(logrus.DebugLevel)

// Set Version from Env
version = os.Getenv("VERSION")
if len(version) == 0 {
// Set Version
if len(Version) == 0 {
out, err := exec.Command("git", "rev-parse", "--short", "HEAD").Output()
if err != nil {
version = "master"
Version = "master"
} else {
version = string(out)
Version = string(out)
}
}
}
Expand Down Expand Up @@ -198,7 +197,7 @@ func main() {

app := &cli.App{
Name: "sats-stacker",
Version: version,
Version: Version,
Compiled: time.Now(),
Authors: []*cli.Author{
&cli.Author{
Expand Down

0 comments on commit 89a613d

Please sign in to comment.