Skip to content

Commit bef6981

Browse files
committed
Tweaks for homebrew
1 parent e9b7fea commit bef6981

File tree

11 files changed

+124
-38
lines changed

11 files changed

+124
-38
lines changed

.github/actions/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ echo "INFO: building"
2525
go build \
2626
-a \
2727
-trimpath \
28-
-ldflags "-s -w -extldflags '-static' -X github.com/FileFormatInfo/fflint/cmd.COMMIT=$GITHUB_SHA -X github.com/FileFormatInfo/fflint/cmd.LASTMOD=$LASTMOD -X github.com/FileFormatInfo/fflint/cmd.VERSION=$VERSION" \
28+
-ldflags "-s -w -extldflags '-static' -X main.COMMIT=$GITHUB_SHA -X main.LASTMOD=$LASTMOD -X main.VERSION=$VERSION -X main.BUILTBY=build.sh" \
2929
-installsuffix cgo \
3030
-tags netgo \
3131
-o "${APP_HOME}/dist/fflint" \

.github/workflows/build.yaml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ name: build
22

33
on:
44
push:
5-
exclude:
6-
- 'v*'
75
ignore:
86
- 'docs/**'
97
- '.github/**'
108
- '*.sh'
119
- '*.md'
10+
tags-ignore:
11+
- '**'
12+
1213
workflow_dispatch:
1314

1415
jobs:
@@ -21,13 +22,9 @@ jobs:
2122
fetch-depth: 0
2223

2324
- name: Setup Go
24-
uses: actions/setup-go@v4
25+
uses: actions/setup-go@v6
2526
with:
26-
go-version: 1.21
27+
go-version: 1.24
2728

28-
- name: GoReleaser Build
29-
uses: goreleaser/goreleaser-action@v5
30-
with:
31-
distribution: goreleaser
32-
version: latest
33-
args: build --snapshot --single-target
29+
- name: Build
30+
run: go build -o fflint ./cmd/fflint/main.go

.github/workflows/release.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,24 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- name: Checkout
19-
uses: actions/checkout@v4
19+
uses: actions/checkout@v5
2020
with:
2121
fetch-depth: 0
2222

2323
- name: Fetch all tags
2424
run: git fetch --force --tags
2525

2626
- name: Set up Go
27-
uses: actions/setup-go@v4
27+
uses: actions/setup-go@v6
2828
with:
29-
go-version: 1.21
29+
go-version: 1.24
3030

3131
- name: Run GoReleaser
32-
uses: goreleaser/goreleaser-action@v5
32+
uses: goreleaser/goreleaser-action@v7
3333
with:
3434
distribution: goreleaser
3535
version: latest
3636
args: release --clean
3737
env:
3838
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
HOMEBREW_TOKEN: ${{ secrets.HOMEBREW_TOKEN }}

.goreleaser.yaml

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# This is an example .goreleaser.yml file with some sensible defaults.
2-
# Make sure to check the documentation at https://goreleaser.com
1+
version: 2
2+
33
before:
44
hooks:
55
- go mod tidy
@@ -11,15 +11,20 @@ builds:
1111
- env:
1212
- CGO_ENABLED=0
1313
ldflags:
14-
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser
14+
- -s
15+
- -w
16+
- -X main.VERSION={{.Version}}
17+
- -X main.LASTMOD={{.Timestamp}}
18+
- -X main.COMMIT={{.ShortCommit}}
19+
- -X main.BUILTBY=goreleaser
1520
main: ./cmd/fflint/main.go
1621
goos:
1722
- linux
1823
- windows
1924
- darwin
2025

