Provide more metadata with images

This assigns the OCI spec labels to images pushed to GHCR, and enables
image users to see current tool version instead of just v0+HEAD.
This commit is contained in:
Timur Demin 2022-03-20 01:13:42 +05:00
parent 6f3720a4ae
commit f8a310288a
No known key found for this signature in database
GPG key ID: 9EDF3F9D9286FA20
2 changed files with 18 additions and 5 deletions

View file

@ -43,3 +43,13 @@ jobs:
tags: |
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:${{ env.tag_name }}
build-args: |
gmnhg_version=${{ env.tag_name }}
# TODO: set org.opencontainers.image.revision when this gets
# fixed: https://github.com/actions/checkout/issues/209
labels: |
org.opencontainers.image.url="${{ github.server_url }}/${{ github.repository }}"
org.opencontainers.image.source=${{ github.repositoryUrl }}
org.opencontainers.image.version=${{ env.tag_name }}
org.opencontainers.image.licenses=GPL-3.0
org.opencontainers.image.title=gmnhg

View file

@ -3,16 +3,19 @@ FROM docker.io/library/golang:1.18-alpine AS builder
WORKDIR /src
ENV CGO_ENABLED=0
ENV GO111MODULE=on
ENV GOFLAGS="-trimpath -ldflags=-linkmode=external"
RUN apk add --no-cache git gcc musl-dev
COPY . /src/
RUN \
go build -v -o /tmp/gmnhg ./cmd/gmnhg && \
go build -v -o /tmp/md2gmn ./cmd/md2gmn
ARG gmnhg_version=v0+HEAD
RUN go build \
-v \
-trimpath \
-ldflags="-linkmode=external -X main.version=${gmnhg_version}" \
-o /tmp/ \
./cmd/gmnhg \
./cmd/md2gmn
FROM docker.io/library/alpine:3.15 AS runner