-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve the way the version is configured so it can be set by the docker build. Signed-off-by: Yves Brissaud <[email protected]>
- Loading branch information
Showing
5 changed files
with
138 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Release on tag | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install Task | ||
uses: arduino/setup-task@v1 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set up containerd | ||
uses: crazy-max/ghaction-setup-docker@v3 | ||
with: | ||
set-host: true | ||
daemon-config: | | ||
{ | ||
"features": { | ||
"containerd-snapshotter": true | ||
} | ||
} | ||
- name: Binaries | ||
run: task go:bin:all | ||
|
||
- name: Create Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
dist/*/docker-runx-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# syntax=docker/dockerfile:1.4 | ||
|
||
ARG XX_VERSION=1.2.1 | ||
ARG ALPINE_VERSION=3.20 | ||
ARG GO_VERSION=1.23.1 | ||
|
||
ARG BIN_NAME | ||
|
||
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx | ||
|
||
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS build-base | ||
COPY --from=xx / / | ||
RUN apk add --no-cache curl | ||
RUN sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin | ||
RUN apk add --no-cache git ca-certificates openssh-client | ||
|
||
FROM build-base AS build | ||
ARG TARGETPLATFORM | ||
RUN xx-go --wrap | ||
WORKDIR /go/src/ | ||
COPY go.mod ./ | ||
COPY go.sum ./ | ||
RUN --mount=type=ssh \ | ||
--mount=type=cache,target=/root/.cache \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
go mod download | ||
COPY . ./ | ||
|
||
FROM build AS binary | ||
ENV CGO_ENABLED=0 | ||
ARG BIN_NAME | ||
RUN --mount=type=cache,target=/root/.cache \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
GIT_VERSION=$(git describe --tags | cut -c 2-) && \ | ||
xx-go build \ | ||
-o dist/${BIN_NAME} \ | ||
-ldflags="-w -s \ | ||
-X {{.PKG_NAME}}/internal/constants.Version=$GIT_VERSION" \ | ||
./cmd/${BIN_NAME} && \ | ||
xx-verify dist/${BIN_NAME} | ||
|
||
FROM scratch AS export-bin | ||
ARG BIN_NAME | ||
ARG TARGETOS | ||
ARG TARGETARCH | ||
COPY --from=binary /go/src/dist/${BIN_NAME} /${BIN_NAME}-${TARGETOS}-${TARGETARCH} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters