Commit f45d017b81

f45d017b81f927dba0f8e84c8713bb5aec9b6918

parent: 9dd3f26ae5

Verified · cmc ci/build: success ci/lint: success ci/test: success

cmc <hello@cleberg.net> · 2026-09-11 14:39 UTC

Add a Makefile and attach binaries to releases

make build, test, lint and dist; dist cross-compiles embed-tag tarballs
for linux, darwin and freebsd with a SHA256SUMS file. The release
workflow builds them in the Go image and uploads them to the GitHub
release of the tag.

Closes #34

Layout: unified · split

.github/workflows/release.yml +25
@@ -73,3 +73,28 @@ jobs:
73 subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} 73 subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
74 subject-digest: ${{ steps.build.outputs.digest }} 74 subject-digest: ${{ steps.build.outputs.digest }}
75 push-to-registry: true 75 push-to-registry: true
76
77 # Binaries for people who do not run the container. The tarballs are built
78 # in the official Go image so no extra action is pinned, and attached to a
79 # GitHub release of the tag with the CLI the runner already has.
80 binaries:
81 if: startsWith(github.ref, 'refs/tags/v')
82 runs-on: ubuntu-latest
83 permissions:
84 contents: write
85 steps:
86 - name: Checkout
87 uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
88 with:
89 fetch-depth: 0
90
91 - name: Build tarballs
92 run: docker run --rm -v "$PWD":/src -w /src -e VERSION="${GITHUB_REF_NAME#v}" golang:1.25 make dist
93
94 - name: Attach to the release
95 env:
96 GH_TOKEN: ${{ github.token }}
97 run: |
98 gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1 || gh release create "$GITHUB_REF_NAME" --generate-notes
99 gh release upload "$GITHUB_REF_NAME" dist/*.tar.gz dist/SHA256SUMS --clobber
100
.gitignore +1
@@ -3,4 +3,5 @@
3**/config.json 3**/config.json
4**/skunkyart 4**/skunkyart
5**/skunkyart-* 5**/skunkyart-*
6dist
6**/.env 7**/.env
Makefile added +39
@@ -0,0 +1,39 @@
1# Build, test and package SkunkyArt. VERSION comes from the nearest tag so a
2# local build reports the same version a release of that commit would.
3
4VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null | sed 's/^v//')
5LDFLAGS = -s -w -X main.version=$(VERSION)
6GOFLAGS = -trimpath
7LINT = github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.13.2
8
9# os/arch pairs packaged by `make dist`.
10PLATFORMS = linux/amd64 linux/arm64 darwin/arm64 freebsd/amd64
11
12.PHONY: build test lint dist clean
13
14build:
15 CGO_ENABLED=0 go build $(GOFLAGS) -tags embed -ldflags "$(LDFLAGS)" -o skunkyart .
16
17test:
18 go test ./... -race -count=1
19
20lint:
21 go run $(LINT) run ./...
22
23# One tar.gz per platform under dist/, each holding the embed-tag binary,
24# the example config and the docs, with a checksum file beside them.
25dist:
26 rm -rf dist && mkdir -p dist
27 set -e; for p in $(PLATFORMS); do \
28 os=$${p%/*}; arch=$${p#*/}; dir=dist/skunkyart-$(VERSION)-$$os-$$arch; \
29 mkdir -p $$dir; \
30 CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch go build $(GOFLAGS) -tags embed -ldflags "$(LDFLAGS)" -o $$dir/skunkyart .; \
31 cp config.example.json README.org SETUP.md API.md LICENSE $$dir/; \
32 cp -r services $$dir/; \
33 tar -C dist -czf $$dir.tar.gz $$(basename $$dir); \
34 rm -r $$dir; \
35 done
36 cd dist && shasum -a 256 *.tar.gz > SHA256SUMS
37
38clean:
39 rm -rf dist skunkyart
README.org +12 −1
@@ -39,7 +39,18 @@ go build -tags embed -ldflags "-w -s"
39#+end_src 39#+end_src
40 40
41that build reports its version as dev. stamp one in with ~-X 41that build reports its version as dev. stamp one in with ~-X
42main.version=<version>~, as the release workflow does from the git tag. 42main.version=<version>~, as the release workflow does from the git tag. or let
43the makefile do both:
44
45#+begin_src sh
46make build # embed tag, version from git describe
47make test
48make lint
49make dist # tarballs for linux, darwin and freebsd under dist/
50#+end_src
51
52release tags also get those tarballs attached on the github mirror's release
53page.
43 54
44* run 55* run
45without docker: put the binary (and ~static/~, unless built with the embed 56without docker: put the binary (and ~static/~, unless built with the embed