How mathieudutour/github-tag-action works
Project Type & Purpose
• Type: Open-source GitHub Action (Node.js / TypeScript)
• Purpose: On merge to a release branch, compute next SemVer version, tag the commit, generate a changelog, and expose outputs for downstream steps (e.g., GitHub Release).
File Structure
• Top‐level:
• action.yml – defines inputs/outputs, entrypoint
• src/ – core TypeScript modules
• tests/ – unit tests for logic
• docs/ – publishing instructions
• src modules:
• main.ts – orchestrates the action’s lifecycle
• action.ts – reads inputs, calls core logic
• github.ts – wraps GitHub REST API calls (fetch tags, create tag)
• ts.ts – Semantic-versioning logic
• utils.ts & defaults.ts – helper functions and default settings
Extract Key Components
• GitHub Actions Runner (hosted Ubuntu, Node.js runtime)
• Action Entrypoint (compiled JavaScript from main.ts)
• Core Logic Modules:
• Input Parser (action.ts)
• Version Calculator (ts.ts + defaults.ts)
• GitHub API Client (github.ts)
• Utilities (utils.ts)
• External Systems: GitHub REST API
• Outputs: New tag name, previous tag, changelog, etc.
Relationships & Data Flows
• Runner → Entrypoint (main.js invoked by action.yml)
• Entrypoint calls Input Parser → passes parameters to Version Calculator
• Version Calculator consults GitHub API Client to fetch existing tags
• Calculator computes next version & changelog via semantic rules
• GitHub API Client creates a new tag reference in the repo
• Action returns outputs to the workflow
Architectural Patterns
• Modular design: separation of concerns (I/O, logic, HTTP calls)
• Single‐process, event-driven flow
• Use of conventional semantic-release conventions for versioning
• Component boundaries (modules vs. external)
• Data stores: Git tags on GitHub