Skip to content

Commit 77e0369

Browse files
committed
Release process
1 parent 18fa83d commit 77e0369

File tree

5 files changed

+214
-31
lines changed

5 files changed

+214
-31
lines changed

.github/workflows/release.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: release
2+
3+
on:
4+
push:
5+
# run only against tags
6+
tags:
7+
- '*'
8+
9+
permissions:
10+
contents: write
11+
# packages: write
12+
# issues: write
13+
14+
jobs:
15+
release:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v5
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Fetch all tags
24+
run: git fetch --force --tags
25+
26+
- name: Set up Go
27+
uses: actions/setup-go@v6
28+
with:
29+
go-version: 1.24
30+
31+
- name: Run GoReleaser
32+
uses: goreleaser/goreleaser-action@v6
33+
with:
34+
distribution: goreleaser
35+
version: latest
36+
args: release --clean
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yaml

Lines changed: 122 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ project_name: fftools
55
before:
66
hooks:
77
- go mod tidy
8-
- ./bin/gen_manpages.sh
98

109
builds:
1110
- id: asciify
@@ -17,6 +16,13 @@ builds:
1716
- linux
1817
- windows
1918
- darwin
19+
ldflags:
20+
- -s
21+
- -w
22+
- -X main.VERSION={{.Version}}
23+
- -X main.LASTMOD={{.Timestamp}}
24+
- -X main.COMMIT={{.ShortCommit}}
25+
- -X main.BUILDER=goreleaser
2026

2127
- id: asciitable
2228
main: ./cmd/asciitable/asciitable.go
@@ -27,6 +33,13 @@ builds:
2733
- linux
2834
- windows
2935
- darwin
36+
ldflags:
37+
- -s
38+
- -w
39+
- -X main.VERSION={{.Version}}
40+
- -X main.LASTMOD={{.Timestamp}}
41+
- -X main.COMMIT={{.ShortCommit}}
42+
- -X main.BUILDER=goreleaser
3043

3144
- id: bytecount
3245
main: ./cmd/bytecount/bytecount.go
@@ -37,6 +50,13 @@ builds:
3750
- linux
3851
- windows
3952
- darwin
53+
ldflags:
54+
- -s
55+
- -w
56+
- -X main.VERSION={{.Version}}
57+
- -X main.LASTMOD={{.Timestamp}}
58+
- -X main.COMMIT={{.ShortCommit}}
59+
- -X main.BUILDER=goreleaser
4060

4161
- id: certinfo
4262
main: ./cmd/certinfo/certinfo.go
@@ -47,6 +67,30 @@ builds:
4767
- linux
4868
- windows
4969
- darwin
70+
ldflags:
71+
- -s
72+
- -w
73+
- -X main.VERSION={{.Version}}
74+
- -X main.LASTMOD={{.Timestamp}}
75+
- -X main.COMMIT={{.ShortCommit}}
76+
- -X main.BUILDER=goreleaser
77+
78+
- id: ghash
79+
main: ./cmd/ghash/ghash.go
80+
binary: ghash
81+
env:
82+
- CGO_ENABLED=0
83+
goos:
84+
- linux
85+
- windows
86+
- darwin
87+
ldflags:
88+
- -s
89+
- -w
90+
- -X main.VERSION={{.Version}}
91+
- -X main.LASTMOD={{.Timestamp}}
92+
- -X main.COMMIT={{.ShortCommit}}
93+
- -X main.BUILDER=goreleaser
5094

5195
- id: hexdumpc
5296
main: ./cmd/hexdumpc/hexdumpc.go
@@ -57,6 +101,47 @@ builds:
57101
- linux
58102
- windows
59103
- darwin
104+
ldflags:
105+
- -s
106+
- -w
107+
- -X main.VERSION={{.Version}}
108+
- -X main.LASTMOD={{.Timestamp}}
109+
- -X main.COMMIT={{.ShortCommit}}
110+
- -X main.BUILDER=goreleaser
111+
112+
- id: hosty
113+
main: ./cmd/hosty/hosty.go
114+
binary: hosty
115+
env:
116+
- CGO_ENABLED=0
117+
goos:
118+
- linux
119+
- windows
120+
- darwin
121+
ldflags:
122+
- -s
123+
- -w
124+
- -X main.VERSION={{.Version}}
125+
- -X main.LASTMOD={{.Timestamp}}
126+
- -X main.COMMIT={{.ShortCommit}}
127+
- -X main.BUILDER=goreleaser
128+
129+
- id: unhexdump
130+
main: ./cmd/unhexdump/unhexdump.go
131+
binary: unhexdump
132+
env:
133+
- CGO_ENABLED=0
134+
goos:
135+
- linux
136+
- windows
137+
- darwin
138+
ldflags:
139+
- -s
140+
- -w
141+
- -X main.VERSION={{.Version}}
142+
- -X main.LASTMOD={{.Timestamp}}
143+
- -X main.COMMIT={{.ShortCommit}}
144+
- -X main.BUILDER=goreleaser
60145

