Go to file
Corey Butler 1c9d139f45 WIP
2019-09-02 18:45:33 -05:00
docs Initial commit 2019-09-02 15:40:00 -05:00
lib WIP 2019-09-02 18:45:33 -05:00
node_modules WIP 2019-09-02 17:50:18 -05:00
.gitignore Added node_modules, per Github requirement. 2019-09-02 16:35:53 -05:00
action.yml Initial cleanup 2019-09-02 16:11:57 -05:00
LICENSE Initial commit 2019-09-02 15:40:00 -05:00
package-lock.json WIP 2019-09-02 17:50:18 -05:00
package.json WIP 2019-09-02 17:50:18 -05:00
README.md WIP 2019-09-02 18:45:33 -05:00

Autotag

Outputs: tag - empty if no tag is created.

Usage

The following is an example .github/main.workflow that will execute when a push to the master branch occurs.

name: Node CI

on: 
  push:
    branches:
    - master

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - uses: butlerlogic/action-autotag@1.0.0
      with:
        GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

To make this work, the workflow must have the checkout action before the autotag action.

This order is important!

- uses: actions/checkout@master
- uses: butlerlogic/action-autotag@1.0.0

If the repository is not checked out first, the autotagger cannot find the package.json file.

Configuration

The GITHUB_TOKEN must be passed in. Without this, it is not possible to create a new tag. Make sure the autotag action looks like the following example:

- uses: butlerlogic/action-autotag@1.0.0
  with:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

The action will automatically extract the token at runtime. DO NOT MANUALLY ENTER YOUR TOKEN. If you put the actual token in your workflow file, you're make it accessible in plaintext to anyone who ever views the repository (it wil be in your git history).

Optional Configurations

There are several options to customize how the tag is created.

  1. tag_prefx

    By default, package.json uses semantic versioning, such as 1.0.0. A prefix can be used to add text before the tag name. For example, if tag_prefx is set to v, then the tag would be labeled as v1.0.0.

    - uses: butlerlogic/action-autotag@1.0.0
      with:
        GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
        tag_prefx: "v"
    
  2. tag_suffix

    Text can also be applied to the end of the tag by setting tag_suffix. For example, if tag_suffix is (beta), the tag would be 1.0.0 (beta). Please note this example violates semantic versioning and is merely here to illustrate how to add text to the end of a tag name if you really want to.

    - uses: butlerlogic/action-autotag@1.0.0
      with:
        GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
        tag_suffix: " (beta)"
    
  3. tag_message

    This is the annotated commit message associated with the tag. By default, a changelog will be generated from the commits between the latest tag and the new tag (HEAD). This will override that with a hard-coded message.

    - uses: butlerlogic/action-autotag@1.0.0
      with:
        GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
        tag_message: "Custom message goes here."
    

Developer Notes

If you are building an action that runs after this one, be aware this action produces several outputs:

  1. tagname will be empty if no tag was created, or it will be the value of the new tag.
  2. tagsha: The SHA of the new tag.
  3. taguri: The URI/URL of the new tag reference.
  4. version will be the version attribute found in the package.json file.