Skip to content

Commit

Permalink
chore: run stencil
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredallard committed Jul 31, 2024
1 parent 4c06615 commit 33d98e1
Show file tree
Hide file tree
Showing 22 changed files with 310 additions and 168 deletions.
3 changes: 1 addition & 2 deletions .github/settings.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Documentation can be found at:
# https://github.com/repository-settings/app/blob/master/docs/configuration.md
_extends: jaredallard/jaredallard:settings.yml

## <<Stencil::Block(custom)>>

## <</Stencil::Block>>
## <</Stencil::Block>>
70 changes: 55 additions & 15 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,38 @@ name: release

on:
# Only run when triggered through the Github UI or API.
workflow_dispatch: {}
workflow_dispatch:
inputs:
rc:
description: "Build a release candidate instead of a stable release"
required: false
default: false
type: boolean
version:
description: "Set a specific version to release, defaults to automatic versioning based on conventional commits"
required: false
default: ""
type: string

permissions:
contents: write
packages: write
issues: write
# Used by attestations in the release workflow.
id-token: write
attestations: write

concurrency:
group: remarkabledayone-release-${{ github.head_ref }}
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

jobs:
release:
runs-on: ubuntu-latest
steps:
## <<Stencil::Block(releaseSetup)>>

## <</Stencil::Block>>
- uses: actions/checkout@v4
with:
fetch-depth: 0
Expand All @@ -26,6 +43,19 @@ jobs:
experimental: true
env:
GH_TOKEN: ${{ github.token }}
- name: Get Go directories
id: go
run: |
echo "cache_dir=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
echo "mod_cache_dir=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
- uses: actions/cache@v4
with:
path: ${{ steps.go.outputs.cache_dir }}
key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }}
- uses: actions/cache@v4
with:
path: ${{ steps.go.outputs.mod_cache_dir }}
key: ${{ runner.os }}-go-mod-cache-${{ hashFiles('go.sum') }}
- name: Retrieve goreleaser version
run: |-
echo "version=$(mise current goreleaser)" >> "$GITHUB_OUTPUT"
Expand All @@ -36,28 +66,38 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: fregante/setup-git-user@v2
- name: Set up git user
uses: fregante/setup-git-user@v2
- name: Download syft (SBOM)
uses: anchore/sbom-action/download-syft@v0.17.0

# Bumping logic
- name: Get next version
id: next_version
uses: thenativeweb/get-next-version@main
with:
prefix: "v" # optional, defaults to ''
- name: Wait for manual approval
uses: trstringer/manual-approval@v1
with:
secret: ${{ secrets.GITHUB_TOKEN }}
approvers: "jaredallard"
issue-title: "Release ${{ steps.next_version.outputs.version }}"
env:
BUILD_RC: ${{ github.event.inputs.rc }}
VERSION_OVERRIDE: ${{ github.event.inputs.version }}
run: |-
echo "version=$(./.github/scripts/get-next-version.sh)" >> "$GITHUB_OUTPUT"
- name: Create Tag
run: |-
git tag -a "${{ steps.next_version.outputs.version }}" -m "Release ${{ steps.next_version.outputs.version }}"
- name: Generate CHANGELOG
run: |-
mise run changelog-release
- name: Create release artifacts and Github Release
uses: goreleaser/goreleaser-action@v5
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: v${{ steps.goreleaser.outputs.version }}
args: release --clean
args: release --release-notes CHANGELOG.md --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
## <<Stencil::Block(goreleaseEnvVars)>>

## <</Stencil::Block>>
- uses: actions/attest-build-provenance@v1
with:
# We attest all generated _archives_ because those are what we
# upload to Github Releases.
subject-path: dist/remarkabledayone_*.*, dist/checksums.txt
23 changes: 18 additions & 5 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ name: tests
on:
push:
branches:
-
- main
pull_request:

permissions:
contents: read

concurrency:
group: remarkabledayone-build-${{ github.head_ref }}
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

