Add docker release job
This commit is contained in:
parent
496f246a2d
commit
8d2662d0dc
|
@ -1,23 +1,61 @@
|
||||||
|
---
|
||||||
name: Release
|
name: Release
|
||||||
|
|
||||||
|
# yamllint disable-line rule:truthy
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- "*"
|
- "*"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ytdl-web:
|
goreleaser:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-go@v3
|
- uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version-file: go.mod
|
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
|
- uses: github.com/goreleaser/goreleaser-action@v2
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
args: release --snapshot --clean
|
args: release --snapshot --clean
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
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
|
||||||
|
|
|
@ -6,6 +6,7 @@ FROM golang:${GOLANG_VERSION}-alpine${ALPINE_VERSION} AS build
|
||||||
ARG VERSION=latest
|
ARG VERSION=latest
|
||||||
ARG BUILD="unknown"
|
ARG BUILD="unknown"
|
||||||
ARG BUILD_DATE="unknown"
|
ARG BUILD_DATE="unknown"
|
||||||
|
ARG BUILT_BY="docker"
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
@ -19,7 +20,7 @@ RUN go build \
|
||||||
-ldflags="-X $VERSION_PKG.Version=${VERSION}" \
|
-ldflags="-X $VERSION_PKG.Version=${VERSION}" \
|
||||||
-ldflags="-X $VERSION_PKG.Build=${BUILD}" \
|
-ldflags="-X $VERSION_PKG.Build=${BUILD}" \
|
||||||
-ldflags="-X $VERSION_PKG.BuildDate=${BUILD_DATE}" \
|
-ldflags="-X $VERSION_PKG.BuildDate=${BUILD_DATE}" \
|
||||||
-ldflags="-X $VERSION_PKG.BuiltBy=dockerfile" \
|
-ldflags="-X $VERSION_PKG.BuiltBy=${BUILT_BY}" \
|
||||||
-o /ytdl-web .
|
-o /ytdl-web .
|
||||||
|
|
||||||
FROM alpine:${ALPINE_VERSION}
|
FROM alpine:${ALPINE_VERSION}
|
||||||
|
|
|
@ -46,7 +46,8 @@ thousand websites using the yt-dlp project under the hood.`,
|
||||||
ytdl := ytdl.NewYtdl(cfg, slog.Default(), cache)
|
ytdl := ytdl.NewYtdl(cfg, slog.Default(), cache)
|
||||||
|
|
||||||
s := server.New(
|
s := server.New(
|
||||||
server.DefaultOptions().
|
server.
|
||||||
|
DefaultOptions().
|
||||||
WithListenAddr(viper.GetString("http.listen")).
|
WithListenAddr(viper.GetString("http.listen")).
|
||||||
WithListenPort(viper.GetInt("http.port")).
|
WithListenPort(viper.GetInt("http.port")).
|
||||||
WithLogger(logger.With("module", "server")),
|
WithLogger(logger.With("module", "server")),
|
||||||
|
|
|
@ -75,6 +75,7 @@
|
||||||
--build-arg VERSION=$VERSION \
|
--build-arg VERSION=$VERSION \
|
||||||
--build-arg BUILD=$(build-id) \
|
--build-arg BUILD=$(build-id) \
|
||||||
--build-arg BUILD_DATE=$(build-date) \
|
--build-arg BUILD_DATE=$(build-date) \
|
||||||
|
--build-arg BUILT_BY="Devenv Script" \
|
||||||
--output $output
|
--output $output
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue