From 125b73289adcdd8688739ea08ac11b9de355be65 Mon Sep 17 00:00:00 2001 From: Hein Date: Wed, 8 Apr 2026 11:29:50 +0200 Subject: [PATCH] chore(ci): add GitHub Actions workflow for release process * Implement test and release jobs for versioned tags * Build binaries for multiple OS/architecture targets * Create release and upload assets to GitHub * Add release-version target in Makefile for version bumping --- .gitea/workflows/release.yml | 57 ++++++++++++++++++++++++++++++++++++ .vscode/launch.json | 16 ++++++++++ Makefile | 14 ++++++++- 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 .gitea/workflows/release.yml create mode 100644 .vscode/launch.json diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..094338f --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,57 @@ +name: Release + +on: + push: + tags: + - 'v*' + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + - name: Test + run: go test ./... + + - name: Lint + run: go vet ./... + + release: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + - name: Build release binaries + run: | + VERSION="${GITHUB_REF_NAME}" + for target in "linux/amd64" "linux/arm64" "darwin/amd64" "darwin/arm64" "windows/amd64"; do + GOOS="${target%/*}" + GOARCH="${target#*/}" + EXT="" + [ "$GOOS" = "windows" ] && EXT=".exe" + NAME="unitdore-${GOOS}-${GOARCH}${EXT}" + GOOS="$GOOS" GOARCH="$GOARCH" go build \ + -ldflags "-X main.version=${VERSION}" \ + -o "$NAME" . + echo "Built $NAME" + done + + - name: Create release and upload assets + uses: softprops/action-gh-release@v2 + with: + files: unitdore-* + generate_release_notes: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..e4819ed --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + + { + "name": "Launch Package", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "${workspaceFolder}" + } + ] +} \ No newline at end of file diff --git a/Makefile b/Makefile index c6c78ed..a3187d1 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ CONFIG_DIR := /etc/unitdore VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev") LDFLAGS := -ldflags "-X main.version=$(VERSION)" -.PHONY: all build install uninstall test lint clean +.PHONY: all build install uninstall test lint clean release-version all: build @@ -40,6 +40,18 @@ lint: clean: rm -f $(BINARY) +## release-version: bump patch version, tag, and push to trigger release workflow +release-version: + @CURRENT=$$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0"); \ + MAJOR=$$(echo $$CURRENT | sed 's/v\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1/'); \ + MINOR=$$(echo $$CURRENT | sed 's/v\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\2/'); \ + PATCH=$$(echo $$CURRENT | sed 's/v\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\3/'); \ + NEXT="v$$MAJOR.$$MINOR.$$((PATCH + 1))"; \ + echo "Current: $$CURRENT → Next: $$NEXT"; \ + git tag -a "$$NEXT" -m "Release $$NEXT"; \ + git push origin "$$NEXT"; \ + echo "Pushed tag $$NEXT — release workflow triggered" + ## help: show this help help: @grep -E '^## ' Makefile | sed 's/## / /'