Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automation checks for tags and improve version output #108

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
36 changes: 36 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build on Tag Push

on:
push:
tags:
- "v*" # Matches any tag

jobs:
build:
name: Build and Release
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.22"

- name: Install dependencies
run: go mod download

- name: Build binary
run: |
go build -o timescaledb-parallel-copy cmd/timescaledb-parallel-copy/main.go

- name: Test version
run: |
TAG_NAME=${{ github.ref_name }}
OUTPUT=$(./timescaledb-parallel-copy --version)
echo "$OUTPUT"

# Check if the version output contains the Git tag
echo "$OUTPUT" | grep "$TAG_NAME" || (echo "Version output does not contain the Git tag: $TAG_NAME" && exit 1)
10 changes: 9 additions & 1 deletion cmd/timescaledb-parallel-copy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"log"
"os"
"runtime"
"runtime/debug"
"time"

"github.com/timescale/timescaledb-parallel-copy/pkg/csvcopy"
Expand Down Expand Up @@ -92,7 +93,14 @@ func (l csvCopierLogger) Infof(msg string, args ...interface{}) {

func main() {
if showVersion {
log.Printf("%s %s (%s %s)\n", binName, version, runtime.GOOS, runtime.GOARCH)
buildInfo, ok := debug.ReadBuildInfo()
if ok {
for _, s := range buildInfo.Settings {
log.Printf("\t%s: %s\n", s.Key, s.Value)
}
}

log.Printf("%s %s [%s] (%s %s)\n", binName, version, runtime.Version(), runtime.GOOS, runtime.GOARCH)
os.Exit(0)
}

Expand Down
Loading