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
34 changes: 0 additions & 34 deletions .github/workflows/release.yaml

This file was deleted.

47 changes: 47 additions & 0 deletions .github/workflows/tagpr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# .github/workflows/tagpr.yaml
name: tagpr and release
on:
push:
branches: ["master"]
workflow_dispatch:
inputs:
tag:
description: "release tag"
required: false
type: string

permissions:
pull-requests: write
packages: write
contents: write
actions: write

jobs:
tagpr:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
with:
persist-credentials: true
ref: ${{ inputs.tag || github.ref }}

- id: tagpr
uses: Songmu/tagpr@9c294c8b7b1815a5f3b7c61d6ee6aa50ac25b030 # v1
if: ${{ github.event_name != 'workflow_dispatch' }} # skip on workflow_dispatch

- name: Set up Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
with:
go-version-file: go.mod
cache: true

- name: Run Go Releaser
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6
if: ${{ steps.tagpr.outputs.tag != '' || github.event_name == 'workflow_dispatch' }}
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 changes: 12 additions & 12 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@ on:
push:
paths:
- "**.go"
- "Makefile"
- "Taskfile.yaml"
- "go.mod"
- "go.sum"
- ".github/workflows/test.yaml"
branches:
- main
- master
- feature/**

jobs:
test:
strategy:
matrix:
go:
- 1.13
- 1.14
name: Build
- "1.13"
- "1.14"
name: Test (Go ${{ matrix.go }})
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4

- name: Set up Go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v1
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
with:
go-version: ${{ matrix.go }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v1
cache: true

- name: Build & Test
run: |
make test
- name: Test
run: go test -v -race ./...
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,11 @@ go.sum
# related release files
pkg/

# GoReleaser output
dist/

vendor/
*~

CLAUDE.md
AGENTS.md
36 changes: 36 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# GoReleaser configuration for bqin
# https://goreleaser.com/

version: 2

builds:
- id: bqin
main: ./cmd/bqin
binary: bqin
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
goarch:
- amd64
- arm64
ignore:
- goos: windows
goarch: arm64
ldflags:
- -s -w
- -X main.buildDate={{.Date}}

archives:
- name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
files:
- LICENSE
- README.md

checksum:
name_template: "checksums.txt"

snapshot:
version_template: "{{ incpatch .Version }}-next"
5 changes: 5 additions & 0 deletions .tagpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[tagpr]
vPrefix = true
releaseBranch = master
versionFile = version.go
release = draft
24 changes: 0 additions & 24 deletions Makefile

This file was deleted.

145 changes: 145 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# Taskfile for bqin development
# https://taskfile.dev/

version: "3"

vars:
VERSION:
sh: git describe --tags --always --dirty 2>/dev/null || echo "dev"
BUILD_DATE:
sh: date +%Y-%m-%dT%H:%M:%S%z
BINARY: bqin
MAIN_PATH: ./cmd/bqin
LDFLAGS: -s -w -X main.version={{.VERSION}} -X main.buildDate={{.BUILD_DATE}}

Copilot AI Oct 29, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LDFLAGS references main.version, but the version variable has been removed from cmd/bqin/version.go. This will cause the linker flag to have no effect. Since the version is now sourced from bqin.Version, this linker flag should be removed or the variable should be kept for backward compatibility.

Suggested change
LDFLAGS: -s -w -X main.version={{.VERSION}} -X main.buildDate={{.BUILD_DATE}}
LDFLAGS: -s -w -X main.buildDate={{.BUILD_DATE}}

Copilot uses AI. Check for mistakes.

tasks:
default:
desc: Show available tasks
cmds:
- task -l
silent: true

deps:
desc: Download and tidy dependencies
cmds:
- go mod download
- go mod tidy

test:
desc: Run tests
cmds:
- go test -v -race -coverprofile=coverage.out ./...
sources:
- "**/*.go"
- go.mod
- go.sum

test:short:
desc: Run tests without race detector (faster)
cmds:
- go test -v ./...

