Giter Site home page Giter Site logo

cbrgm / semver-bump-action Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 71 KB

Stable and fast action to automatically bump the given semver version up.

Home Page: https://cbrgm.net

License: Apache License 2.0

Makefile 25.32% Go 67.72% Nix 6.95%
bump github semver version action gihub-actions go

semver-bump-action's Introduction

Semver Bump Action

Automatically bump the given semver version up.

GitHub release Go Report Card go-lint-test go-binaries container

Inputs

current-version

Required - The semantic version (semver) that needs to be bumped. For example, 1.2.3.

bump-level

Required - Specifies the semver bump level. Allowed values:

  • major - Increments the major version (e.g., 1.2.3 to 2.0.0).
  • minor - Increments the minor version (e.g., 1.2.3 to 1.3.0).
  • patch - Increments the patch version (e.g., 1.2.3 to 1.2.4).
  • premajor - Creates a premajor prerelease (e.g., 1.2.3 to 2.0.0-alpha.0).
  • preminor - Creates a preminor prerelease (e.g., 1.2.3 to 1.3.0-alpha.0).
  • prepatch - Creates a prepatch prerelease (e.g., 1.2.3 to 1.2.4-alpha.0).
  • prerelease - Increments an existing prerelease or creates a new one (e.g., 1.2.3-alpha.0 to 1.2.3-alpha.1).

prerelease-tag

Required - The tag to use for prereleases (e.g., alpha, beta). For example, specifying alpha in combination with bump-level as prerelease will result in versions like 1.2.3-alpha.0.

Outputs

new_version

The bumped semantic version. For example, if current-version is 1.2.3 and bump-level is minor, new_version will be 1.3.0.

Workflow Usage

Add the following step to your GitHub Actions Workflow:

name: Demo Workflow

on:
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Get Latest Tag
        id: current
        run: |
          latest_tag="v1.0.0"
          echo "latest_tag=$latest_tag" >> $GITHUB_ENV

      - name: Bump Minor Version
        id: bump
        uses: cbrgm/semver-bump-action@main
        with:
          current-version: ${{ env.latest_tag }}
          bump-level: minor

      - name: Output
        run: |
          new_tag=${{ steps.bump.outputs.new_version }}
          echo $new_tag
          echo $new_tag

Example: Bump + Publish Minor Version Tag

name: Publish Tag

on:
  workflow_dispatch:
    inputs:
      bump-level:
        required: true
        type: choice
        description: 'The semver bump level'
        options:
          - 'major'
          - 'minor'
          - 'patch'
          - 'premajor'
          - 'preminor'
          - 'prepatch'
          - 'prerelease'
        default: 'patch'

      prerelease-tag:
        required: false
        description: 'The tag to use for prereleases'
        default: 'alpha'

jobs:
  publish-tag:
    runs-on: ubuntu-latest
    steps:

      - name: Checkout
        uses: actions/checkout@v4
        with:
          ssh-key: "${{ secrets.COMMIT_KEY }}"

      - name: Get Latest Tag
        id: current
        run: |
          git fetch --tags
          latest_tag=$(git tag --sort=taggerdate | tail -n 1)
          echo "current version is: $latest_tag"
          echo "latest_tag=$latest_tag" >> $GITHUB_ENV

      - name: Bump Version
        id: bump
        uses: cbrgm/semver-bump-action@main
        with:
          current-version: ${{ env.latest_tag }}
          bump-level: ${{ github.event.inputs.bump-level }}
          prerelease-tag: ${{ github.event.inputs.prerelease-tag }}

      - name: Publish Tag
        run: |
          git fetch --tags
          latest_tag=$(git tag --sort=taggerdate | tail -n 1)
          new_tag=${{ steps.bump.outputs.new_version }}
          if [[ $(git rev-list $latest_tag..HEAD --count) -gt 0 ]]; then
            git config user.name "GitHub Actions"
            git config user.email "[email protected]"
            git tag $new_tag
            git push origin $new_tag
          else
            echo "No new commits since last tag. Skipping tag push."
          fi

Local Development

You can build this action from source using Go:

make build

Contributing & License

We welcome and value your contributions to this project! ๐Ÿ‘ If you're interested in making improvements or adding features, please refer to our Contributing Guide. This guide provides comprehensive instructions on how to submit changes, set up your development environment, and more.

Please note that this project is developed in my spare time and is available for free ๐Ÿ•’๐Ÿ’ป. As an open-source initiative, it is governed by the Apache 2.0 License. This license outlines your rights and obligations when using, modifying, and distributing this software.

Your involvement, whether it's through code contributions, suggestions, or feedback, is crucial for the ongoing improvement and success of this project. Together, we can ensure it remains a useful and well-maintained resource for everyone ๐ŸŒ.

semver-bump-action's People

Contributors

cbrgm avatar renovate[bot] avatar dependabot[bot] avatar github-actions[bot] avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.