mirror of
https://github.com/sablierapp/sablier.git
synced 2025-12-21 13:23:03 +01:00
fix: inject release version inside docker image
This commit is contained in:
10
.github/workflows/docker.yaml
vendored
10
.github/workflows/docker.yaml
vendored
@@ -18,7 +18,7 @@ jobs:
|
|||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v3
|
uses: docker/metadata-action@v4
|
||||||
with:
|
with:
|
||||||
# list of Docker images to use as base name for tags
|
# list of Docker images to use as base name for tags
|
||||||
images: |
|
images: |
|
||||||
@@ -26,12 +26,10 @@ jobs:
|
|||||||
acouvreur/sablier
|
acouvreur/sablier
|
||||||
# generate Docker tags based on the following events/attributes
|
# generate Docker tags based on the following events/attributes
|
||||||
tags: |
|
tags: |
|
||||||
type=schedule
|
|
||||||
type=ref,event=branch
|
type=ref,event=branch
|
||||||
type=ref,event=pr
|
type=ref,event=pr
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
type=semver,pattern={{major}}
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v2
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
@@ -58,4 +56,8 @@ jobs:
|
|||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
build-args: |
|
||||||
|
BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
|
||||||
|
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
|
||||||
|
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
|
||||||
@@ -10,9 +10,12 @@ RUN go mod download
|
|||||||
|
|
||||||
COPY . /go/src/sablier
|
COPY . /go/src/sablier
|
||||||
|
|
||||||
|
ARG BUILDTIME
|
||||||
|
ARG VERSION
|
||||||
|
ARG REVISION
|
||||||
ARG TARGETOS
|
ARG TARGETOS
|
||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
RUN make ${TARGETOS}/${TARGETARCH}
|
RUN make BUILDTIME=${BUILDTIME} VERSION=${VERSION} GIT_REVISION=${REVISION} ${TARGETOS}/${TARGETARCH}
|
||||||
|
|
||||||
FROM alpine
|
FROM alpine
|
||||||
|
|
||||||
|
|||||||
8
Makefile
8
Makefile
@@ -3,17 +3,19 @@ PLATFORMS := linux/amd64 linux/arm64 linux/arm/v7 linux/arm
|
|||||||
temp = $(subst /, ,$@)
|
temp = $(subst /, ,$@)
|
||||||
os = $(word 1, $(temp))
|
os = $(word 1, $(temp))
|
||||||
arch = $(word 2, $(temp))
|
arch = $(word 2, $(temp))
|
||||||
version = draft
|
VERSION = draft
|
||||||
|
|
||||||
# Version info for binaries
|
# Version info for binaries
|
||||||
GIT_REVISION := $(shell git rev-parse --short HEAD)
|
GIT_REVISION := $(shell git rev-parse --short HEAD)
|
||||||
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
|
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
|
||||||
|
BUILDTIME := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||||
|
BUILDUSER := $(shell whoami)@$(shell hostname)
|
||||||
|
|
||||||
VPREFIX := github.com/acouvreur/sablier/version
|
VPREFIX := github.com/acouvreur/sablier/version
|
||||||
GO_LDFLAGS := -X $(VPREFIX).Branch=$(GIT_BRANCH) -X $(VPREFIX).Version=$(version) -X $(VPREFIX).Revision=$(GIT_REVISION) -X $(VPREFIX).BuildUser=$(shell whoami)@$(shell hostname) -X $(VPREFIX).BuildDate=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
|
GO_LDFLAGS := -X $(VPREFIX).Branch=$(GIT_BRANCH) -X $(VPREFIX).Version=$(VERSION) -X $(VPREFIX).Revision=$(GIT_REVISION) -X $(VPREFIX).BuildUser=$(BUILDUSER) -X $(VPREFIX).BuildDate=$(BUILDTIME)
|
||||||
|
|
||||||
$(PLATFORMS):
|
$(PLATFORMS):
|
||||||
CGO_ENABLED=0 GOOS=$(os) GOARCH=$(arch) go build -tags=nomsgpack -v -ldflags="${GO_LDFLAGS}" -o 'sablier_$(version)_$(os)-$(arch)' .
|
CGO_ENABLED=0 GOOS=$(os) GOARCH=$(arch) go build -tags=nomsgpack -v -ldflags="${GO_LDFLAGS}" -o 'sablier_$(VERSION)_$(os)-$(arch)' .
|
||||||
|
|
||||||
release: $(PLATFORMS)
|
release: $(PLATFORMS)
|
||||||
.PHONY: release $(PLATFORMS)
|
.PHONY: release $(PLATFORMS)
|
||||||
@@ -7,7 +7,7 @@ module.exports = {
|
|||||||
"@semantic-release/commit-analyzer",
|
"@semantic-release/commit-analyzer",
|
||||||
"@semantic-release/release-notes-generator",
|
"@semantic-release/release-notes-generator",
|
||||||
["@semantic-release/exec", {
|
["@semantic-release/exec", {
|
||||||
"publishCmd": "make version=${nextRelease.version} release -j 3"
|
"publishCmd": "make VERSION=${nextRelease.version} release -j 3"
|
||||||
}],
|
}],
|
||||||
["@semantic-release/github", {
|
["@semantic-release/github", {
|
||||||
"assets": [
|
"assets": [
|
||||||
|
|||||||
Reference in New Issue
Block a user