Skip to content

About

Automatically update major version tags (v1, v1.2) to latest semver release in Go

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Major Tag Action

Continuous Integration License: MIT Latest Tag Top Language GitHub Marketplace

A Go-based GitHub Action that automatically updates major (and optionally minor) version tags to point to the latest semver release. For example, when you release v1.2.3, this action updates the v1 tag to point to the same commit.


Features

  • Automatically extract and update major version tags (e.g., v1.2.3 -> v1)
  • Optionally update minor version tags (e.g., v1.2.3 -> v1.2)
  • Support for both GitHub token and SSH key authentication
  • Lightweight Go-based Docker container
  • Outputs major tag, minor tag, and commit SHA

For detailed usage examples, authentication options, and troubleshooting, see the Usage Guide.


Usage


Basic

steps:
  - name: Checkout
    uses: actions/checkout@v6
    with:
      fetch-depth: 0

  - name: Update major version tag
    uses: somaz94/major-tag-action@v1
    with:
      tag: ${{ github.ref_name }}
      github_token: ${{ secrets.PAT_TOKEN }}

In Release Workflow

name: Create release

on:
  push:
    tags:
      - "v[0-9]+.[0-9]+.[0-9]+"

permissions:
  contents: write

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0

      - name: Create GitHub release
        uses: softprops/action-gh-release@v2
        with:
          tag_name: ${{ github.ref_name }}

      - name: Update major version tag
        uses: somaz94/major-tag-action@v1
        with:
          tag: ${{ github.ref_name }}
          github_token: ${{ secrets.PAT_TOKEN }}

With Minor Tag

- name: Update major and minor version tags
  uses: somaz94/major-tag-action@v1
  with:
    tag: ${{ github.ref_name }}
    github_token: ${{ secrets.PAT_TOKEN }}
    major_only: false

This updates both v1 and v1.2 for a v1.2.3 release.


With SSH Key

- name: Update major version tag via SSH
  uses: somaz94/major-tag-action@v1
  with:
    tag: ${{ github.ref_name }}
    ssh_key: ${{ secrets.SSH_PRIVATE_KEY }}

The key needs push access to the repository, for example as a deploy key with write access. When ssh_key is set, the action points origin at [email protected]:<owner>/<repo>.git and verifies the host against GitHub's published SSH host keys, so the checkout step can stay on HTTPS.


Inputs

Input Description Required Default
tag The full semver tag (e.g., v1.2.3) Yes -
github_token GitHub token for pushing tags No ${{ github.token }}
ssh_key SSH private key (alternative to token) No ``
major_only Only update major tag. Set false to also update minor tag No true

Outputs

Output Description Example
major_tag The major version tag updated v1
minor_tag The minor version tag updated (empty if major_only: true) v1.2
commit_sha The commit SHA the tags point to abc123def456

Why?

GitHub Actions users reference actions by major version (e.g., uses: owner/action@v1). When you release v1.2.3, the v1 tag needs to be updated so users automatically get the latest patch. This action automates that process, replacing the common shell script pattern found in most release workflows.


Project Structure

.
├── cmd/
│   └── main.go              # Entry point
├── internal/
│   ├── config/
│   │   ├── config.go        # Configuration from env vars
│   │   └── config_test.go
│   ├── output/
│   │   ├── output.go        # GitHub Actions output helpers
│   │   └── output_test.go
│   └── tagger/
│       ├── errors.go        # Sentinel errors
│       ├── git.go           # GitRunner interface and git operations
│       ├── tagger.go        # Tagger struct and tag update logic
│       └── tagger_test.go
├── action.yml
├── Dockerfile
├── Makefile
└── go.mod

Development


Prerequisites

  • Go (the version in go.mod)
  • Docker (for container builds)

Build

make build

Test

make test

Coverage

make cover

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.


License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Automatically update major version tags (v1, v1.2) to latest semver release in Go

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages