From 7d6a79e3b883d7f31329574d502590d704ff38d1 Mon Sep 17 00:00:00 2001 From: Mufeed Ali Date: Wed, 29 Oct 2025 01:32:42 +0530 Subject: [PATCH] feat: Introduce ghcr package --- .github/workflows/release.yml | 13 ++++++++- .goreleaser.yml | 54 +++++++++++++++++++++++++++++++++++ Containerfile | 1 + 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 547a2ea..5328055 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,6 +7,7 @@ on: permissions: contents: write + packages: write jobs: goreleaser: @@ -21,7 +22,17 @@ jobs: name: Set up Go uses: actions/setup-go@v4 with: - go-version: 1.22 + go-version: 1.22 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - + name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Test run: go test -v ./... diff --git a/.goreleaser.yml b/.goreleaser.yml index ed451ad..bc04800 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -51,3 +51,57 @@ changelog: exclude: - '^docs:' - '^test:' + +dockers: + - image_templates: + - "ghcr.io/{{ .Env.GITHUB_REPOSITORY_OWNER }}/dir2opds:{{ .Tag }}-amd64" + - "ghcr.io/{{ .Env.GITHUB_REPOSITORY_OWNER }}/dir2opds:latest-amd64" + dockerfile: Containerfile + build_flag_templates: + - "--pull" + - "--platform=linux/amd64" + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.title={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + - "--label=org.opencontainers.image.source={{.GitURL}}" + use: buildx + goarch: amd64 + extra_files: + - go.mod + - go.sum + - internal/ + - opds/ + - main.go + - main_test.go + - image_templates: + - "ghcr.io/{{ .Env.GITHUB_REPOSITORY_OWNER }}/dir2opds:{{ .Tag }}-arm64" + - "ghcr.io/{{ .Env.GITHUB_REPOSITORY_OWNER }}/dir2opds:latest-arm64" + dockerfile: Containerfile + build_flag_templates: + - "--pull" + - "--platform=linux/arm64" + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.title={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + - "--label=org.opencontainers.image.source={{.GitURL}}" + use: buildx + goarch: arm64 + extra_files: + - go.mod + - go.sum + - internal/ + - opds/ + - main.go + - main_test.go + +docker_manifests: + - name_template: "ghcr.io/{{ .Env.GITHUB_REPOSITORY_OWNER }}/dir2opds:{{ .Tag }}" + image_templates: + - "ghcr.io/{{ .Env.GITHUB_REPOSITORY_OWNER }}/dir2opds:{{ .Tag }}-amd64" + - "ghcr.io/{{ .Env.GITHUB_REPOSITORY_OWNER }}/dir2opds:{{ .Tag }}-arm64" + - name_template: "ghcr.io/{{ .Env.GITHUB_REPOSITORY_OWNER }}/dir2opds:latest" + image_templates: + - "ghcr.io/{{ .Env.GITHUB_REPOSITORY_OWNER }}/dir2opds:latest-amd64" + - "ghcr.io/{{ .Env.GITHUB_REPOSITORY_OWNER }}/dir2opds:latest-arm64" diff --git a/Containerfile b/Containerfile index 448e1bf..0596dd1 100644 --- a/Containerfile +++ b/Containerfile @@ -9,3 +9,4 @@ RUN go build -o /app/dir2opds # Stage 2: Final Image FROM docker.io/alpine COPY --from=builder /app/dir2opds /dir2opds +ENTRYPOINT ["/dir2opds"]