Update release workflow

This commit is contained in:
Svilen Markov 2024-08-07 18:47:50 +01:00
parent d5cf881d7a
commit a5728e9407
3 changed files with 48 additions and 100 deletions

View File

@ -2,10 +2,8 @@ name: Create release
permissions: permissions:
contents: write contents: write
packages: write
on: on:
# Only run the workflow when a tag that starts with "v" (e.g. "v1.2.3") is pushed.
push: push:
tags: tags:
- 'v*' - 'v*'
@ -15,43 +13,25 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout the target Git reference - name: Checkout the target Git reference
# https://github.com/actions/checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Log in to the GitHub Packages registry
# https://github.com/docker/login-action
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub - name: Log in to Docker Hub
env:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
# Skip this step if credentials are not present.
if: ${{ env.dockerhub_username && env.dockerhub_token }}
# https://github.com/docker/login-action
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Golang - name: Set up Golang
# https://github.com/actions/setup-go
uses: actions/setup-go@v5 uses: actions/setup-go@v5
with: with:
go-version-file: go.mod go-version-file: go.mod
- name: Set up Docker buildx - name: Set up Docker buildx
# https://github.com/docker/setup-buildx-action
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Run GoReleaser - name: Run GoReleaser
# https://github.com/goreleaser/goreleaser-action
uses: goreleaser/goreleaser-action@v5 uses: goreleaser/goreleaser-action@v5
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,103 +1,72 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json project_name: glanceapp/glance
# .goreleaser.yaml
# ref: https://goreleaser.com/customization/
project_name: wfg/glance checksum:
disable: true
builds: builds:
- binary: glance - binary: glance
env: env:
- CGO_ENABLED=0 - CGO_ENABLED=0
goos: goos:
- darwin
- freebsd
- linux - linux
- openbsd - openbsd
- freebsd
- windows - windows
- darwin
goarch:
- amd64
- arm64
- arm
- 386
goarm:
- 7
ldflags:
- -s -w -X github.com/glanceapp/glance/internal/glance.buildVersion={{ .Tag }}
archives: archives:
# Defaults to .tar.gz; override Windows to .zip. -
- format_overrides: name_template: "glance-{{ .Os }}-{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}"
files:
- nothing*
format_overrides:
- goos: windows - goos: windows
format: zip format: zip
dockers: dockers:
# Build linux/amd64 image - image_templates:
- use: buildx - &amd64_image "{{ .ProjectName }}:{{ .Tag }}-amd64"
goarch: amd64
dockerfile: goreleaser.Dockerfile
image_templates:
# - "{{ .ProjectName }}:{{ .Version }}-amd64"
- ghcr.io/{{ .ProjectName }}:{{ .Version }}-amd64
build_flag_templates: build_flag_templates:
- --platform=linux/amd64 - --platform=linux/amd64
goarch: amd64
use: buildx
dockerfile: Dockerfile.goreleaser
# Build linux/arm64/v7 image - image_templates:
- use: buildx - &arm64v8_image "{{ .ProjectName }}:{{ .Tag }}-arm64"
goarch: arm64
dockerfile: goreleaser.Dockerfile
image_templates:
# - "{{ .ProjectName }}:{{ .Version }}-arm64v7"
- ghcr.io/{{ .ProjectName }}:{{ .Version }}-arm64v7
build_flag_templates:
- --platform=linux/arm64/v7
# Build linux/arm64 image
- use: buildx
goarch: arm64
dockerfile: goreleaser.Dockerfile
image_templates:
# - "{{ .ProjectName }}:{{ .Version }}-arm64"
- ghcr.io/{{ .ProjectName }}:{{ .Version }}-arm64
build_flag_templates: build_flag_templates:
- --platform=linux/arm64 - --platform=linux/arm64
goarch: arm64
use: buildx
dockerfile: Dockerfile.goreleaser
- image_templates:
- &arm64v7_image "{{ .ProjectName }}:{{ .Tag }}-arm64v7"
build_flag_templates:
- --platform=linux/arm64/v7
goarch: arm
goarm: 7
use: buildx
dockerfile: Dockerfile.goreleaser
docker_manifests: docker_manifests:
# Bundle images into a single multi-arch image - name_template: "{{ .ProjectName }}:{{ .Tag }}"
# glanceapp/glance:${tag}
# Creates tags for "v1.2.3", "v1.2", "v1", and latest
# - name_template: "{{ .ProjectName }}:v{{ .Major }}.{{ .Minor }}.{{ .Patch }}"
# image_templates:
# - "{{ .ProjectName }}:{{ .Version }}-amd64"
# - "{{ .ProjectName }}:{{ .Version }}-arm64v7"
# - "{{ .ProjectName }}:{{ .Version }}-arm64"
# - name_template: {{ .ProjectName }}:v{{ .Major }}.{{ .Minor }}
# image_templates:
# - "{{ .ProjectName }}:{{ .Version }}-amd64"
# - "{{ .ProjectName }}:{{ .Version }}-arm64v7"
# - "{{ .ProjectName }}:{{ .Version }}-arm64"
# - name_template: {{ .ProjectName }}:v{{ .Major }}
# image_templates:
# - "{{ .ProjectName }}:{{ .Version }}-amd64"
# - "{{ .ProjectName }}:{{ .Version }}-arm64v7"
# - "{{ .ProjectName }}:{{ .Version }}-arm64"
# - name_template: {{ .ProjectName }}:latest
# image_templates:
# - "{{ .ProjectName }}:{{ .Version }}-amd64"
# - "{{ .ProjectName }}:{{ .Version }}-arm64v7"
# - "{{ .ProjectName }}:{{ .Version }}-arm64"
# ghcr.io/glanceapp/glance
# Creates tags for "v1.2.3", "v1.2", "v1", and latest
- name_template: ghcr.io/{{ .ProjectName }}:v{{ .Major }}.{{ .Minor }}.{{ .Patch }}
image_templates: image_templates:
- ghcr.io/{{ .ProjectName }}:{{ .Version }}-amd64 - *amd64_image
- ghcr.io/{{ .ProjectName }}:{{ .Version }}-arm64v7 - *arm64v8_image
- ghcr.io/{{ .ProjectName }}:{{ .Version }}-arm64 - *arm64v7_image
- name_template: ghcr.io/{{ .ProjectName }}:v{{ .Major }}.{{ .Minor }} - name_template: "{{ .ProjectName }}:latest"
skip_push: auto
image_templates: image_templates:
- ghcr.io/{{ .ProjectName }}:{{ .Version }}-amd64 - *amd64_image
- ghcr.io/{{ .ProjectName }}:{{ .Version }}-arm64v7 - *arm64v8_image
- ghcr.io/{{ .ProjectName }}:{{ .Version }}-arm64 - *arm64v7_image
- name_template: ghcr.io/{{ .ProjectName }}:v{{ .Major }}
image_templates:
- ghcr.io/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/{{ .ProjectName }}:{{ .Version }}-arm64v7
- ghcr.io/{{ .ProjectName }}:{{ .Version }}-arm64
- name_template: ghcr.io/{{ .ProjectName }}:latest
image_templates:
- ghcr.io/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/{{ .ProjectName }}:{{ .Version }}-arm64v7
- ghcr.io/{{ .ProjectName }}:{{ .Version }}-arm64

View File

@ -1,9 +1,8 @@
FROM alpine:3.20 FROM alpine:3.20
WORKDIR /app WORKDIR /app
# This binary is an artifact from goreleaser.
COPY glance . COPY glance .
ENTRYPOINT ["/app/glance"]
EXPOSE 8080/tcp EXPOSE 8080/tcp
ENTRYPOINT ["/app/glance"]