From 41b3a76c3b2ad18a2f9f11a7f62472def174c9dc Mon Sep 17 00:00:00 2001 From: Steven Tracey Date: Sun, 8 Mar 2026 22:45:49 +0100 Subject: [PATCH] Added release on build, fixed subdomains with new toml configs, and added trimmed build target --- .gitea/workflows/build.yml | 39 ++++++++++++++++++++++++++++++++++++-- Makefile | 8 ++++++-- internal/acme_manager.go | 3 +-- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 562a63e..55b11f9 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -39,12 +39,47 @@ jobs: fi echo "VERSION=$VERSION" >> $GITHUB_ENV + - name: Get latest commit message + run: echo "COMMIT_MSG=$(git log -1 --pretty=%s)" >> $GITHUB_ENV + - name: Build run: make build - name: Upload artifact uses: https://github.com/actions/upload-artifact@v3 with: - name: certman-${{ env.VERSION }}-amd64 + name: certman-${{ env.VERSION }}-amd64.zip path: certman-${{ env.VERSION }}-amd64 - if-no-files-found: error \ No newline at end of file + if-no-files-found: error + + - name: Create release and upload binary + run: | + # Create the release + RELEASE_RESPONSE=$(curl --fail --silent --show-error \ + -X POST \ + -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ + -H "Content-Type: application/json" \ + -d '{ + "tag_name": "v${{ env.VERSION }}", + "name": "v${{ env.VERSION }}", + "body": "${{ env.COMMIT_MSG }}", + "draft": false, + "prerelease": false + }' \ + "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases") + + # Extract the release ID + RELEASE_ID=$(echo "$RELEASE_RESPONSE" | jq -r '.id') + if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = "null" ]; then + echo "Failed to create release" >&2 + echo "$RELEASE_RESPONSE" >&2 + exit 1 + fi + + # Upload the binary as a release attachment + curl --fail --silent --show-error \ + -X POST \ + -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ + -H "Content-Type: application/octet-stream" \ + --upload-file "certman-${{ env.VERSION }}-amd64" \ + "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/$RELEASE_ID/assets?name=certman-${{ env.VERSION }}-amd64" \ No newline at end of file diff --git a/Makefile b/Makefile index 2c5e7a4..953f626 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION := 1.0.1-beta +VERSION := 1.0.2-beta BUILD := $(shell git rev-parse --short HEAD) GO := go @@ -6,13 +6,17 @@ GO := go BUILD_FLAGS := -buildmode=pie -trimpath LDFLAGS := -linkmode=external -extldflags="-Wl,-z,relro,-z,now" -X git.nevets.tech/Keys/CertManager/internal.Version=$(VERSION) -X git.nevets.tech/Keys/CertManager/internal.Build=$(BUILD) -.PHONY: proto build stage +.PHONY: proto build debug stage proto: @protoc --go_out=./proto --go-grpc_out=./proto proto/hook.proto @protoc --go_out=./proto --go-grpc_out=./proto proto/symlink.proto build: proto + $(GO) build $(BUILD_FLAGS) -ldflags="-s -w $(LDFLAGS)" -o ./certman . + @cp ./certman ./certman-$(VERSION)-amd64 + +debug: proto $(GO) build $(BUILD_FLAGS) -ldflags="$(LDFLAGS)" -o ./certman . @cp ./certman ./certman-$(VERSION)-amd64 diff --git a/internal/acme_manager.go b/internal/acme_manager.go index 0e8740e..d5c3232 100644 --- a/internal/acme_manager.go +++ b/internal/acme_manager.go @@ -259,8 +259,7 @@ func buildDomainRuntimeConfig(domainKey string) (*DomainRuntimeConfig, error) { requestMethod := domainCfg.GetString("Certificates.request_method") - subdomains := domainCfg.GetString("Certificates.subdomains") - subdomainArray := parseCSVLines(subdomains) + subdomainArray := domainCfg.GetStringSlice("Certificates.subdomains") return &DomainRuntimeConfig{ DomainName: domainName,