1
0
mirror of https://github.com/mxpv/podsync.git synced 2024-05-11 05:55:04 +00:00

Add nightly build job

This commit is contained in:
Maksym Pavlenko
2023-05-05 15:24:36 -07:00
parent 5adb7fb04d
commit 748084df0f
5 changed files with 91 additions and 30 deletions

45
.github/workflows/nightly.yml vendored Normal file
View File

@ -0,0 +1,45 @@
name: Nightly
on:
schedule:
- cron: "0 0 * * *" # Every day at midnight
push:
paths:
- ".github/workflows/nightly.yml"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
publish:
name: Nightly
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
packages: write
steps:
- name: 📦 Checkout repository
uses: actions/checkout@v3
- name: 🧪 Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: 🔒 Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 🏗️ Build and push
uses: docker/build-push-action@v4
with:
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly

View File

@ -45,14 +45,3 @@ jobs:
DOCKERHUB_USER: ${{ secrets.DOCKER_LOGIN }}
GHCR_USER: ${{ env.GHCR_USER }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Publish nightly build.
- uses: goreleaser/goreleaser-action@v4.2.0
if: ${{ github.repository_owner == 'mxpv' && github.event_name == 'schedule' }}
with:
version: latest
args: release --rm-dist --nightly
env:
DOCKERHUB_USER: ${{ secrets.DOCKER_LOGIN }}
GHCR_USER: ${{ env.GHCR_USER }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,14 +1,25 @@
# This is a template to be used by GoReleaser.
# See docs for details: https://goreleaser.com/customization/docker/
FROM golang:1.20 as builder
WORKDIR /build
COPY . .
RUN make build
# Download youtube-dl
RUN wget -O /usr/bin/yt-dlp https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp && \
chmod +x /usr/bin/yt-dlp
FROM alpine:3.17
FROM alpine:3.16
WORKDIR /app
RUN wget -O /usr/bin/yt-dlp https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp && \
chmod +x /usr/bin/yt-dlp && \
ln -s /usr/bin/yt-dlp /usr/bin/youtube-dl && \
apk --no-cache add ca-certificates python3 py3-pip ffmpeg tzdata
COPY podsync /app/podsync
RUN apk --no-cache add ca-certificates python3 py3-pip ffmpeg tzdata \
# https://github.com/golang/go/issues/59305
libc6-compat && ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2
COPY --from=builder /usr/bin/yt-dlp /usr/bin/youtube-dl
COPY --from=builder /build/bin/podsync /app/podsync
ENTRYPOINT ["/app/podsync"]
CMD ["--no-banner"]

View File

@ -5,19 +5,33 @@ all: build test
#
# Build Podsync CLI binary
# Example:
# $ GOOS=amd64 make build
#
GOARCH ?= $(shell go env GOARCH)
GOOS ?= $(shell go env GOOS)
TAG := $(shell git tag --points-at HEAD)
HASH := $(shell git rev-parse --short HEAD)
DATE := $(shell date)
LDFLAGS := "-X 'main.version=${TAG}' -X 'main.commit=${HASH}' -X 'main.date=${DATE}' -X 'main.arch=${GOARCH}'"
.PHONY: build
build:
go build -o bin/podsync ./cmd/podsync
go build -ldflags ${LDFLAGS} -o bin/podsync ./cmd/podsync
#
# Build Docker image
# Build a local Docker image
# Example:
# $ make docker
# $ docker run -it --rm localhost/podsync:latest
#
TAG ?= localhost/podsync
IMAGE_TAG ?= localhost/podsync
.PHONY: docker
docker:
docker build -t $(TAG) .
docker push $(TAG)
docker buildx build -t $(IMAGE_TAG) .
#
# Run unit tests

View File

@ -46,6 +46,7 @@ var (
version = "dev"
commit = "none"
date = "unknown"
arch = ""
)
func main() {
@ -75,6 +76,13 @@ func main() {
log.Info(banner)
}
log.WithFields(log.Fields{
"version": version,
"commit": commit,
"date": date,
"arch": arch,
}).Info("running podsync")
// Load TOML file
log.Debugf("loading configuration %q", opts.ConfigPath)
cfg, err := LoadConfig(opts.ConfigPath)
@ -99,12 +107,6 @@ func main() {
}
}
log.WithFields(log.Fields{
"version": version,
"commit": commit,
"date": date,
}).Info("running podsync")
downloader, err := ytdl.New(ctx, cfg.Downloader)
if err != nil {
log.WithError(err).Fatal("youtube-dl error")