Skip to content

Commit

Permalink
ci: add lint and goreleaser workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jon4hz committed Feb 29, 2024
1 parent e915353 commit 84a648c
Show file tree
Hide file tree
Showing 3 changed files with 216 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: lint
on: [push, pull_request, workflow_dispatch]

jobs:
lint:
uses: jon4hz/meta/.github/workflows/lint.yml@master
89 changes: 89 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
name: goreleaser

on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:


permissions:
contents: write
id-token: write
packages: write

jobs:
prepare:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
env:
flags: ""
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version: 1.21
cache: true
- shell: bash
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- uses: actions/cache@v3
if: matrix.os == 'ubuntu-latest'
with:
path: dist/linux
key: linux-${{ env.sha_short }}
- if: ${{ github.event_name == 'workflow_dispatch' }}
shell: bash
run: echo "flags=--nightly" >> $GITHUB_ENV
- uses: goreleaser/goreleaser-action@v4
if: steps.cache.outputs.cache-hit != 'true' # do not run if cache hit
with:
distribution: goreleaser-pro
version: latest
args: release --clean --split ${{ env.flags }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
AUR_KEY: ${{ secrets.AUR_KEY }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}

release:
runs-on: ubuntu-latest
needs: prepare
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version: 1.21
cache: true

# copy the cashes from prepare
- shell: bash
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
path: dist/linux
key: linux-${{ env.sha_short }}

# release
- uses: goreleaser/goreleaser-action@v4
if: steps.cache.outputs.cache-hit != 'true' # do not run if cache hit
with:
version: latest
distribution: goreleaser-pro
args: continue --merge
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
AUR_KEY: ${{ secrets.AUR_KEY }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
121 changes: 121 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---
variables:
main: "."
binary_name: "gmotd"
description: "a configurable, dynamic motd generator"
github_url: "https://github.com/jon4hz/gmotd"
maintainer: "jonah <[email protected]>"
license: "MIT"
homepage: "https://jon4hz.io"
aur_package: |-
# bin
install -Dm755 "./gmotd" "${pkgdir}/usr/bin/gmotd"
# license
install -Dm644 "./LICENSE" "${pkgdir}/usr/share/licenses/gmotd/LICENSE"
before:
hooks:
- go mod tidy

builds:
-
id: default
env:
- CGO_ENABLED=0
main: '{{ .Var.main }}'
binary: '{{ .Var.binary_name }}'
ldflags:
- -s
- -w
- -X github.com/jon4hz/{{ .Var.binary_name }}/internal/version.Version={{ .Version }}
- -X github.com/jon4hz/{{ .Var.binary_name }}/internal/version.Commit={{ .Commit }}
- -X github.com/jon4hz/{{ .Var.binary_name }}/internal/version.Date={{ .Date }}
- -X github.com/jon4hz/{{ .Var.binary_name }}/internal/version.BuiltBy=goreleaser
flags:
- -trimpath
goos:
- linux
goarch:
- amd64

archives:
-
id: default
rlcp: true
name_template: "{{ .Var.binary_name }}-v{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}-{{ .Mips }}{{ end }}"
builds:
- default
files:
- LICENSE*
- README*
- CHANGELOG*

checksum:
name_template: 'checksums.txt'

nfpms:
-
file_name_template: "{{ .Var.binary_name }}-v{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}-{{ .Mips }}{{ end }}"
vendor: jon4hz
homepage: '{{ .Var.homepage }}'
maintainer: '{{ .Var.maintainer }}'
description: '{{ .Var.description }}'
license: '{{ .Var.license }}'
formats:
- apk
- deb
- rpm

aurs:
-
name: '{{ .Var.binary_name }}-bin'
homepage: '{{ .Var.homepage }}'
description: '{{ .Var.description }}'
maintainers:
- '{{ .Var.maintainer }}'
license: '{{ .Var.license }}'
private_key: '{{ .Env.AUR_KEY }}'
git_url: 'ssh://[email protected]/{{ .Var.binary_name }}-bin.git'
package: '{{ .Var.aur_package }}'

source:
rlcp: true
enabled: true

snapshot:
name_template: "{{ incpatch .Version }}-devel"

changelog:
sort: asc
use: github
filters:
exclude:
- "^docs:"
- "^test:"
groups:
- title: 'New Features'
regexp: "^.*feat[(\\w)]*:+.*$"
order: 0
- title: 'Bug fixes'
regexp: "^.*fix[(\\w)]*:+.*$"
order: 10
- title: Others
order: 999

furies:
- account: jon4hz

brews:
-
name: '{{ .Var.binary_name }}'
tap:
owner: jon4hz
name: homebrew-tap
token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}"
commit_author:
name: jon4hz
email: [email protected]
homepage: '{{ .Var.homepage }}'
description: '{{ .Var.description }}'
install: |-
bin.install "{{ .Var.binary_name }}"

0 comments on commit 84a648c

Please sign in to comment.