Giter Site home page Giter Site logo

semver-tags's Introduction

semver-tags

This action is designed to be used with CI/CD pipelines that automatically increment the version of the application.

Inputs

GITHUB_TOKEN required

The github token.

tag-prefix

A value prefixed to the version number when tagging the repo.

Default value ''

default-version

The version number that will be used if no semver tag is found.

Default value '1.0.0'

incremented-value

What value should be incremented.

Allowed values 'major'|'minor'|'patch'

Default value 'patch'

create-release

A value to set whether to create a release along with the tag. If the value is a branch name, then a release is created if value equals the name of branch that triggered the workflow.

Allowed values true|false|branch_name

Default value true

prerelease

The prerelease tag that will be used in the semver version number.

metadata

The metadata tag that will be used in the semver version number.

previous-major-version

A value to use for the major version when searching for the previous version tag.

previous-minor-version

A value to use for the minor version when searching for the previous version tag.

previous-prerelease

A value to use for the prerelease value when searching for the previous version tag.

previous-metadata

A value to use for the metadata value when searching for the previous version tag.

add-minor-tag

Adds/updates a tag for the major.minor version.

Default value false

add-major-tag

Adds/updates a tag for the major version.

Default value false

dry-run

The prerelease tag that will be used in the semver version number.

Default value false

Outputs

previous-version

The previous version number.

core-version

The core version part of the semantic version.

major-version

The major version part of the semantic version.

minor-version

The minor version part of the semantic version.

patch-version

The patch version part of the semantic version.

semantic-version

The calculated version number.

Example usage

uses: SOLIDSoftworks/semver-tags@v1
with:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
  tag-prefix: 'v'
  default-version: '0.0.1'
  prerelease: 'alpha'

semver-tags's People

Contributors

dependabot[bot] avatar gislikonrad avatar github-actions[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

semver-tags's Issues

define prerelease based on branch

Hi! Great work! Your GitHub action helped me a lot.

Still, I'm trying to implement a workflow where all pushes outside of main branch create ...-alpha tags and pushes to main branch creates the usual semver tag.

What I tried:

env:
  PRERELEASE: false

jobs:
    self_tag:
      runs-on: ubuntu-latest
      steps:
        - name: Checkout
          uses: actions/checkout@v3

        - name: add prerelease variable
          if: ${{ github.ref != 'refs/heads/main' }}
          run: echo "PRERELEASE=alpha" >> $GITHUB_ENV

        - name: add tag
          uses: SOLIDSoftworks/semver-tags@v1
          with:
            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
            tag-prefix: 'v'
            default-version: '1.0.0'
            prerelease: ${{ env.PRERELEASE }}
            create-release: main
            add-minor-tag: true
            add-major-tag: true

Github Action Stdout is

Run SOLIDSoftworks/semver-tags@v1
  with:
    GITHUB_TOKEN: ***
    tag-prefix: v
    default-version: 1.0.0
    prerelease: false
    create-release: main
    add-minor-tag: true
    add-major-tag: true
    incremented-value: patch
    dry-run: false
  env:
    PRERELEASE: false
....
....
Creating new release tag: v1.0.2-false
Release is a prerelease. Skipping major tag...
Release is a prerelease. Skipping minor tag...

and if I removing

env:
  PRERELEASE: false

then stdout is:

  with:
    GITHUB_TOKEN: ***
    tag-prefix: v
    default-version: 1.0.0
    prerelease: $
    add-minor-tag: true
    add-major-tag: true
    incremented-value: patch
    create-release: main
    dry-run: false
...
...
Creating new release tag: v1.0.1-$
Release is a prerelease. Skipping major tag...
Release is a prerelease. Skipping minor tag...

For now, I have two steps in the same workflow, wich only differs by if condition based on the branch. Still, it will be nice to have the ability to specify prerelease tags based on the branch.

I can create a PR, but there are a few options on how it can be implemented, and I want to discuss it with you first.

Possible implementation:

  1. updating if(prerelease) in the code to check if string is false
  2. updating prerelease variable with logic you had in create-release variable
  3. create prerelease if create-release didn't contain valid branch

wdyt?

Bug: latest (1.5.3) cannot tag when a previous tag does not exist

It seems if this action has to generate a default tag it fails

Run SOLIDSoftworks/[email protected]
Generating version regex pattern
Generated pattern: ^hatch-test-suite-v(\d+)\.(\d+)\.(\d+)(-(\w[\w.]*))?(\+(\w[\w\.]*))??$
Getting previous tags
Generating version regex pattern
Generated pattern: ^hatch-test-suite-v?(\d+)\.(\d+)\.(\d+)(-(\w[\w.]*))?(\+(\w[\w\.]*))??$
No previous version tag. Using '0.1.0' as next version.
/runner/_work/_actions/SOLIDSoftworks/semver-tags/v1.5.3/dist/index.js:27572
    major = match[1];
                 ^

TypeError: Cannot read properties of null (reading '1')
    at calculateNextVersion (/runner/_work/_actions/SOLIDSoftworks/semver-tags/v1.5.3/dist/index.js:27572:18)
    at run (/runner/_work/_actions/SOLIDSoftworks/semver-tags/v1.5.3/dist/index.js:27685:20)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

My guess is that the match is not being populated, possibly because prefix optional=true being ignored:

const versionPattern = generateVersionPattern({ tagPrefix: tagPrefix, tagPrefixOptional: true });

Usage in question:

      - name: Bump version and push tag
        uses: SOLIDSoftworks/[email protected]
        id: tag_version
        with:
          GITHUB_TOKEN: ${{ steps.secrets.outputs.GITHUB_TOKEN }}
          tag-prefix: ${{ matrix.workflows }}-v
          default-version: '0.1.0'
          incremented-value: ${{ steps.bump_version.outputs.value }}
          dry-run: ${{ github.event_name == 'pull_request' }}

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.