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:
contents: write
packages: write
on:
# Only run the workflow when a tag that starts with "v" (e.g. "v1.2.3") is pushed.
push:
tags:
- 'v*'
@ -15,43 +13,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the target Git reference
# https://github.com/actions/checkout
uses: actions/checkout@v4
with:
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
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
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Golang
# https://github.com/actions/setup-go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Set up Docker buildx
# https://github.com/docker/setup-buildx-action
uses: docker/setup-buildx-action@v3
- name: Run GoReleaser
# https://github.com/goreleaser/goreleaser-action
uses: goreleaser/goreleaser-action@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,103 +1,72 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# .goreleaser.yaml
# ref: https://goreleaser.com/customization/
project_name: glanceapp/glance
project_name: wfg/glance
checksum:
disable: true
builds:
- binary: glance
env:
- CGO_ENABLED=0
goos:
- darwin
- freebsd
- linux
- openbsd
- freebsd
- windows
- darwin
goarch:
- amd64
- arm64
- arm
- 386
goarm:
- 7
ldflags:
- -s -w -X github.com/glanceapp/glance/internal/glance.buildVersion={{ .Tag }}
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
format: zip
dockers:
# Build linux/amd64 image
- use: buildx
goarch: amd64
dockerfile: goreleaser.Dockerfile
image_templates:
# - "{{ .ProjectName }}:{{ .Version }}-amd64"
- ghcr.io/{{ .ProjectName }}:{{ .Version }}-amd64
- image_templates:
- &amd64_image "{{ .ProjectName }}:{{ .Tag }}-amd64"
build_flag_templates:
- --platform=linux/amd64
goarch: amd64
use: buildx
dockerfile: Dockerfile.goreleaser
# Build linux/arm64/v7 image
- use: buildx
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
- image_templates:
- &arm64v8_image "{{ .ProjectName }}:{{ .Tag }}-arm64"
build_flag_templates:
- --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:
# Bundle images into a single multi-arch image
# 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 }}
- name_template: "{{ .ProjectName }}:{{ .Tag }}"
image_templates:
- ghcr.io/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/{{ .ProjectName }}:{{ .Version }}-arm64v7
- ghcr.io/{{ .ProjectName }}:{{ .Version }}-arm64
- name_template: ghcr.io/{{ .ProjectName }}:v{{ .Major }}.{{ .Minor }}
- *amd64_image
- *arm64v8_image
- *arm64v7_image
- name_template: "{{ .ProjectName }}:latest"
skip_push: auto
image_templates:
- ghcr.io/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/{{ .ProjectName }}:{{ .Version }}-arm64v7
- ghcr.io/{{ .ProjectName }}:{{ .Version }}-arm64
- 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
- *amd64_image
- *arm64v8_image
- *arm64v7_image

View File

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