jobs:
Expand All @@ -23,13 +23,26 @@ jobs:
experimental: true
env:
GH_TOKEN: ${{ github.token }}
- name: Get Go directories
id: go
run: |
echo "cache_dir=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
echo "mod_cache_dir=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
- uses: actions/cache@v4
with:
path: ${{ steps.go.outputs.cache_dir }}
key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }}
- uses: actions/cache@v4
with:
path: ${{ steps.go.outputs.mod_cache_dir }}
key: ${{ runner.os }}-go-mod-cache-${{ hashFiles('go.sum') }}
- name: Download dependencies
run: go mod download
- name: Run go test
run: |
gotestsum -- -coverprofile=cover.out ./...
- name: Upload test coverage
uses: codecov/codecov-action@v4.3.0
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./cover.out
Expand All @@ -50,7 +63,7 @@ jobs:
echo "version=$(mise current golangci-lint)" >> "$GITHUB_OUTPUT"
id: golangci_lint
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v6
with:
version: v${{ steps.golangci_lint.outputs.version }}
args: --timeout=30m
args: --timeout=30m
48 changes: 45 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Editor files
*.swp
*~
\#*\#
.idea/*
TAGS
*.sublime-project
*.sublime-workspace
.\#*
.dir-locals.el

# Test binary, build with "go test -c"
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Log files
*.log

# Releases and other binaries
bin/
dist/
.env.*
!.env.development
.state.yml
.dist/

# Don't. Commit. Vendor. Or other package manager dep directories
node_modules
vendor

# macOS
.DS_Store

# Task local state
.task

# VSCode debugger launch configs
launch.json

# Currently a build artifact
CHANGELOG.md
66 changes: 28 additions & 38 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,50 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
version: 2
project_name: remarkabledayone
before:
hooks:
- go mod tidy
report_sizes: true
metadata:
mod_timestamp: "{{ .CommitTimestamp }}"
builds:
- main: ./cmd/{{ .ProjectName }}
- main: ./cmd/remarkabledayone
flags:
- -trimpath
ldflags:
- -s
- -w
## <<Stencil::Block(remarkabledayoneLdflags)>>

## <</Stencil::Block>>
env:
- CGO_ENABLED=0
goarch:
- amd64
- arm64
## <<Stencil::Block(remarkabledayoneExtraArch)>>

## <</Stencil::Block>>
goos:
- linux
- darwin
archives:
- format: tar.xz
- windows
## <<Stencil::Block(remarkabledayoneExtraOS)>>

## <</Stencil::Block>>
ignore:
- goos: windows
goarch: arm
mod_timestamp: "{{ .CommitTimestamp }}"
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
use: git
release:
prerelease: "auto"
footer: |-
**Full Changelog**: https://github.com/jaredallard/remarkabledayone/compare/{{ .PreviousTag }}...{{ .Tag }}
## <<Stencil::Block(extraReleaseOpts)>>
brews:
- commit_author:
name: GitHub Actions
Expand All @@ -42,34 +62,4 @@ brews:
owner: jaredallard
name: homebrew-tap
token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN}}"
changelog:
sort: asc
use: git
filters:
exclude:
- "^test:"
- "^chore:"
- "merge conflict"
- Merge pull request
- Merge remote-tracking branch
- Merge branch
- go mod tidy
groups:
- title: Dependency updates
regexp: "^.*(feat|chore|fix)\\(deps\\)*:+.*$"
order: 300
- title: "New Features"
regexp: "^.*feat[(\\w)]*:+.*$"
order: 100
- title: "Bug fixes"
regexp: "^.*fix[(\\w)]*:+.*$"
order: 200
- title: "Documentation updates"
regexp: "^.*docs[(\\w)]*:+.*$"
order: 400
- title: Other work
order: 9999

release:
footer: |-
**Full Changelog**: https://github.com/jaredallard/remarkabledayone/compare/{{ .PreviousTag }}...{{ .Tag }}
## <</Stencil::Block>>
43 changes: 29 additions & 14 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -1,35 +1,50 @@

# Default versions of tools, to update these, set [tools.override]
[tools]
bun = "latest"
git-cliff = "latest"
golang = "1.22"
shfmt = "3"
golangci-lint = "1.56"
golangci-lint = "1.59"
goreleaser = "latest"
"go:gotest.tools/gotestsum" = "v1.11.0"
"go:gotest.tools/gotestsum" = "v1.12.0"
"go:golang.org/x/tools/cmd/goimports" = "latest"
"go:mvdan.cc/sh/v3/cmd/shfmt" = "latest"
"go:github.com/thenativeweb/get-next-version" = "latest"

[tasks.build]
description = "Build a binary for the current platform/architecture"
run = "go build -trimpath -o ./bin/ -v ./cmd/..."

[tasks.test]
description = "Run tests"
run = "gotestsum"

[tasks.lint]
description = "Run linters"
run = "golangci-lint run"
[tasks.changelog]
description = "Generate a changelog for the current version"
outputs = ["CHANGELOG.md"]
run = ["git-cliff --config .cliff.toml --output CHANGELOG.md"]

[tasks.fmt]
alias = "format"
description = "Format code"
run = [
"go mod tidy",
"gofmt -s -w .",
"goimports -w .",
"shfmt -w -i 2 -ci -sr .",
"go mod tidy",
"gofmt -s -w .",
"goimports -w .",
"shfmt -w .",
"bun node_modules/.bin/prettier --write '**/*.{json,yaml,yml,md,jsonschema.json}'",
]

[tasks.lint]
description = "Run linters"
run = "golangci-lint run"

[tasks.next-version]
description = """Get the version number that would be released if a release was ran right now.
Pass --rc to get the next release candidate version.
"""
run = ["./.github/scripts/get-next-version.sh"]

[tasks.test]
description = "Run tests"
run = "gotestsum"

## <<Stencil::Block(custom)>>
[tasks.run]
description = "Run the binary"
Expand Down
Loading

0 comments on commit 33d98e1

Please sign in to comment.