Skip to content

✨ Add GitHub Action for flopha version tagging#14

Open
sjquant wants to merge 15 commits intomainfrom
claude/github-action-version-tagging-R9FUP
Open

✨ Add GitHub Action for flopha version tagging#14
sjquant wants to merge 15 commits intomainfrom
claude/github-action-version-tagging-R9FUP

Conversation

@sjquant
Copy link
Copy Markdown
Owner

@sjquant sjquant commented May 3, 2026

Summary

This PR introduces a GitHub Action wrapper for flopha, enabling automated semantic versioning and tag creation based on conventional commits within GitHub workflows.

Key Changes

  • action.yml: New GitHub Action definition that:

    • Wraps the flopha CLI tool for automated version bumping
    • Supports multiple input parameters: auto (conventional commit detection), increment (manual bump level), pattern (tag format), pre (pre-release channel), rule (custom bump rules), and github-token
    • Handles cross-platform binary installation (Linux x86_64, macOS x86_64, macOS arm64)
    • Fetches full git history and tags before version detection
    • Configures git user for tag creation and pushes the new tag to origin
    • Outputs the created tag for downstream workflow steps
  • .github/workflows/tag-action.yml: New workflow that:

    • Automatically updates a floating v1 tag on published releases (excluding pre-releases)
    • Enables users to reference the action as owner/repo@v1 for the latest stable version

Notable Implementation Details

  • The action uses git fetch --unshallow with error suppression to handle both shallow and full clones
  • Platform detection uses uname to determine the correct binary target
  • Input parameters are passed to flopha via environment variables and conditionally added to the command arguments
  • The workflow uses actions/checkout@v4 with explicit ref targeting to ensure correct tag context

https://claude.ai/code/session_017tUnFZgkNcbdN8LAS9vsRL

claude added 2 commits May 3, 2026 10:33
- composite action installs the pre-built binary — no Rust toolchain needed
- auto-tags on push to main via `uses: sjquant/flopha@v1`
- tag-action.yml keeps the floating v1 tag pointing at each stable release

https://claude.ai/code/session_017tUnFZgkNcbdN8LAS9vsRL
- add `version` input to pin the flopha binary version
- add `dry-run` input to preview the next tag without pushing
- emit actionable error with permissions hint on push failure
- use `git config --local` to avoid polluting global git config
- narrow tag-action.yml permissions to job level
- add comment on when to bump floating tag from v1 → v2
- mention Windows-not-supported in platform error message

https://claude.ai/code/session_017tUnFZgkNcbdN8LAS9vsRL
@sjquant sjquant force-pushed the claude/github-action-version-tagging-R9FUP branch from 82a6b24 to 437fd8e Compare May 3, 2026 10:34
@sjquant sjquant changed the title Add GitHub Action for flopha version tagging ✨ Add GitHub Action for flopha version tagging May 3, 2026
claude added 13 commits May 3, 2026 11:31
The floating v1 tag can be updated manually during the release process.
No need for a dedicated workflow.

https://claude.ai/code/session_017tUnFZgkNcbdN8LAS9vsRL
Scripts:
- action/install.sh  — binary download, version-pinnable, clear platform errors
- action/run.sh      — tag creation, push, optional GitHub Release via gh CLI

New action inputs:
- create-release     — create a GitHub Release for the new tag
- draft              — create the release as a draft
- release-title      — custom release title (defaults to tag name)
- release-body       — custom release body (overrides generate-release-notes)
- generate-release-notes — auto-generate notes via GitHub API (default: true)
- version            — pin the flopha binary version

New action outputs:
- version            — bare semver extracted from the tag (e.g. 1.2.3 from v1.2.3)
- release-url        — URL of the created GitHub Release

Test env (.github/workflows/test-action.yml):
- dry-run (auto)     — asserts tag/version outputs match semver
- dry-run (pattern)  — asserts custom pattern is applied
- dry-run (pre)      — asserts pre-release suffix is present
- install (ubuntu + macos) — verifies binary installs and runs
- install (pinned)   — verifies version-pinned install

https://claude.ai/code/session_017tUnFZgkNcbdN8LAS9vsRL
- Install to \$HOME/.flopha/bin instead of /usr/local/bin (no root
  needed on Linux runners); chmod +x after extraction; add to GITHUB_PATH
- Replace grep -oP (unavailable on macOS BSD grep) with bash parameter
  expansion for bare version extraction