61146
- id: unicount
62147
main: ./cmd/unicount/unicount.go
@@ -67,6 +152,13 @@ builds:
67152
- linux
68153
- windows
69154
- darwin
155+
ldflags:
156+
- -s
157+
- -w
158+
- -X main.VERSION={{.Version}}
159+
- -X main.LASTMOD={{.Timestamp}}
160+
- -X main.COMMIT={{.ShortCommit}}
161+
- -X main.BUILDER=goreleaser
70162

71163
- id: uniwhat
72164
main: ./cmd/uniwhat/uniwhat.go
@@ -80,10 +172,27 @@ builds:
80172
ldflags:
81173
- -s
82174
- -w
83-
- -X github.com/FileFormatInfo/fftools/internal.VERSION={{.Version}}
84-
- -X github.com/FileFormatInfo/fftools/internal.LASTMOD={{.Timestamp}}
85-
- -X github.com/FileFormatInfo/fftools/internal.COMMIT={{.ShortCommit}}
86-
- -X github.com/FileFormatInfo/fftools/internal.BUILDER=goreleaser
175+
- -X main.VERSION={{.Version}}
176+
- -X main.LASTMOD={{.Timestamp}}
177+
- -X main.COMMIT={{.ShortCommit}}
178+
- -X main.BUILDER=goreleaser
179+
180+
- id: urly
181+
main: ./cmd/urly/urly.go
182+
binary: urly
183+
env:
184+
- CGO_ENABLED=0
185+
goos:
186+
- linux
187+
- windows
188+
- darwin
189+
ldflags:
190+
- -s
191+
- -w
192+
- -X main.VERSION={{.Version}}
193+
- -X main.LASTMOD={{.Timestamp}}
194+
- -X main.COMMIT={{.ShortCommit}}
195+
- -X main.BUILDER=goreleaser
87196

88197
archives:
89198
- formats: [tar.gz]
@@ -99,9 +208,7 @@ archives:
99208
format_overrides:
100209
- goos: windows
101210
formats: [zip]
102-
#- files:
103-
# - LICENSE.txt
104-
# - manpages/*
211+
105212

106213
homebrew_casks:
107214
- name: fftools
@@ -110,12 +217,16 @@ homebrew_casks:
110217
- asciitable
111218
- bytecount
112219
- certinfo
220+
- ghash
113221
- hexdumpc
222+
- hosty
223+
- unhexdump
114224
- unicount
115225
- uniwhat
226+
- urly
116227
# manpages:
117228
# completions:
118-
directory: pkg/cask
229+
directory: Casks
119230
skip_upload: true
120231
commit_author:
121232
name: Andrew Marcuse
@@ -140,22 +251,15 @@ nfpms:
140251
formats:
141252
- deb
142253
- rpm
143-
# - contents:
144-
# - src: ./manpages/
145-
# dst: /usr/share/man/man1/
146-
# type: dir
147-
# file_info:
148-
# mode: 0644
149-
150254

151255
report_sizes: true
152256

153257
#source:
154258
# enabled: true
155259
# name_template: "{{ .ProjectName }}.src"
156260

157-
#upx:
158-
# - enabled: true
261+
upx:
262+
- enabled: true
159263

160264
#changelog:
161265
# sort: asc

README.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
# File Format Tools [<img alt="Logo for fftools" src="docs/favicon.svg" height="96" align="right"/>](https://www.fileformat.info/)
22

