Skip to content

Commit

Permalink
feat: release automation
Browse files Browse the repository at this point in the history
  • Loading branch information
grishy committed Nov 20, 2024
1 parent fcfdab3 commit c3b2e42
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: release

on:
push:
tags:
- "v*"

permissions:
packages: write
contents: write

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

- uses: actions/setup-go@v5
with:
go-version: "1.23.3"

- name: Set up QEMU for cross-compilation of Docker images
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository }}
- uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker images
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: linux/amd64,linux/arm64,linux/arm/v7
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
52 changes: 52 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# https://github.com/goreleaser/goreleaser/pull/4391
version: 2

report_sizes: true

builds:
# https://goreleaser.com/customization/build/
- env:
- CGO_ENABLED=0
flags:
- -trimpath
ldflags:
- -w -s
goos:
- linux
- freebsd
- darwin
- windows
goarch:
- "386"
- "amd64"
- "arm"
- "arm64"
goarm:
- "6"
- "7"
mod_timestamp: "{{ .CommitTimestamp }}"

archives:
# https://goreleaser.com/customization/archive/
- format: tar.gz
name_template: "{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"

checksum:
# https://goreleaser.com/customization/checksum/
name_template: "checksums.txt"

release:
# https://goreleaser.com/customization/release/
target_commitish: "{{ .Commit }}"
mode: replace
header: |
## ℹ️ For information on how to install and use please see `README.md`
footer: |
Your PRs & issues are welcome! Thanks 😉
disable: false
skip_upload: false

changelog:
# https://goreleaser.com/customization/changelog/
sort: asc

0 comments on commit c3b2e42

Please sign in to comment.