2126
archives:
22-
- format: tar.gz
27+
- formats: [ tar.gz ]
2328
# this name template makes the OS and Arch compatible with the results of uname.
2429
name_template: >-
2530
{{ .ProjectName }}_
@@ -30,20 +35,67 @@ archives:
3035
{{- if .Arm }}v{{ .Arm }}{{ end }}
3136
# use zip for windows archives
3237
format_overrides:
33-
- goos: windows
34-
format: zip
38+
- goos: windows
39+
formats: [ zip ]
40+
files:
41+
- src: README.md
42+
info:
43+
owner: root
44+
group: root
45+
mtime: "{{ .CommitDate }}"
46+
- src: LICENSE.txt
47+
info:
48+
owner: root
49+
group: root
50+
mtime: "{{ .CommitDate }}"
51+
- src: completions/*
52+
info:
53+
owner: root
54+
group: root
55+
mtime: "{{ .CommitDate }}"
56+
- src: manpages/*
57+
info:
58+
owner: root
59+
group: root
60+
mtime: "{{ .CommitDate }}"
61+
3562
checksum:
3663
name_template: 'checksums.txt'
64+
3765
snapshot:
38-
name_template: "{{ incpatch .Version }}-next"
66+
version_template: "{{ incpatch .Version }}-next"
67+
3968
changelog:
4069
sort: asc
4170
filters:
4271
exclude:
4372
- '^docs:'
4473
- '^test:'
4574

46-
# The lines beneath this are called `modelines`. See `:help modeline`
47-
# Feel free to remove those if you don't want/use them.
48-
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
49-
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
75+
homebrew_casks:
76+
- name: fflint
77+
binaries:
78+
- fflint
79+
manpages:
80+
- manpages/fflint.1.gz
81+
completions:
82+
bash: completions/fflint.bash
83+
zsh: completions/fflint.zsh
84+
fish: completions/fflint.fish
85+
directory: Casks
86+
skip_upload: false
87+
description: "File formt linter"
88+
homepage: "https://www.fflint.dev/"
89+
license: "MIT"
90+
repository:
91+
owner: FileFormatInfo
92+
name: homebrew-tap
93+
branch: main
94+
token: "{{ .Env.HOMEBREW_TOKEN }}"
95+
hooks:
96+
post:
97+
install: |
98+
if OS.mac?
99+
system_command "/usr/bin/xattr", args: ["-dr", "com.apple.quarantine", "#{staged_path}/fflint"]
100+
end
101+

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023-2024 Andrew Marcuse
3+
Copyright (c) 2023-2026 Andrew Marcuse
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
File renamed without changes.

bin/manpages.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ rm -rf "${MANPAGES_DIR}"
1717
mkdir "${MANPAGES_DIR}"
1818

1919
echo "INFO: generating manpages"
20-
go run "${REPO_HOME}/cmd/mangen" man
21-
#| gzip -c -9 >"${MANPAGES_DIR}/fflint.1.gz"
20+
go run "${REPO_HOME}/cmd/mangen" man \
21+
| gzip -c -9 >"${MANPAGES_DIR}/fflint.1.gz"
2222

2323
echo "INFO: manpages complete at $(date -u +%Y-%m-%dT%H:%M:%SZ)"

bin/release.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
#
3+
# make a new release by pushing a new tag to git
4+
#
5+
6+
set -o errexit
7+
set -o pipefail
8+
set -o nounset
9+
10+
echo "INFO: Starting release process at $(date -u +%Y-%m-%dT%H:%M:%SZ)"
11+
12+
TAG=${1:-DEFAULT}
13+
14+
if [[ "$TAG" == "DEFAULT" ]]; then
15+
echo "INFO: No tag provided, calculating next version based on git tags"
16+
# get tags from remote
17+
git fetch --tags
18+
# get the latest tag from git and increment the patch version
19+
LATEST_TAG=$(git tag --sort=v:refname | tail -1)
20+
echo "INFO: Latest tag is '${LATEST_TAG}'"
21+
# if none, start at 0.1.0
22+
if [[ -z "$LATEST_TAG" ]]; then
23+
TAG="0.1.0"
24+
else
25+
IFS='.' read -r -a VERSION_PARTS <<< "$LATEST_TAG"
26+
MAJOR=${VERSION_PARTS[0]}
27+
MINOR=${VERSION_PARTS[1]}
28+
PATCH=${VERSION_PARTS[2]}
29+
PATCH=$((PATCH + 1))
30+
TAG="$MAJOR.$MINOR.$PATCH"
31+
fi
32+
fi
33+
34+
echo "INFO: Releasing version ${TAG}"
35+
36+
git tag -a "$TAG" -m "Release version ${TAG}"
37+
git push origin "$TAG"
38+
39+
echo "INFO: Completed release process at $(date -u +%Y-%m-%dT%H:%M:%SZ)"

cmd/fflint/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ import (
1010
)
1111

1212
var (
13-
version = "0.0.0"
14-
commit = "local"
15-
date = "local"
16-
builtBy = "unknown"
13+
VERSION = "0.0.0"
14+
COMMIT = "local"
15+
LASTMOD = "local"
16+
BUILTBY = "unknown"
1717
)
1818

1919
func main() {
2020
var rootCmd = &cobra.Command{
2121
Use: "fflint",
2222
Short: "A linter to make sure your files are valid",
2323
Long: `See [www.fflint.dev](https://www.fflint.dev/) for detailed instructions`,
24-
Version: version,
24+
Version: VERSION,
2525
SilenceErrors: true,
2626
SilenceUsage: true,
2727
}
@@ -30,7 +30,7 @@ func main() {
3030
shared.AddCommon(rootCmd)
3131

3232
command.AddAllCommands(rootCmd)
33-
command.AddVersionCommand(rootCmd, command.VersionInfo{Commit: commit, Version: version, LastMod: date, Builder: builtBy})
33+
command.AddVersionCommand(rootCmd, command.VersionInfo{Commit: COMMIT, Version: VERSION, LastMod: LASTMOD, Builder: BUILTBY})
3434

3535
if err := rootCmd.Execute(); err != nil {
3636
fmt.Fprintf(os.Stderr, "ERROR: %v\n", err.Error())

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ require (
99
github.com/adrg/frontmatter v0.2.0
1010
github.com/antchfx/xmlquery v1.4.4
1111
github.com/bmatcuk/doublestar/v4 v4.8.1
12-
github.com/cevaris/ordered_map v0.0.0-20220813181356-34664b69742b
1312
github.com/cheggaaa/pb/v3 v3.1.7
1413
github.com/gorilla/sessions v1.4.0
1514
github.com/mattn/go-isatty v0.0.20

0 commit comments

Comments
 (0)