chore: scaffold the module, tooling and release config

This commit is contained in:
tgiachi 2026-11-15 09:41:05 +01:00
commit 704214c6c4
9 changed files with 6133 additions and 0 deletions

25
Makefile Normal file
View file

@ -0,0 +1,25 @@
# SPDX-License-Identifier: GPL-3.0-or-later
GO ?= go
MODULE := git.kmalloc.org/squid/motorino
VERSION ?= dev
LDFLAGS := -s -w -X $(MODULE)/internal/version.value=$(VERSION)
.PHONY: check build dist
# check runs the formatter check, the vet, staticcheck and the tests.
check:
@test -z "$$(gofmt -l .)" || { echo "gofmt needed on:"; gofmt -l .; exit 1; }
$(GO) vet ./...
staticcheck ./...
$(GO) test ./...
# build compiles a local binary into bin/motorino.
build:
$(GO) build -trimpath -ldflags "$(LDFLAGS)" -o bin/motorino ./cmd/motorino
# dist compiles the release binary for the server and writes its SHA-256.
dist:
mkdir -p dist
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -trimpath -ldflags "$(LDFLAGS)" -o dist/motorino-linux-amd64 ./cmd/motorino
cd dist && sha256sum motorino-linux-amd64 > motorino-linux-amd64.sha256

65
README.md Normal file
View file

@ -0,0 +1,65 @@
# motorino
The static site generator of [kmalloc.org](https://kmalloc.org/). It turns Markdown pages, news, templates and language files into plain HTML with no JavaScript. It is made for that one site and is not a general-purpose generator.
Licence: GPL-3.0-or-later, see `LICENSE`.
## Usage
```
motorino build -site DIR -out DIR build the site in DIR into the output folder (defaults: . and public)
motorino version print the version
```
The binary is a single static Go program. The version comes from semantic-release.
## What a site looks like
```
site.json shared strings (contact, addresses, base_url), the language list, the assets
lang/<lang>.json menu, footer and other interface strings of one language
content/<lang>/**/*.md the pages; index.md is the home of a folder
news/<name>.md the news, one file each
templates/**/*.html the page chrome, the layouts, the news post and category page
static/style.css the stylesheet, inlined in every page
```
The first language in `site.json` is the default and lives at the root of the site; the others live under `/<lang>/`.
### Header
Every page and every news file starts with lines of `Key: value`, ended by a line that holds a single `-`. The body is Markdown, and raw HTML is allowed in it.
News:
```
Title: GNU/Linux Day 2026
Author: Matteo Bini
Date: 2026-09-18T17:00:45+0200
Categories: Linux Day, FLUG
Description: An optional one-line summary.
-
The text of the news.
```
A news file `news/name.md` is published as `/news/YYYY/MM/name.html`, with the year and the month of `Date` as written. Every category gets a page, `/news/category/<name>.html`.
Pages: `Title`, `ID` (the same in every language, it links the translations), `Description`, and optionally `Layout` (`page`, `bare` or `manifesto`), `Note` and `Switch`.
### Placeholders
`{{name}}`, with lowercase letters, digits and underscores, is replaced by a string from `site.json` or the language file. An unknown placeholder stops the build and names the file. `{{news_list}}`, `{{latest_news}}` and `{{categories_list}}` stand alone in a paragraph and expand to generated lists.
## Development
```
make check gofmt, go vet, staticcheck and the tests
make build a local binary in bin/motorino
make dist the release binary and its SHA-256 in dist/
```
Go code has a doc comment on every package and declaration, and is formatted with `gofmt`. Commits follow conventional commits.
## Release
semantic-release is run by hand from a clean `main`: `npm run release:dry`, then `npm run release`. It tags `vX.Y.Z`, updates `CHANGELOG.md`, builds the `linux/amd64` binary and publishes it, with its SHA-256, as a release on this repository. The site deploy pins a version and checks the hash before it runs the binary.

22
cmd/motorino/main.go Normal file
View file

@ -0,0 +1,22 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Command motorino builds the kmalloc.org site from Markdown, templates and
// language files.
package main
import (
"fmt"
"os"
"git.kmalloc.org/squid/motorino/internal/version"
)
// main runs the command line and exits with its status code.
func main() {
if len(os.Args) > 1 && os.Args[1] == "version" {
fmt.Println("motorino", version.String())
return
}
fmt.Fprintln(os.Stderr, "usage: motorino version")
os.Exit(2)
}

3
go.mod Normal file
View file

@ -0,0 +1,3 @@
module git.kmalloc.org/squid/motorino
go 1.27

View file

@ -0,0 +1,18 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Package version holds the version of the motorino binary.
//
// The release build stamps the value with
//
// -ldflags "-X git.kmalloc.org/squid/motorino/internal/version.value=1.2.3"
//
// and an unstamped build reports "dev".
package version
// value is the version stamped by the linker; it stays "dev" for local builds.
var value = "dev"
// String returns the version of this build.
func String() string {
return value
}

View file

@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-3.0-or-later
package version
import "testing"
// TestString checks that an unstamped build reports the development version.
func TestString(t *testing.T) {
if got := String(); got != "dev" {
t.Fatalf("String() = %q, want %q", got, "dev")
}
}

5925
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

20
package.json Normal file
View file

@ -0,0 +1,20 @@
{
"name": "motorino",
"version": "0.0.0",
"private": true,
"description": "Release tooling of motorino. The generator itself is Go: see the Makefile.",
"license": "GPL-3.0-or-later",
"scripts": {
"release": "semantic-release --no-ci",
"release:dry": "semantic-release --no-ci --dry-run"
},
"devDependencies": {
"@semantic-release/changelog": "7.0.0",
"@semantic-release/commit-analyzer": "13.0.1",
"@semantic-release/exec": "7.1.0",
"@semantic-release/git": "11.0.1",
"@semantic-release/release-notes-generator": "14.1.1",
"conventional-changelog-conventionalcommits": "9.3.1",
"semantic-release": "25.0.9"
}
}

43
release.config.mjs Normal file
View file

@ -0,0 +1,43 @@
/**
* semantic-release: the version comes from the conventional commits on main.
* feat is a minor release, fix and perf are patches, a breaking change is a major one.
* The result is the tag vX.Y.Z, CHANGELOG.md, and a Forgejo release with the linux/amd64 binary
* and its SHA-256 (built by `make dist`, uploaded by scripts/publish-release.sh).
* Run it by hand from a clean main with `npm run release` (`npm run release:dry` first shows what it would do).
*/
export default {
branches: ['main'],
tagFormat: 'v${version}',
plugins: [
[
'@semantic-release/commit-analyzer',
{
preset: 'conventionalcommits',
// The breaking rule comes first: a custom rule list replaces the defaults, and `feat!:` would otherwise match `feat`.
releaseRules: [
{ breaking: true, release: 'major' },
{ type: 'feat', release: 'minor' },
{ type: 'fix', release: 'patch' },
{ type: 'perf', release: 'patch' },
{ type: 'revert', release: 'patch' },
],
},
],
['@semantic-release/release-notes-generator', { preset: 'conventionalcommits' }],
['@semantic-release/changelog', { changelogFile: 'CHANGELOG.md' }],
[
'@semantic-release/git',
{
assets: ['CHANGELOG.md'],
message: 'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}',
},
],
[
'@semantic-release/exec',
{
prepareCmd: 'make dist VERSION=${nextRelease.version}',
publishCmd: 'scripts/publish-release.sh ${nextRelease.version}',
},
],
],
};