Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/amitsingh-007/next-release-tag

A Github Action which automatically generates next Release Tag for you
https://github.com/amitsingh-007/next-release-tag

actions github-actions pnpm release release-automation release-tag

Last synced: 3 months ago
JSON representation

A Github Action which automatically generates next Release Tag for you

Awesome Lists containing this project

README

        

# Generate Next Release Tag

- This is a GitHub Action that automates the process of creating the next release tag version for your repository. Note: it generates a new release version, but it does not create a new release.
- The action sets an output variable named `next_release_tag`, which can be used to create the next release.
- It uses the previous release tag and increments it based on the year, month, date, and iteration count.
- The action supports creating release tags based on the template given to the action. Refer to the [Templating System](https://github.com/amitsingh-007/next-release-tag#templating-system) section for more information.
- This action is recommended to be used with `softprops/action-gh-release` or `ncipollo/release-action` to create the release.
- The minimum supported Node.js version is v20.

## Inputs

`github_token`: The Github Secret `GITHUB_TOKEN` or `Personal Access Token`. This is a required input.

`tag_prefix`: The prefix to be added to the generated release tag. Pass as `''` to remove prefix in the generated output. This is a required input.

`tag_template`: A preconfigured static template based on which the new release tag will be generated. Please check the [Templating System](https://github.com/amitsingh-007/next-release-tag#templating-system) section for more information. This is a required input.

`previous_tag`: Pass this to override previous tag value and not fetch previous release tag. This is an optional input.

## Outputs

`next_release_tag`: This output variable contains the next release version and is set by the action. You can access it via `step..outputs.next_release_tag`.

`prev_release_tag`: Additionally, the action also sets this output variable, which contains the previous release version. You can access it via `step..outputs.prev_release_tag`.

## Example workflow

```yaml
name: Create Release

on: push

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout branch
uses: actions/checkout@v4

- name: Generate release tag
id: generate_release_tag
uses: amitsingh-007/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag_prefix: 'v'
tag_template: 'yyyy.mm.dd.i'

- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: Release ${{ steps.generate_release_tag.outputs.next_release_tag }}
tag_name: ${{ steps.generate_release_tag.outputs.next_release_tag }}
token: ${{secrets.GITHUB_TOKEN}}
generate_release_notes: true
```

## Templating System

This action supports a flexible templating system with a few constraints. Users must pass the `tag_template` option in the action, and the action will fill in the corresponding values based on the template to generate a new release tag. The following are the rules and constraints:

- The template represents the final release tag's format without the tag prefix. You must pass the tag prefix separately.
- The allowed template tokens are: `yyyy` (full year), `yy` (short year), `mm` (month), `dd` (date), `i` (iteration count).
- Each of these tokens must be combined with a separator to form the template (e.g., `yyyy.mm.i`).
- Separators cannot be at the beginning or end of the template (e.g., `.yy.mm.i.` is not allowed).
- A separator can be any string, but it cannot contain the above-mentioned tokens.
- Only a single kind of separator is allowed in the string (e.g., `yy-mm-dd.i` is not allowed).
- The iteration count resets to `01` when any of the year, month, or date is changed between the last release and the current release.
- The final generated release tag will be in the format: `` (e.g., if the tag_prefix is `v` and the tag_template is `yyyy.mm.dd.i`, then the second release on June 21, 2024, will be `v2024.06.21.02`).