Compare commits
4 Commits
v1.0.1-bet
...
v1.0.2-bet
| Author | SHA1 | Date | |
|---|---|---|---|
| 41b3a76c3b | |||
| a9c1529f9d | |||
| 693c324eb0 | |||
| e806470b11 |
85
.gitea/workflows/build.yml
Normal file
85
.gitea/workflows/build.yml
Normal file
@@ -0,0 +1,85 @@
|
||||
name: Build (artifact)
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: https://github.com/actions/checkout@v4
|
||||
|
||||
- name: Setup Go
|
||||
uses: https://github.com/actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.25"
|
||||
|
||||
- name: Install protoc
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y protobuf-compiler
|
||||
|
||||
- name: Install Go protobuf plugins
|
||||
run: |
|
||||
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
|
||||
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
|
||||
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Read VERSION from Makefile
|
||||
shell: bash
|
||||
run: |
|
||||
VERSION="$(awk -F':=' '/^VERSION[[:space:]]*:=/ {gsub(/[[:space:]]/,"",$2); print $2; exit}' Makefile)"
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo "Failed to read VERSION from Makefile" >&2
|
||||
exit 1
|
||||
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.zip
|
||||
path: certman-${{ env.VERSION }}-amd64
|
||||
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"
|
||||
8
Makefile
8
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
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
@@ -13,13 +12,6 @@ import (
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
var (
|
||||
tls = flag.Bool("tls", false, "Connection uses TLS if true, else plain TCP")
|
||||
caFile = flag.String("ca_file", "", "The file containing the CA root cert file")
|
||||
serverAddr = flag.String("addr", "localhost:50051", "The server address in the format of host:port")
|
||||
serverHostOverride = flag.String("server_host_override", "x.test.example.com", "The server name used to verify the hostname returned by the TLS handshake")
|
||||
)
|
||||
|
||||
func SendHook(domain string) {
|
||||
conn, err := grpc.NewClient(
|
||||
"unix:///run/certman.sock",
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -98,14 +98,9 @@ func LoadConfig() error {
|
||||
return err
|
||||
}
|
||||
|
||||
switch config.GetString("App.mode") {
|
||||
case "server":
|
||||
if config.GetString("App.mode") == "server" {
|
||||
config.SetConfigType("toml")
|
||||
config.SetConfigFile("server.conf")
|
||||
return config.MergeInConfig()
|
||||
case "Client":
|
||||
config.SetConfigType("toml")
|
||||
config.SetConfigFile("Client.conf")
|
||||
config.SetConfigFile("/etc/certman/server.conf")
|
||||
return config.MergeInConfig()
|
||||
}
|
||||
|
||||
@@ -168,12 +163,8 @@ func WriteConfig(filePath string, config *viper.Viper) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func WriteMainConfig() error {
|
||||
return WriteConfig("/etc/certman/certman.conf", config)
|
||||
}
|
||||
|
||||
func WriteDomainConfig(config *viper.Viper) error {
|
||||
return WriteConfig(config.GetString("Domain.domain_name"), config)
|
||||
return WriteConfig(filepath.Join("/etc/certman/domains", config.GetString("Domain.domain_name")+".conf"), config)
|
||||
}
|
||||
|
||||
// SaveDomainConfigs writes every loaded domain config back to disk.
|
||||
|
||||
Reference in New Issue
Block a user