- Fix dry-run-pattern test: repo has no release-X.Y.Z tags so flopha
  returned "No version found"; replaced with manual minor-bump test
  against existing v* tags, asserting patch resets to 0

https://claude.ai/code/session_017tUnFZgkNcbdN8LAS9vsRL
- install.sh: skip download if flopha already on PATH (allows test
  workflow to inject a source-built binary via artifact)
- run.sh: explicitly export PATH to \$HOME/.flopha/bin so flopha is
  always found without relying on \$GITHUB_PATH propagation between
  composite-action steps
- Cargo.toml: bump to 0.3.0 so the release on merge ships the binary
  with --auto / --pre / --rule support
- test-action.yml: add build job that compiles from source and uploads
  an artifact; dry-run jobs download that artifact and pre-place it at
  \$HOME/.flopha/bin so install.sh skips the download and the tests run
  against the actual current code

https://claude.ai/code/session_017tUnFZgkNcbdN8LAS9vsRL
Users can now pass any regex directly via `major-pattern` and
`minor-pattern` instead of being locked to conventional commits.
Priority: `rule` > `major/minor-pattern` > built-in defaults.
A new dry-run-pattern CI job validates the inputs end-to-end.

https://claude.ai/code/session_017tUnFZgkNcbdN8LAS9vsRL
Blocking fixes:
- install.sh: detect download failures (temp file + curl --fail)
- run.sh: capture git push stderr; delete local tag on push failure
- run.sh: separate release error output from RELEASE_URL variable
- action.yml: pass TAG via env var in extract-version step (shell injection)

Other improvements:
- Rename version input to flopha-version (avoids shadowing version output)
- Warn when increment is ignored with auto: true
- Document that major/minor-pattern replaces both built-in defaults
- Add permissions: contents: read to all test jobs
- Add dry-run-rule CI job to test multiline rule input
- Annotate install-pinned version pin with explanatory comment
- Add comprehensive GitHub Action section to README

https://claude.ai/code/session_017tUnFZgkNcbdN8LAS9vsRL
Explicitly setting permissions: contents: read drops the default
actions: read scope, which actions/download-artifact@v4 needs to
locate artifacts from other jobs. All 5 dry-run jobs were failing.

https://claude.ai/code/session_017tUnFZgkNcbdN8LAS9vsRL
- generate-release-notes defaults to false (opt-in, not opt-out)
- install.sh: don't log "flopha flopha X.Y.Z" (avoid double prefix)
- install.sh: mkdir -p BIN_DIR before appending to GITHUB_PATH on
  skip path, so subsequent steps don't get a missing-dir on PATH

https://claude.ai/code/session_017tUnFZgkNcbdN8LAS9vsRL
Without this step, install.sh inside the composite action can't find
the source-built binary (not yet on PATH), falls through to download
the latest release, and overwrites the artifact with an older binary
that lacks --auto/--pre/--rule support, causing all dry-run jobs to fail.

https://claude.ai/code/session_017tUnFZgkNcbdN8LAS9vsRL
The previous implementation relied on regex::escape escaping {} in a
specific way, then unescaping the placeholders. This chain could produce
wrong regexes (duplicate capture group names) depending on the regex
crate version or input.

Replace with a sentinel approach: substitute placeholders with \x01-
delimited sentinels before escaping (so regex::escape never touches
them), then swap sentinels for the actual capture groups afterward.

https://claude.ai/code/session_017tUnFZgkNcbdN8LAS9vsRL
CARGO_INCREMENTAL=0 forces cargo to relink from object files each run,
preventing Swatinem/rust-cache from serving a compiled versioning.rs
that pre-dates the get_regex sentinel fix.

https://claude.ai/code/session_017tUnFZgkNcbdN8LAS9vsRL
Bash finds the first } in a \${VAR:-default} expression as the closing
brace of the expansion, regardless of nesting. So:

  \${INPUT_PATTERN:-v{major}.{minor}.{patch}}

closes at the } after 'major', and .{minor}.{patch}} is appended as
literal text, corrupting the pattern to:

  v{major}.{minor}.{patch}.{minor}.{patch}}

Since action.yml provides defaults for every input, INPUT_* vars are
always set — replace all \${VAR:-default} forms with plain \$VAR.

https://claude.ai/code/session_017tUnFZgkNcbdN8LAS9vsRL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants