Add docker release job

This commit is contained in:
Evan Fiordeliso 2023-08-14 19:26:48 -04:00
parent 496f246a2d
commit 8d2662d0dc
4 changed files with 46 additions and 5 deletions

View File

@ -1,23 +1,61 @@
---
name: Release
# yamllint disable-line rule:truthy
on:
push:
tags:
- "*"
jobs:
ytdl-web:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: go.mod
- uses: github.com/docker/setup-qemu-action@v2
- uses: github.com/docker/setup-buildx-action@v2
- uses: github.com/goreleaser/goreleaser-action@v2
with:
version: latest
args: release --snapshot --clean
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
docker:
runs-on: ubuntu-latest
steps:
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: git.fifitido.net/apps/ytdl-web
# generate Docker tags based on the following events/attributes
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=pep440,pattern={{version}}
type=sha
- name: Setup QEMU
uses: github.com/docker/setup-qemu-action@v2
- name: Setup Docker Buildx
uses: github.com/docker/setup-buildx-action@v2
- name: Login to Docker Registry
uses: github.com/docker/login-action@v2
with:
registry: git.fifitido.net
username: ${{ gitea.repository_owner }}
password: ${{ secrets.GITEA_TOKEN }}
- name: Build and push
uses: github.com/docker/build-push-action@v4
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# yamllint disable rule:line-length
build-args: |
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
BUILD=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
BUILD_DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
BUILT_BY=Gitea Actions
# yamllint enable rule:line-length

View File

@ -6,6 +6,7 @@ FROM golang:${GOLANG_VERSION}-alpine${ALPINE_VERSION} AS build
ARG VERSION=latest
ARG BUILD="unknown"
ARG BUILD_DATE="unknown"
ARG BUILT_BY="docker"
WORKDIR /app
@ -19,7 +20,7 @@ RUN go build \
-ldflags="-X $VERSION_PKG.Version=${VERSION}" \
-ldflags="-X $VERSION_PKG.Build=${BUILD}" \
-ldflags="-X $VERSION_PKG.BuildDate=${BUILD_DATE}" \
-ldflags="-X $VERSION_PKG.BuiltBy=dockerfile" \
-ldflags="-X $VERSION_PKG.BuiltBy=${BUILT_BY}" \
-o /ytdl-web .
FROM alpine:${ALPINE_VERSION}

View File

@ -46,7 +46,8 @@ thousand websites using the yt-dlp project under the hood.`,
ytdl := ytdl.NewYtdl(cfg, slog.Default(), cache)
s := server.New(
server.DefaultOptions().
server.
DefaultOptions().
WithListenAddr(viper.GetString("http.listen")).
WithListenPort(viper.GetInt("http.port")).
WithLogger(logger.With("module", "server")),

View File

@ -75,6 +75,7 @@
--build-arg VERSION=$VERSION \
--build-arg BUILD=$(build-id) \
--build-arg BUILD_DATE=$(build-date) \
--build-arg BUILT_BY="Devenv Script" \
--output $output
'';