Skip to content

Commit

Permalink
Inject version
Browse files Browse the repository at this point in the history
  • Loading branch information
maoueh committed Dec 11, 2024
1 parent dfa5b80 commit 047e0b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: './go.mod'

- uses: actions/cache@v4
with:
path: |
Expand All @@ -40,9 +35,6 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: Build Binary
run: go build -v -o ./substreams ./cmd/substreams

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

Expand All @@ -69,6 +61,14 @@ jobs:
flavor: |
latest=${{ startsWith(github.ref, 'refs/tags/') }}
- name: Set version
id: version
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
echo "VERSION=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
else
echo "VERSION=edge" >> "$GITHUB_OUTPUT"
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
Expand All @@ -77,3 +77,5 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.version.outputs.VERSION }}
4 changes: 2 additions & 2 deletions Dockerfile.github
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ FROM --platform=$BUILDPLATFORM golang:1.23-bullseye AS build

WORKDIR /src

ARG TARGETOS TARGETARCH
ARG TARGETOS TARGETARCH VERSION=dev

RUN --mount=target=. \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /app/substreams ./cmd/substreams
GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags "-X main.Version=$VERSION" -o /app/substreams ./cmd/substreams

FROM ubuntu:22.04

Expand Down

0 comments on commit 047e0b5

Please sign in to comment.