Skip to content

Commit

Permalink
ci: set up release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
michenriksen committed May 22, 2024
1 parent 924829e commit 36628c7
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
name: release
permissions:
contents: write
on:
workflow_dispatch:
inputs:
version:
description: "Release version (e.g., v1.0.0)"
required: true
jobs:
run:
name: Release
runs-on: ubuntu-latest
container:
image: goreleaser/goreleaser:latest
steps:
- name: Install dependencies
run: apk add --no-cache bash ncurses git
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- run: |
git config --global --add safe.directory "$PWD"
git fetch --force --tags
- name: Create release tag
run: |
git config --global user.email "[email protected]"
git config --global user.name "Michael Henriksen"
git tag -a "$VERSION" -m "$VERSION"
env:
VERSION: ${{ github.event.inputs.version }}
- name: Run GoReleaser
run: goreleaser release --clean
env:
VERSION: ${{ github.event.inputs.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Notify Go proxy about new release
run: go list -m "github.com/michenriksen/tatt@${VERSION}" || true
env:
GOPROXY: proxy.golang.org
VERSION: ${{ github.event.inputs.version }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,5 @@ tags

# End of https://www.toptal.com/developers/gitignore/api/go,vim,visualstudiocode,macos,linux


dist/
67 changes: 67 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

# The lines below are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 1
project_name: tatt

before:
hooks:
- go mod tidy

builds:
- id: tatt
env:
- CGO_ENABLED=0
main: ./cmd/tatt
binary: tatt
flags:
- "-trimpath"
asmflags:
- "-D mysymbol"
- "all=-trimpath={{.Env.GOPATH}}"
ldflags:
- "-s -w"
- "-X github.com/michenriksen/tatt/internal/cli.version={{ .Version }}"
goos:
- linux
- windows
- darwin

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
files:
- README.md
- LICENSE

checksum:
name_template: "checksums.txt"

changelog:
sort: asc
filters:
include:
- "^feat[(:]"
- "^fix[(:]"
- "^build[(:]"

release:
draft: true
replace_existing_draft: true
discussion_category_name: General

0 comments on commit 36628c7

Please sign in to comment.