From f8b3e70fbfda421d4a01fa5d834db4afdf1bca09 Mon Sep 17 00:00:00 2001 From: Tim Tattersall Date: Fri, 24 Oct 2025 00:38:53 +1100 Subject: [PATCH 1/2] feat: add version flag to cli --- .github/workflows/ci.yml | 22 +++++++++++++++++++++- cmd/cmd.go | 8 ++++++++ internal/sift/interactive_view.go | 2 ++ internal/sift/version.go | 3 +++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 internal/sift/version.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 270734c..124638b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,8 @@ on: push: tags: - 'v*' + branches: + - main pull_request: paths-ignore: - '*.md' @@ -35,7 +37,25 @@ jobs: make test make vet - - uses: goreleaser/goreleaser-action@v6 + - name: tag release + if: github.ref == 'refs/heads/main' + run: | + VERSION=$(go run . --version) + + if git rev-parse "$TAG" >/dev/null 2>&1; then + echo "Tag $TAG already exists, skipping release" + else + echo "Creating new tag and release for $TAG" + git config user.name github-actions + git config user.email github-actions@github.com + git tag "$TAG" + git push origin "$TAG" + fi + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: create release + uses: goreleaser/goreleaser-action@v6 if: success() && startsWith(github.ref, 'refs/tags/') with: version: latest diff --git a/cmd/cmd.go b/cmd/cmd.go index 2206ed2..452b7e2 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -2,6 +2,8 @@ package cmd import ( "context" + "fmt" + "os" "github.com/timtatt/sift/internal/sift" ) @@ -10,11 +12,17 @@ type CLI struct { Debug bool `name:"debug" short:"d" help:"enable debug view"` RawLogs bool `name:"raw" short:"r" help:"disable prettified logs"` NonInteractive bool `name:"non-interactive" short:"n" help:"disable interactive mode"` + Version bool `name:"version" short:"v" help:"print version"` } func (c *CLI) Run() error { ctx := context.Background() + if c.Version { + fmt.Print(sift.Version) + os.Exit(0) + } + return sift.Run(ctx, sift.SiftOptions{ Debug: c.Debug, NonInteractive: c.NonInteractive, diff --git a/internal/sift/interactive_view.go b/internal/sift/interactive_view.go index 3ac344c..e457c7e 100644 --- a/internal/sift/interactive_view.go +++ b/internal/sift/interactive_view.go @@ -20,6 +20,8 @@ func (m *siftModel) interactiveView() string { header += styleSecondary.Render(" [AUTO TOGGLE MODE]") } + header += " " + lipgloss.NewStyle().Foreground(colorMutedBlue).Render(Version) + if m.opts.Debug { header += fmt.Sprintf(" cursor: [%d, %d] %d | yoffset: %d, bottom %d", m.cursor.test, m.cursor.log, m.GetCursorPos(), m.viewport.YOffset, m.viewport.YOffset+m.viewport.Height) diff --git a/internal/sift/version.go b/internal/sift/version.go new file mode 100644 index 0000000..010b831 --- /dev/null +++ b/internal/sift/version.go @@ -0,0 +1,3 @@ +package sift + +var Version = "v0.11.0" From 38db5dc2d76f768952d955b336686f4b205703be Mon Sep 17 00:00:00 2001 From: Tim Tattersall Date: Fri, 24 Oct 2025 00:40:51 +1100 Subject: [PATCH 2/2] chore: split release and ci workflow --- .github/workflows/ci.yml | 9 --------- .github/workflows/release.yml | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 124638b..8a40289 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,12 +53,3 @@ jobs: fi env: GITHUB_TOKEN: ${{ github.token }} - - - name: create release - uses: goreleaser/goreleaser-action@v6 - if: success() && startsWith(github.ref, 'refs/tags/') - with: - version: latest - args: release --clean - env: - GITHUB_TOKEN: ${{ github.token }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7c2cb3a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,33 @@ +name: Release +on: + push: + tags: + - 'v*' + +permissions: + contents: write + packages: write + + +jobs: + release: + runs-on: ubuntu-latest + steps: + + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - uses: actions/setup-go@v4 + with: + go-version: 1.25 + cache: true + + - name: create release + uses: goreleaser/goreleaser-action@v6 + if: success() && startsWith(github.ref, 'refs/tags/') + with: + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ github.token }}