Skip to content

Commit 748084d

Browse files
committed
Add nightly build job
1 parent 5adb7fb commit 748084d

5 files changed

Lines changed: 91 additions & 30 deletions

File tree

.github/workflows/nightly.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Nightly
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *" # Every day at midnight
6+
push:
7+
paths:
8+
- ".github/workflows/nightly.yml"
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
publish:
16+
name: Nightly
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 10
19+
20+
permissions:
21+
contents: read
22+
packages: write
23+
24+
steps:
25+
- name: 📦 Checkout repository
26+
uses: actions/checkout@v3
27+
28+
- name: 🧪 Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v2
30+
31+
- name: 🔒 Log in to the Container registry
32+
uses: docker/login-action@v2
33+
with:
34+
registry: ${{ env.REGISTRY }}
35+
username: ${{ github.actor }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: 🏗️ Build and push
39+
uses: docker/build-push-action@v4
40+
with:
41+
cache-from: type=gha
42+
cache-to: type=gha,mode=max
43+
platforms: linux/amd64,linux/arm64
44+
push: true
45+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly

.github/workflows/release.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,3 @@ jobs:
4545
DOCKERHUB_USER: ${{ secrets.DOCKER_LOGIN }}
4646
GHCR_USER: ${{ env.GHCR_USER }}
4747
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48-
49-
# Publish nightly build.
50-
- uses: goreleaser/goreleaser-action@v4.2.0
51-
if: ${{ github.repository_owner == 'mxpv' && github.event_name == 'schedule' }}
52-
with:
53-
version: latest
54-
args: release --rm-dist --nightly
55-
env:
56-
DOCKERHUB_USER: ${{ secrets.DOCKER_LOGIN }}
57-
GHCR_USER: ${{ env.GHCR_USER }}
58-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
1-
# This is a template to be used by GoReleaser.
2-
# See docs for details: https://goreleaser.com/customization/docker/
1+
FROM golang:1.20 as builder
32

4-
FROM alpine:3.16
5-
WORKDIR /app
3+
WORKDIR /build
4+
5+
COPY . .
66

7+
RUN make build
8+
9+
# Download youtube-dl
710
RUN wget -O /usr/bin/yt-dlp https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp && \
8-
chmod +x /usr/bin/yt-dlp && \
9-
ln -s /usr/bin/yt-dlp /usr/bin/youtube-dl && \
10-
apk --no-cache add ca-certificates python3 py3-pip ffmpeg tzdata
11-
COPY podsync /app/podsync
11+
chmod +x /usr/bin/yt-dlp
12+
13+
FROM alpine:3.17
14+
15+
WORKDIR /app
16+
17+
RUN apk --no-cache add ca-certificates python3 py3-pip ffmpeg tzdata \
18+
# https://github.com/golang/go/issues/59305
19+
libc6-compat && ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2
20+
21+
COPY --from=builder /usr/bin/yt-dlp /usr/bin/youtube-dl
22+
COPY --from=builder /build/bin/podsync /app/podsync
1223

1324
ENTRYPOINT ["/app/podsync"]
1425
CMD ["--no-banner"]

Makefile

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,33 @@ all: build test
55

66
#
77
# Build Podsync CLI binary
8+
# Example:
9+
# $ GOOS=amd64 make build
810
#
11+
12+
GOARCH ?= $(shell go env GOARCH)
13+
GOOS ?= $(shell go env GOOS)
14+
15+
TAG := $(shell git tag --points-at HEAD)
16+
HASH := $(shell git rev-parse --short HEAD)
17+
DATE := $(shell date)
18+
19+
LDFLAGS := "-X 'main.version=${TAG}' -X 'main.commit=${HASH}' -X 'main.date=${DATE}' -X 'main.arch=${GOARCH}'"
20+
921
.PHONY: build
1022
build:
11-
go build -o bin/podsync ./cmd/podsync
23+
go build -ldflags ${LDFLAGS} -o bin/podsync ./cmd/podsync
1224

1325
#
14-
# Build Docker image
26+
# Build a local Docker image
27+
# Example:
28+
# $ make docker
29+
# $ docker run -it --rm localhost/podsync:latest
1530
#
16-
TAG ?= localhost/podsync
31+
IMAGE_TAG ?= localhost/podsync
1732
.PHONY: docker
1833
docker:
19-
docker build -t $(TAG) .
20-
docker push $(TAG)
34+
docker buildx build -t $(IMAGE_TAG) .
2135

2236
#
2337
# Run unit tests

cmd/podsync/main.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ var (
4646
version = "dev"
4747
commit = "none"
4848
date = "unknown"
49+
arch = ""
4950
)
5051

5152
func main() {
@@ -75,6 +76,13 @@ func main() {
7576
log.Info(banner)
7677
}
7778

79+
log.WithFields(log.Fields{
80+
"version": version,
81+
"commit": commit,
82+
"date": date,
83+
"arch": arch,
84+
}).Info("running podsync")
85+
7886
// Load TOML file
7987
log.Debugf("loading configuration %q", opts.ConfigPath)
8088
cfg, err := LoadConfig(opts.ConfigPath)
@@ -99,12 +107,6 @@ func main() {
99107
}
100108
}
101109

102-
log.WithFields(log.Fields{
103-
"version": version,
104-
"commit": commit,
105-
"date": date,
106-
}).Info("running podsync")
107-
108110
downloader, err := ytdl.New(ctx, cfg.Downloader)
109111
if err != nil {
110112
log.WithError(err).Fatal("youtube-dl error")

0 commit comments

Comments
 (0)