Skip to content

jaywcjlove/create-tag-action

Use this GitHub Action with your project

Add this Action to an existing workflow or create a new one.

View on Marketplace
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
October 26, 2022 23:17
September 16, 2023 23:24
src
September 16, 2023 23:24
September 2, 2021 19:25
January 5, 2021 17:45
January 5, 2021 17:45
January 5, 2021 17:45
January 5, 2021 19:15
April 19, 2023 15:19
October 13, 2022 09:35
September 16, 2023 23:25

create-tag-action

CI Repo Dependents

Auto create tags from commit or package.json

Inputs

  • token Your GITHUB_TOKEN. This is required. Why do we need token? Read more here: About the GITHUB_TOKEN secret. Default: ${{ github.token }}
  • version Create tag for specified version. Exampe: version: v1.0.0
  • test The regular expression matches the submitted content. Exampe: test: '[R|r]elease[d]\s+[v|V]\d(\.\d+){0,2}'
  • package-path The path of the package.json file. Default package.json.
  • release Optionally marks this tag as release. Set to true to enable.
  • prerelease Optionally marks this release as prerelease. Set to true to enable.
  • body An optional body for the release.

Outputs

  • version The version number of the tag created, example: v1.0.0.
  • versionNumber The version number of the tag created, example: 1.0.0.
  • preversion The previous tag version number, example: v1.0.0.
  • preversionNumber The previous tag version number of the tag created. example: 1.0.0.
  • successful The tag was successfully created.
  • majorVersion MAJOR version when you make incompatible API changes.
  • minorVersion MINOR version when you add functionality in a backwards compatible manner, and.
  • patchVersion PATCH version when you make backwards compatible bug fixes.
- run: echo "version - ${{ steps.create_tag.outputs.version }}"
- run: echo "version || preversion - ${{ steps.create_tag.outputs.version || steps.create_tag.outputs.preversion }}"
- run: echo "versionNumber - ${{ steps.create_tag.outputs.versionNumber }}"
- run: echo "versionNumber || preversionNumber - ${{ steps.create_tag.outputs.versionNumber || steps.create_tag.outputs.preversionNumber }}"
- run: echo "majorVersion - ${{ steps.create_tag.outputs.majorVersion }}"
- run: echo "minorVersion - ${{ steps.create_tag.outputs.minorVersion }}"
- run: echo "patchVersion - ${{ steps.create_tag.outputs.patchVersion }}"
- run: echo "preversion - ${{ steps.create_tag.outputs.preversion }}"
- run: echo "successful - ${{ steps.create_tag.outputs.successful }}"

Example Usage

First, we must listen for push events

on:
  push:
    branches:
      - master
    paths-ignore:
      - '.github/**/*.yml'
      - '.gitignore'

Compare the tag version number in package.json with the last tag and automatically generate tags

- run: echo "previous_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo '')" >> $GITHUB_ENV
- name: Create Tag
  id: create_tag
  uses: jaywcjlove/create-tag-action@main
  if: env.previous_tag
  with:
    package-path: ./package.json

Or, Compare the tag version number in the commit content with the last tag and automatically generate tags

- run: echo "previous_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo '')" >> $GITHUB_ENV
- name: Create Tag
  id: create_tag
  uses: jaywcjlove/create-tag-action@main
  if: env.previous_tag
  with:
    test: '[R|r]elease[d]\s+[v|V]\d(\.\d+){0,2}'

Use steps.<job_id>.outputs.successful to determine whether the version is created successfully, and a changelog will be automatically generated.

- name: Generate Changelog
  id: changelog
  uses: jaywcjlove/changelog-generator@main
  if: steps.create_tag.outputs.successful
  with:
    head-ref: ${{steps.create_tag.outputs.version}}
    filter-author: (jaywcjlove|小弟调调™|dependabot\[bot\]|Renovate Bot)
    filter: (^[\s]+?[R|r]elease)|(^[R|r]elease)

Use steps.<job_id>.outputs.successful to determine whether the version is created successfully, the creation has been released

- name: Create Release
  uses: ncipollo/release-action@v1
  if: steps.create_tag.outputs.successful
  with:
    token: ${{ secrets.GITHUB_TOKEN }}
    name: ${{ steps.create_tag.outputs.version }}
    tag: ${{ steps.create_tag.outputs.version }}
    body: |
      ```bash
      npm i @uiw/react-heat-map@${{steps.create_tag.outputs.versionNumber}}
      ```

      ${{ steps.changelog.outputs.compareurl }}
      ${{ steps.changelog.outputs.changelog }}

OR use jaywcjlove/create-tag-action@main:

- name: Generate Changelog
  uses: jaywcjlove/create-tag-action@main
  if: steps.create_tag.outputs.successful
  with:
    version: ${{steps.create_tag.outputs.version}}
    release: true
    body: |
      ```bash
      npm i @uiw/react-heat-map@${{steps.create_tag.outputs.versionNumber}}
      ```

      ${{ steps.changelog.outputs.compareurl }}
      ${{ steps.changelog.outputs.changelog }}

See Also

Example

License

The scripts and documentation in this project are released under the MIT License