Skip to content

Commit

Permalink
feat: add release workflow based on goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
tamcore committed Jul 30, 2024
1 parent e552e3c commit 421c837
Show file tree
Hide file tree
Showing 4 changed files with 273 additions and 132 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release

on:
push:
tags:
- 'v*'

permissions:
contents: write
packages: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- uses: goreleaser/goreleaser-action@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKER_REPO: ghcr.io/${{ github.repository }}
with:
version: latest
args: release
73 changes: 73 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
builds:
-
main: main.go
binary: pmoxs3backuproxy
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
goarch:
- amd64
- arm64
no_unique_dist_dir: true

archives:
-
id: tar
format: tar.gz
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"

checksum:
name_template: "{{ .Version }}_SHA256SUMS"
algorithm: sha256

dockers:
-
dockerfile: Dockerfile
use: buildx
goos: linux
goarch: amd64
image_templates:
- "{{ .Env.DOCKER_REPO }}:{{ .Tag }}-amd64"
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.url={{ .Env.GITHUB_SERVER_URL }}/{{ .Env.GITHUB_REPOSITORY }}"
- "--label=org.opencontainers.image.source={{ .Env.GITHUB_SERVER_URL }}/{{ .Env.GITHUB_REPOSITORY }}"
-
dockerfile: Dockerfile
use: buildx
goos: linux
goarch: arm64
image_templates:
- "{{ .Env.DOCKER_REPO }}:{{ .Tag }}-arm64v8"
build_flag_templates:
- "--platform=linux/arm64/v8"
- "--pull"
- "--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.url={{ .Env.GITHUB_SERVER_URL }}/{{ .Env.GITHUB_REPOSITORY }}"
- "--label=org.opencontainers.image.source={{ .Env.GITHUB_SERVER_URL }}/{{ .Env.GITHUB_REPOSITORY }}"

docker_manifests:
- name_template: "{{ .Env.DOCKER_REPO }}:latest"
image_templates:
- "{{ .Env.DOCKER_REPO }}:{{ .Tag }}-amd64"
- "{{ .Env.DOCKER_REPO }}:{{ .Tag }}-arm64v8"
- name_template: "{{ .Env.DOCKER_REPO }}:{{ .Tag }}"
image_templates:
- "{{ .Env.DOCKER_REPO }}:{{ .Tag }}-amd64"
- "{{ .Env.DOCKER_REPO }}:{{ .Tag }}-arm64v8"

gomod:
proxy: false

release:
draft: false
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM gcr.io/distroless/static-debian12:nonroot

WORKDIR /

ADD --chmod=555 pmoxs3backuproxy /pmoxs3backuproxy

ENTRYPOINT ["/pmoxs3backuproxy"]
Loading

0 comments on commit 421c837

Please sign in to comment.