chore: add support for build automation ()

This PR seeks to solve .

It adds a Makefile that can build, test, lint and package the code and the Forgejo workflows needed to automate the build. In addition, it resolves various issues highlighted by the linter.

Reviewed-on: 
Co-authored-by: Emmanuel BENOÎT <tseeker@nocternity.net>
Co-committed-by: Emmanuel BENOÎT <tseeker@nocternity.net>
This commit is contained in:
Emmanuel BENOîT 2024-07-26 14:07:46 +02:00 committed by Emmanuel BENOîT
parent 36850a0650
commit 3b7757b1d9
16 changed files with 1533 additions and 25 deletions
.forgejo/workflows

View file

@ -0,0 +1,52 @@
name: Build and upload project release
on:
create:
tags: [ v* ]
jobs:
release:
runs-on: debian-12
if: startsWith(github.ref, 'refs/tags/v')
steps:
-
name: Checkout repo
uses: actions/checkout@v4
-
name: Extract Go version
id: go-version
run: |
sed '/^go /!d; s/go /version=/' go.mod >>"$GITHUB_OUTPUT"
-
name: Extract release notes
id: release-notes
run: |
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
TAG_DATA="$(git tag -l --format '%(contents:body)' "${GITHUB_REF#refs/tags/}")"
TAG_DATA="${TAG_DATA//'%'/'%25'}"
TAG_DATA="${TAG_DATA//$'\n'/'%0A'}"
TAG_DATA="${TAG_DATA//$'\r'/'%0D'}"
echo "::set-output name=content::${TAG_DATA}"
-
name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ steps.go-version.outputs.version }}
-
name: Run tests
run: |
make test
-
name: Build binaries
run: |
make dist-all
-
name: Upload release
uses: actions/forgejo-release@v1
with:
direction: upload
name: binaries
release-dir: dist/release
release-notes: ${{ steps.release-notes.outputs.content }}
token: ${{ secrets.FORGEJO_TOKEN }}

View file

@ -0,0 +1,65 @@
name: Run tests and linters
on:
push:
branches: [master]
pull_request:
jobs:
test:
runs-on: debian-12
steps:
-
name: Checkout repo
uses: actions/checkout@v4
-
name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache-dependency-path: |
go.sum
tools/go.sum
-
name: Run tests
run: |
make test
lint:
runs-on: debian-12
steps:
-
name: Checkout repo
uses: actions/checkout@v4
-
name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache-dependency-path: |
go.sum
tools/go.sum
-
name: Run linters
run: |
make lint
build:
runs-on: debian-12
steps:
-
name: Checkout repo
uses: actions/checkout@v4
-
name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache-dependency-path: |
go.sum
tools/go.sum
-
name: Build binaries
run: |
make build