coverage:
desc: Show test coverage in browser
deps: [test]
cmds:
- go tool cover -html=coverage.out

lint:
desc: Run linters (requires staticcheck)
cmds:
- go vet ./...
- staticcheck ./...
preconditions:
- sh: command -v staticcheck
msg: "staticcheck not found. Install with: go install honnef.co/go/tools/cmd/staticcheck@latest"

fmt:
desc: Format code
cmds:
- go fmt ./...

build:
desc: Build binary for current platform
cmds:
- go build -ldflags "{{.LDFLAGS}}" -o {{.BINARY}} {{.MAIN_PATH}}
sources:
- "**/*.go"
- go.mod
- go.sum
generates:
- "{{.BINARY}}"

install:
desc: Install binary to $GOPATH/bin
cmds:
- go install -ldflags "{{.LDFLAGS}}" {{.MAIN_PATH}}

clean:
desc: Clean build artifacts
cmds:
- rm -f {{.BINARY}}
- rm -f coverage.out
- rm -rf dist/
- rm -rf pkg/

run:
desc: Build and run (usage: task run -- [args])
deps: [build]
cmds:
- ./{{.BINARY}} {{.CLI_ARGS}}

goreleaser:check:
desc: Check goreleaser config
cmds:
- goreleaser check
preconditions:
- sh: command -v goreleaser
msg: "goreleaser not found. Install from: https://goreleaser.com/install/"

goreleaser:build:
desc: Build with goreleaser (snapshot)
cmds:
- goreleaser build --snapshot --clean
preconditions:
- sh: command -v goreleaser
msg: "goreleaser not found. Install from: https://goreleaser.com/install/"

goreleaser:release:
desc: Create a local release with goreleaser (for testing)
cmds:
- goreleaser release --snapshot --clean
preconditions:
- sh: command -v goreleaser
msg: "goreleaser not found. Install from: https://goreleaser.com/install/"

ci:
desc: Run all CI checks (format, lint, test)
cmds:
- task: fmt
- task: lint
- task: test

help:
desc: Show detailed help
cmds:
- |
echo "bqin development tasks"
echo ""
echo "Common tasks:"
echo " task test - Run all tests"
echo " task build - Build binary"
echo " task install - Install to GOPATH"
echo " task lint - Run linters"
echo " task ci - Run all CI checks"
echo ""
echo "Development:"
echo " task run -- [args] - Build and run with arguments"
echo " task coverage - View test coverage"
echo ""
echo "Release:"
echo " task goreleaser:check - Validate goreleaser config"
echo " task goreleaser:build - Test build with goreleaser"
echo ""
echo "For full list: task -l"
silent: true
3 changes: 2 additions & 1 deletion cmd/bqin/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"syscall"

"github.com/google/subcommands"
"github.com/kayac/bqin"
"github.com/kayac/bqin/internal/logger"
)

Expand Down Expand Up @@ -36,7 +37,7 @@ func (w *cmdWrap) Execute(ctx context.Context, f *flag.FlagSet, args ...interfac
minLevel = logger.DebugLevel
}
logger.Setup(os.Stderr, minLevel)
logger.Infof("bqin version: %s", version)
logger.Infof("bqin version: %s", bqin.Version)

return w.Command.Execute(ctx, f, args...)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/bqin/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"fmt"

"github.com/google/subcommands"
"github.com/kayac/bqin"
)

var (
version string
buildDate string
)

Expand All @@ -30,7 +30,7 @@ func (_ *versionCmd) SetFlags(_ *flag.FlagSet) {}

func (_ *versionCmd) Execute(_ context.Context, _ *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
fmt.Println("bqin is a BigQuery data importer with AWS S3 and SQS messaging.")
fmt.Println("version:", version)
fmt.Println("version:", bqin.Version)
fmt.Println("build:", buildDate)
return subcommands.ExitSuccess
}
3 changes: 3 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package bqin

var Version = "v0.3.1"
Loading