Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
go-version: '1.24'

- name: Build
run: CGO_ENABLED=0 go build -v ./...
run: CGO_ENABLED=0 go build -v -ldflags="-X main.version=${GITHUB_SHA::7}" ./...

- name: Test
run: go test -v ./...
Expand Down Expand Up @@ -70,8 +70,9 @@ jobs:
ARCH="armv7"
fi
SUFFIX="${{ matrix.suffix }}"
go build -trimpath -ldflags="-s -w" -o "vaydns-client-${{ matrix.goos }}-${ARCH}${SUFFIX}" ./vaydns-client
go build -trimpath -ldflags="-s -w" -o "vaydns-server-${{ matrix.goos }}-${ARCH}${SUFFIX}" ./vaydns-server
VERSION="${GITHUB_SHA::7}"
go build -trimpath -ldflags="-s -w -X main.version=${VERSION}" -o "vaydns-client-${{ matrix.goos }}-${ARCH}${SUFFIX}" ./vaydns-client
go build -trimpath -ldflags="-s -w -X main.version=${VERSION}" -o "vaydns-server-${{ matrix.goos }}-${ARCH}${SUFFIX}" ./vaydns-server

- name: Upload artifacts
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -119,5 +120,6 @@ jobs:
context: .
file: Dockerfile
push: true
build-args: VERSION=dev-${{ env.SHORT_SHA }}
tags: ghcr.io/${{ github.repository }}:dev-${{ env.SHORT_SHA }}

7 changes: 5 additions & 2 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ jobs:
ARCH="armv7"
fi
SUFFIX="${{ matrix.suffix }}"
go build -trimpath -ldflags="-s -w" -o "vaydns-client-${{ matrix.goos }}-${ARCH}${SUFFIX}" ./vaydns-client
go build -trimpath -ldflags="-s -w" -o "vaydns-server-${{ matrix.goos }}-${ARCH}${SUFFIX}" ./vaydns-server
TAG="${{ needs.release-please.outputs.tag_name }}"
VERSION="${TAG#v}"
go build -trimpath -ldflags="-s -w -X main.version=${VERSION}" -o "vaydns-client-${{ matrix.goos }}-${ARCH}${SUFFIX}" ./vaydns-client
go build -trimpath -ldflags="-s -w -X main.version=${VERSION}" -o "vaydns-server-${{ matrix.goos }}-${ARCH}${SUFFIX}" ./vaydns-server
chmod +x vaydns-client-* vaydns-server-*

- name: Upload artifact
Expand Down Expand Up @@ -148,6 +150,7 @@ jobs:
context: .
file: Dockerfile
push: true
build-args: VERSION=${{ steps.version.outputs.VERSION }}
tags: |
ghcr.io/${{ github.repository }}:${{ steps.version.outputs.VERSION }}
ghcr.io/${{ github.repository }}:latest
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ COPY go.mod go.sum ./
RUN go mod download
COPY . .

RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /vaydns-server ./vaydns-server
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /vaydns-client ./vaydns-client
ARG VERSION=dev
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X main.version=${VERSION}" -o /vaydns-server ./vaydns-server
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X main.version=${VERSION}" -o /vaydns-client ./vaydns-client

FROM alpine
RUN apk add --no-cache curl
Expand Down
9 changes: 9 additions & 0 deletions vaydns-client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
log "github.com/sirupsen/logrus"
)

var version = "dev"

func readKeyFromFile(filename string) ([]byte, error) {
f, err := os.Open(filename)
if err != nil {
Expand All @@ -30,6 +32,7 @@ func readKeyFromFile(filename string) ([]byte, error) {
}

func main() {
var showVersion bool
var dohURL string
var dotAddr string
var domainArg string
Expand Down Expand Up @@ -140,8 +143,14 @@ Known TLS fingerprints for -utls are:

var logLevel string
flag.StringVar(&logLevel, "log-level", "info", "log level (debug, info, warning, error)")
flag.BoolVar(&showVersion, "v", false, "print version and exit")
flag.Parse()

if showVersion {
fmt.Println(version)
os.Exit(0)
}

level, err := log.ParseLevel(logLevel)
if err != nil {
fmt.Fprintf(os.Stderr, "invalid log level: %s\n", logLevel)
Expand Down
9 changes: 9 additions & 0 deletions vaydns-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,10 @@ func run(privkey []byte, domain dns.Name, upstream string, dnsConn net.PacketCon
return recvLoop(domain, dnsConn, ttConn, ch, fallbackMgr, stats, wireConfig)
}

var version = "dev"

func main() {
var showVersion bool
var genKey bool
var domainArg string
var upstream string
Expand Down Expand Up @@ -1250,8 +1253,14 @@ Example:

var logLevel string
flag.StringVar(&logLevel, "log-level", "info", "log level (debug, info, warning, error)")
flag.BoolVar(&showVersion, "v", false, "print version and exit")
flag.Parse()

if showVersion {
fmt.Println(version)
os.Exit(0)
}

level, err := log.ParseLevel(logLevel)
if err != nil {
fmt.Fprintf(os.Stderr, "invalid log level: %s\n", logLevel)
Expand Down
Loading