diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..742adb8 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,6 @@ +name: lint +on: [push, pull_request, workflow_dispatch] + +jobs: + lint: + uses: jon4hz/meta/.github/workflows/lint.yml@master diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..5fcc722 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 }} diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..365530a --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,121 @@ +--- +variables: + main: "." + binary_name: "gmotd" + description: "a configurable, dynamic motd generator" + github_url: "https://github.com/jon4hz/gmotd" + maintainer: "jonah " + 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://aur@aur.archlinux.org/{{ .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: me@jon4hz.io + homepage: '{{ .Var.homepage }}' + description: '{{ .Var.description }}' + install: |- + bin.install "{{ .Var.binary_name }}"