diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 270734c..8a40289 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,10 +37,19 @@ jobs: make test make vet - - uses: goreleaser/goreleaser-action@v6 - if: success() && startsWith(github.ref, 'refs/tags/') - with: - version: latest - args: release --clean + - 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 }} 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 }} 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"