From a25b3708a280eb8795c913529c9268f93de7a690 Mon Sep 17 00:00:00 2001 From: peio Date: Sun, 18 Jan 2026 17:23:51 +0000 Subject: [PATCH] add CI --- .gitea/workflows/release.yml | 52 ++++++++++++++++++++++++++++++++++++ cmd/kc-policy/main.go | 8 ++++++ 2 files changed, 60 insertions(+) create mode 100644 .gitea/workflows/release.yml diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..f09eeac --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,52 @@ +name: release + +on: + push: + tags: + - "v*" + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + goos: [linux] + arch: [amd64] # [amd64, arm64] + + steps: + - name: Checkout + uses: https://gitea.com/actions/checkout@v4 + + - name: Setup Go + uses: https://gitea.com/actions/setup-go@v5 + with: + go-version: "1.22.x" + + - name: Build (linux/musl) + env: + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.arch }} + CGO_ENABLED: "0" + VERSION: ${{ github.ref_name }} + run: | + set -eux + mkdir -p dist + BIN="kc-policy-${GOOS}-${GOARCH}" + go build \ + -trimpath \ + -ldflags="-s -w -X main.version=${VERSION}" \ + -o "dist/${BIN}" ./cmd/kc-policy + tar -C dist -czf "dist/${BIN}.tar.gz" "${BIN}" + sha256sum "dist/${BIN}.tar.gz" >> dist/checksums.txt + + - name: Upload assets to Gitea release + uses: https://gitea.com/actions/gitea-release-action@v1 + with: + files: | + dist/*.tar.gz + dist/*.sha256 + generate_release_notes: true + env: + GITEA_TOKEN: ${{ github.token }} diff --git a/cmd/kc-policy/main.go b/cmd/kc-policy/main.go index 45f91d1..6f482fe 100644 --- a/cmd/kc-policy/main.go +++ b/cmd/kc-policy/main.go @@ -2,6 +2,7 @@ package main import ( "context" + "fmt" "log" "os" "os/signal" @@ -11,7 +12,14 @@ import ( "kc-policy/internal/kcpolicy" ) +var version = "dev" + func main() { + if len(os.Args) > 1 && os.Args[1] == "--version" { + fmt.Println(version) + return + } + cfgPath := "/etc/kc-policy/config.yaml" if len(os.Args) >= 2 { cfgPath = os.Args[1]