33
[![build](https://github.com/FileFormatInfo/fftools/actions/workflows/build.yaml/badge.svg)](https://github.com/FileFormatInfo/fftools/actions/workflows/build.yaml)
4-
4+
[![release](https://github.com/FileFormatInfo/fftools/actions/workflows/release.yaml/badge.svg)](https://github.com/FileFormatInfo/fftools/actions/workflows/release.yaml)
55

66
## Programs
77

8-
- `asciify`: converts to ASCII using [anyascii](https://github.com/anyascii/anyascii)
9-
- `asciitable`: prints out an table of ASCII characters
10-
- `bytecount`: counts the number of occurrences of each byte
11-
- `certinfo`: print info about an x509 (aka SSL/HTTPS) certificate
12-
- `hexdumpc`: generate canonical hexdump (`hexdump -C`) output in case you don't have [`hexdump`](https://man7.org/linux/man-pages/man1/hexdump.1.html) installed
13-
- `unicount`: count Unicode codepoints in a file
14-
- `uniwhat`: print the names of each Unicode character in a file
8+
- [asciify](cmd/asciify/README.md): converts to ASCII using [anyascii](https://github.com/anyascii/anyascii)
9+
- [asciitable](cmd/asciitable/README.md): prints out an table of ASCII characters
10+
- [bytecount](cmd/bytecount/README.md): counts the number of occurrences of each byte
11+
- [certinfo](cmd/certinfo/README.md): print info about an x509 (aka SSL/HTTPS) certificate
12+
- [ghash](cmd/ghash/README.md): calculate file hashes
13+
- [hexdumpc](cmd/hexdumpc/README.md): generate canonical hexdump (`hexdump -C`) output in case you don't have [hexdump`]
14+
(https://man7.org/linux/man-pages/man1/hexdump.1.html) installed
15+
- [unhexdump](cmd/unhexdump/README.md): convert `hexdump -c` output back into binary
16+
- [unicount](cmd/unicount/README.md): count Unicode codepoints in a file
17+
- [uniwhat](cmd/uniwhat/README.md): print the names of each Unicode character in a file
18+
- [urly](cmd/urly/README.md): manipulate URLs
1519

1620
## Experiments
1721

1822
- `wombat` - tests terminal screen functions
19-
- `spinner` - terminal spinner for long-running tasks
2023

2124
## Credits
2225

@@ -25,15 +28,16 @@
2528
[![golang](https://www.vectorlogo.zone/logos/golang/golang-ar21.svg)](https://golang.org/ "Programming language")
2629
[![svgrepo](https://www.vectorlogo.zone/logos/svgrepo/svgrepo-ar21.svg)](https://www.svgrepo.com/svg/276165/gardening-tools-rake "Icon")
2730

28-
## Scripts To Do
31+
* [goreleaser](https://goreleaser.com/)
32+
33+
## To Do
2934

30-
- [ ] `ghash`: calculate various [hashes available in the Go standard library](https://pkg.go.dev/crypto#Hash)
3135
- [ ] `body`: prints specific lines of a file (in between `head` and `tail`)
36+
- [hosty](cmd/hosty/README.md): manipulate hostnames
3237
- [ ] `trilobyte`: translates bytes according to a map
3338
- [ ] `trune`: translates Unicode codepoints (runes) according to a map
3439
- [ ] `ustrings`: like the standard [`strings`](https://man7.org/linux/man-pages/man1/strings.1.html) utility, but with Unicode support
3540
- [ ] `utf8ify`: convert to UTF-8
36-
- [ ] `unhexdump`: convert the (edited) output of [`hexdump -C`](https://man7.org/linux/man-pages/man1/hexdump.1.html) back to binary
3741

3842

3943
## General

bin/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ for f in "${FILES[@]}"; do
4444
fi
4545
echo "INFO: compiling ${f} to dist directory"
4646
go build \
47-
-ldflags "-s -w -X github.com/FileFormatInfo/fftools/internal.LASTMOD=${LASTMOD} -X github.com/FileFormatInfo/fftools/internal.COMMIT=${COMMIT} -X github.com/FileFormatInfo/fftools/internal.BUILDER=build.sh" \
47+
-ldflags "-s -w -X main.LASTMOD=${LASTMOD} -X main.COMMIT=${COMMIT} -X main.BUILDER=build.sh -X main.VERSION=localdev" \
4848
-o "${DIST_DIR}/${f}" \
4949
"${REPO_DIR}/cmd/${f}"
5050
done

bin/release.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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 the latest tag from git and increment the patch version
17+
LATEST_TAG=$(git tag --sort=v:refname | tail -1)
18+
echo "INFO: Latest tag is '${LATEST_TAG}'"
19+
# if none, start at 0.1.0
20+
if [[ -z "$LATEST_TAG" ]]; then
21+
TAG="0.1.0"
22+
else
23+
IFS='.' read -r -a VERSION_PARTS <<< "$LATEST_TAG"
24+
MAJOR=${VERSION_PARTS[0]}
25+
MINOR=${VERSION_PARTS[1]}
26+
PATCH=${VERSION_PARTS[2]}
27+
PATCH=$((PATCH + 1))
28+
TAG="$MAJOR.$MINOR.$PATCH"
29+
fi
30+
fi
31+
32+
echo "INFO: Releasing version ${TAG}"
33+
34+
git tag -a "$TAG" -m "Release version ${TAG}"
35+
git push origin "$TAG"
36+
37+
echo "INFO: Completed release process at $(date -u +%Y-%m-%dT%H:%M:%SZ)"

0 commit comments

Comments
 (0)