Git Product home page Git Product logo

action-autotag's Introduction

Autotag

This action will generate a Github tag when a new version is detected.

graph LR
  e[Detect/Extract<br/>Semantic Version]
  e-->c[Compare<br/>to Existing Tags]
  c-->d{Newer?}
  d-.->|No|done[Done]
  d-.->|Yes|p[Create Tag]

There are several "detection strategies" to choose from:

  1. package: Extract from package.json.
  2. composer: Extract from composer.json.
  3. docker: Extract from Dockerfile, in search of a LABEL version=x.x.x value.
  4. regex: Use a JavaScript regular expression with any file for your own custom extraction.
  5. manual: Manually supply the version number (no need to specify this strategy, just specify the version).

When a new version is detected, it is compared to the current tags in the Github repository. If the version is newer than other tags (or if no tags exist yet), the version will be used to create a new tag.

Tagging: Part of a Complete Deployment Solution

This action works well in combination with:

Usage

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

name: Create Tag

on:
  push:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - uses: butlerlogic/action-autotag@stable
      env:
        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@v2
- uses: butlerlogic/action-autotag@stable

If the repository is not checked out first, the autotagger cannot find the source files.

Configuration

The GITHUB_TOKEN must be provided. 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@stable
  env:
    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'll make it accessible (in plaintext) to anyone who ever views the repository (it will be in your git history).

Optional Configuration Options

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

strategy (required)

This is the strategy used to identify the version number/tag from within the code base.

- uses: butlerlogic/[email protected]
  env:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  with:
    strategy: <your_choice>
  1. package: Search package.json for new versions. Use this for JavaScript projects based on Node/Deno/Bun modules (npm, yarn, etc).
  2. composer: Same as package, but uses composer.json instead of package.json.
  3. docker: Search a Dockerfile for a LABEL version=x.x.x value. Use this for container projects.
  4. regex*: Use a JavaScript regular expression with any file for your own custom extraction.

EXCEPTION: This property is not required if the regex_pattern property (below) is defined, because it is assumed to be "regex".

root

Depending on the selected strategy, autotagger will look for the confgured identify file (i.e. package.json, composer.json, Dockerfile, etc) in the project root. If the file is located in a subdirectory, this option can be used to point to the correct file.

Using the package (or composer) strategy:

- uses: butlerlogic/[email protected]
  env:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  with:
    strategy: package # Optional, since "package" is the default strategy
    root: "/path/to/subdirectory"

The version number would be extracted from /path/to/subdirectory/package.json.

Using the docker strategy:

- uses: butlerlogic/[email protected]
  env:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  with:
    strategy: docker
    root: "/path/to/subdirectory"

The version number would be extracted from /path/to/subdirectory/Dockerfile, specifically looking for the LABEL version=x.x.x line within the file.

Using the regex strategy:

- uses: butlerlogic/[email protected]
  env:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  with:
    strategy: regex # Optional since regex_pattern is defined
    root: "/path/to/subdirectory/my.file"
    regex_pattern: "version=([0-9\.])"

The version will be extracted by scanning the content of /path/to/subdirectory/my.file for a string like version=1.0.0. See the regex_pattern option for more details.

regex_pattern

An optional attribute containing the regular expression used to extract the version number.

- uses: butlerlogic/[email protected]
  env:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  with:
    regex_pattern: "version=([0-9\.]{5}([-\+][\w\.0-9]+)?)"

This attribute is used as the first argument of a RegExp object. The first "group" (i.e. what's in the main set of parenthesis/the whole version number) will be used as the version number. For an example, see this working example.

The pattern described in this example is a simplistic one. If you need a more explicit one the complete semver pattern is:

^((0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)$

As of 1.1.2, JavaScript named patterns are supported, where the group named version will be used to populate the tag. For example:

- uses: butlerlogic/[email protected]
  env:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  with:
    regex_pattern: "(version=)(?<version>[\d+\.]{3}([-\+][\w\.0-9]+)?)"

tag_prefix

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

- uses: butlerlogic/[email protected]
  env:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  with:
    tag_prefix: "v"

tag_suffix

Text can 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/[email protected]
  env:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  with:
    tag_suffix: " (beta)"

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 current reference (HEAD). Setting this option will override the message.

- uses: butlerlogic/[email protected]
  env:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  with:
    tag_message: "Custom message goes here."

commit_message_template

By default, a changelog is generated, containing the commit messages since the last release. The message is generated by applying a commit message template to each commit's data attributes.

- uses: butlerlogic/[email protected]
  env:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  with:
    commit_message_template: "({{sha}} by {{author}}) {{message}}"

Optional data points:

  1. number The commit number (relevant to the overall list)
  2. message The commit message.
  3. author The author of the commit.
  4. sha The SHA value representing the commit.

The default is {{number}}) {{message}} ({{author}})\nSHA: {{sha}}\n.

Example output:

1) Update README.md (coreybutler)
(SHA: c5e09fc45106a4b27b8f4598fb79811b589a4684)

2) Added metadoc capability to introspect the shell/commands. (coreybutler)
(SHA: b690be366a5636d51b1245a1b39c86102ddb8a81)

version

Explicitly set the version instead of using automatic detection (forces "manual" strategy).

Useful for projects where the version number may be output by a previous action.

- uses: butlerlogic/[email protected]
  env:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  with:
    version: "${{ steps.previous_step.outputs.version }}"

min_version

Set the minimum version which would be used to create a tag.

The default value (0.0.1) prevents a 0.0.0 from being created. This can also be used when introducing Autotag to a repository which already has tags.

For example, if the version 0.1.0 is already published, set the minVersion to the next patch to prevent a duplicate tag for that version.

- uses: butlerlogic/[email protected]
  with:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
    min_version: "0.1.1"

dry_run

If this value is true, the tag will not be pushed. You can check for duplicate versions when creating a pull request.

- uses: butlerlogic/[email protected]
  with:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
    dry_run: true

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. tagrequested: The name of the requested tag. This will be populated even if the tag is not created. This will usually be the same as tagname and/or version for successful executions. This output is typically used for rollbacks/notifications when the creation of a tag fails.
  3. tagsha: The SHA of the new tag.
  4. taguri: The URI/URL of the new tag reference.
  5. tagmessage: The message applied to the tag reference (this is what shows up on the tag screen on Github).
  6. tagcreated: yes or no.
  7. version will be the extracted/provided version.
  8. prerelease: "yes" or "no", indicating the tag represents a semantic version pre-release.
  9. build: "yes" or "no", indicating the tag represents a semantic version build.

Credits

This action was written and is primarily maintained by Corey Butler.

This project has had great contributions from these wonderful people. Additional gratitude goes to Jaliborc, who came up with the idea and original implementation for a pattern-based tag extraction (the Regex strategy).

Active Sponsors

These sponsors are helping make this project possible.

Our Ask...

If you use this or find value in it, please consider contributing in one or more of the following ways:

  1. Click the "Sponsor" button at the top of the page and make a contribution.
  2. Star it!
  3. Tweet about it!
  4. Fix an issue.
  5. Add a feature (post a proposal in an issue first!).

Copyright ยฉ 2020-2023 Butler Logic, Corey Butler, and Contributors.

action-autotag's People

Contributors

actions-user avatar bana118 avatar coreybutler avatar dependabot[bot] avatar jacobtomlinson avatar maximilianmeier avatar oomathias avatar samrobbins85 avatar theclive avatar tpluscode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

action-autotag's Issues

failing with `Bad credentials` when pushing a tag to remote

Issue:
The stable build fails to push a tag to the remote:

Warning: Attempting to use regex version extraction strategy.
Warning: Attempting to create v3.0.3 tag.
Warning: Bad credentials
Warning: HttpError: Bad credentials
    at /app/node_modules/@octokit/request/dist-node/index.js:86:21
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Tag.getTags (file:///app/lib/tag.js:92:18)
    at async Tag.exists (file:///app/lib/tag.js:102:[18](https://github.com/Svetlanko/fiery-lion-template/actions/runs/4057414256/jobs/6983140082#step:4:19))
    at async run (file:///app/main.js:59:9)

How To Reproduce:
the setup with a regex pattern(reading version number from a version file):

name: Tag Release

on:
  push:
    paths:
      - version
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name:  Create a tag
        uses: butlerlogic/action-autotag@stable
        with:
          strategy: regex
          root: "version"
          regex_pattern: "(\\d+\\.\\d+\\.\\d+)"
          tag_prefix: "v"
        env:
          GITHUB_TOKEN: "{{ secrets.GITHUB_TOKEN }}"
          ACTIONS_STEP_DEBUG: true  #purely for debugging purpose

Expected Behavior:
a new tag is pushed and available in the remote

A screen with logs:
Screen Shot 2023-01-31 at 11 57 53 AM
Screen Shot 2023-01-31 at 11 05 18 AM

I tested several combinations:

  1. non-regex pattern
  2. using this setup in the private repository in a personal account
  3. using this setup in the private repository as part of GitHub Enterprise
  4. using a PAT(personal token) instead of secrets.GITHUB_TOKEN
    in all of these cases, the error is the same.

Using master build vs stable gave different errors.
secrets.GITHUB_TOKEN works with other GitHub actions, which makes me think the token is not issue.

โ“ Would you be able to recommend anything else to try? or suggest a fix? thank you ๐Ÿ™

Using custom version generated from a previous step shows a warning

I'm using this action like the following, which is the custom version way.


name: Create Tag

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Maven Version
        id: get-version
        uses: JActions/[email protected]
      - uses: ButlerLogic/[email protected]
        env:
          GITHUB_TOKEN: "${{ github.token }}"
        with:
          version: "v${{ steps.get-version.outputs.version }}"

So I am reading a version from get-version step which reads it from a pom.xml file. I'm getting errors and a tag is not generated.

Warning:
Attempting to use package version extraction strategy.

Warning:
package.json does not exist at /github/workspace/package.json.

Warning:
Error: package.json does not exist at /github/workspace/package.json. at new Package (file:///app/lib/package.js:13:13) at run (file:///app/main.js:33:20) at file:///app/main.js:89:1 at ModuleJob.run (internal/modules/esm/module_job.js:110:37) at async Loader.import (internal/modules/esm/loader.js:179:24)

Autotag is broken: stable branch needs to use at least node14 instead of node13

Issue:
butlerlogic/action-autotag@stable uses node13 but also makes use of the most recent version of other libraries (notably https://github.com/nodejs/undici) which need >= node14.

This leads to the following warnings when building:

  #9 2.892 npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":">=14.0"} (current: {"node":"13.14.0","npm":"6.14.4"})
  #9 2.892 npm WARN notsup Not compatible with your version of node/npm: [email protected]
  #9 2.893 npm WARN notsup Unsupported engine for @fastify/[email protected]: wanted: {"node":">=14"} (current: {"node":"13.14.0","npm":"6.14.4"})
  #9 2.893 npm WARN notsup Not compatible with your version of node/npm: @fastify/[email protected]

So far this has not caused problems. But in version v5.27.1 of undici they started using optional chaining (which is only supported in >= node14).
Luckily because of their incredible response time (and me missing that the issue was actually caused by autotag and not their library) they worked around the issue in version v5.27.2 before I could close the issue again. But you might update the stable branch to at least node14 to get rid of the warnings when building and in case optional chaining (or other features) is introduced again in any other library.

The problem resurfaced again in version v5.28.0 which means autotag is now broken again.

The problem is explained in more detail here (it is focused on version v5.27.1 which they changed afterwards. but exactly the same problem was introduced again in v5.28.0,):
nodejs/undici#2399

How To Reproduce:
Just build action-autotag@stable and notice the warnings.

Expected Behavior:
Either not use the most recent versions of other libraries or update nodeJS to version 14 or above.

Full terminal output (notice warnings in #9)

/usr/bin/docker build -t 8a3030:9da51c9b1b394e38bcad9fe306105ad4 -f "/home/runner/work/_actions/butlerlogic/action-autotag/stable/Dockerfile" "/home/runner/work/_actions/butlerlogic/action-autotag/stable"
  #0 building with "default" instance using docker driver
  
  #1 [internal] load .dockerignore
  #1 transferring context: 2B done
  #1 DONE 0.0s
  
  #2 [internal] load build definition from Dockerfile
  #2 transferring dockerfile: 154B done
  #2 DONE 0.0s
  
  #3 [internal] load metadata for docker.io/library/node:13-alpine
  #3 ...
  
  #4 [auth] library/node:pull token for registry-1.docker.io
  #4 DONE 0.0s
  
  #3 [internal] load metadata for docker.io/library/node:13-alpine
  #3 DONE 1.1s
  
  #5 [internal] load build context
  #5 transferring context: 24.42kB done
  #5 DONE 0.0s
  
  #6 [1/4] FROM docker.io/library/node:13-alpine@sha256:527c70f74817f6f6b5853588c28de33459178ab72421f1fb7b63a281ab670258
  #6 resolve docker.io/library/node:13-alpine@sha256:527c70f74817f6f6b5853588c28de33459178ab72421f1fb7b63a281ab670258 done
  #6 sha256:780514bed1adda642a7f7008ea5b1477bb78a23e3f76eabbdde21031b2185a2f 11.53MB / 35.30MB 0.2s
  #6 sha256:5d74fb112a7d313344f9f679ccb975062377464235fac36e1b952aa2b125d5e2 2.24MB / 2.24MB 0.2s done
  #6 sha256:527c70f74817f6f6b5853588c28de33459178ab72421f1fb7b63a281ab670258 1.65kB / 1.65kB done
  #6 sha256:4d6b35f8d14b2f476005883f9dec0a93c83213838fd3def3db0d130b1b148653 1.16kB / 1.16kB done
  #6 sha256:8216bf4583a5d422edd579a3b77f66a8fe127c4acb5eabecf085d911786f3e68 6.77kB / 6.77kB done
  #6 sha256:cbdbe7a5bc2a134ca8ec91be58565ec07d037386d1f1d8385412d224deafca08 2.81MB / 2.81MB 0.1s done
  #6 extracting sha256:cbdbe7a5bc2a134ca8ec91be58565ec07d037386d1f1d8385412d224deafca08
  #6 sha256:4b9536424fa1675675e7edd59ae9a92573f0c010c5458733a493e2c3e1daf1ae 0B / 283B 0.2s
  #6 sha256:780514bed1adda642a7f7008ea5b1477bb78a23e3f76eabbdde21031b2185a2f 30.41MB / 35.30MB 0.3s
  #6 extracting sha256:cbdbe7a5bc2a134ca8ec91be58565ec07d037386d1f1d8385412d224deafca08 0.1s done
  #6 sha256:4b9536424fa1675675e7edd59ae9a92573f0c010c5458733a493e2c3e1daf1ae 283B / 283B 0.2s done
  #6 sha256:780514bed1adda642a7f7008ea5b1477bb78a23e3f76eabbdde21031b2185a2f 35.30MB / 35.30MB 0.4s done
  #6 extracting sha256:780514bed1adda642a7f7008ea5b1477bb78a23e3f76eabbdde21031b2185a2f
  #6 extracting sha256:780514bed1adda642a7f7008ea5b1477bb78a23e3f76eabbdde21031b2185a2f 1.6s done
  #6 extracting sha256:5d74fb112a7d313344f9f679ccb975062377464235fac36e1b952aa2b125d5e2
  #6 extracting sha256:5d74fb112a7d313344f9f679ccb975062377464235fac36e1b952aa2b125d5e2 0.1s done
  #6 extracting sha256:4b9536424fa1675675e7edd59ae9a92573f0c010c5458733a493e2c3e1daf1ae done
  #6 DONE 2.4s
  
  #7 [2/4] ADD ./app /app
  #7 DONE 0.0s
  
  #8 [3/4] WORKDIR /app
  #8 DONE 0.0s
  
  #9 [4/4] RUN cd /app && npm i
  #9 2.892 npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":">=14.0"} (current: {"node":"13.14.0","npm":"6.14.4"})
  #9 2.892 npm WARN notsup Not compatible with your version of node/npm: [email protected]
  #9 2.893 npm WARN notsup Unsupported engine for @fastify/[email protected]: wanted: {"node":">=14"} (current: {"node":"13.14.0","npm":"6.14.4"})
  #9 2.893 npm WARN notsup Not compatible with your version of node/npm: @fastify/[email protected]
  #9 2.893 npm WARN @octokit/[email protected] requires a peer of @octokit/core@>=3 but none is installed. You must install peer dependencies yourself.
  #9 2.893 
  #9 2.894 added 62 packages from 77 contributors and audited 62 packages in 2.329s
  #9 2.913 
  #9 2.913 2 packages are looking for funding
  #9 2.913   run `npm fund` for details
  #9 2.913 
  #9 2.913 found 0 vulnerabilities
  #9 2.913 
  #9 DONE 3.0s
  
  #10 exporting to image
  #10 exporting layers
  #10 exporting layers 0.6s done
  #10 writing image sha256:f2927ab6726cdeaaf8fa262939865bc1ac0da05cd9ceaa69de90cad12089e73c done
  #10 naming to docker.io/library/8a3030:9da51c9b1b394e38bcad9fe306105ad4 done
  #10 DONE 0.7s

Pre-Release Not Supported

Semantic Versioning requires pre-releases to have the version number followed by a hyphen and a dot separated identifiers. For example, 1.0.0-alpha.1

However, autotag removes characters after 1.0.0 in the above example. This means that Semantic Versioning will not create a pre-release tag.

My workflow:
`name: Create Tag

on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: butlerlogic/action-autotag@stable
with:
strategy: docker
root: /mypath
tag_suffix: -Alpha
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"`

In my Dockerfile, I set the VERSION = 1.0.0-Alpha.1

Prevent tagging version 0.0.0 (or below any arbitrary SemVer)

I am trying to build a workflow around a set of packages in a monorepo. This could mean a new project, adding packages to an existing workspace or introducing AutoTag in a repository which was tagged manually until now. The principle will be the same

For example, let's say that I add a new package to a repo. I will tag it based on package.json as @package/foo/vX.Y.Z. Initial I would create a package.json with version: 0.0.0 but that would create a meaningless tag @package/foo/v0.0.0

I would like to propose a min tag number parameter so that a tag would not be created. Something like minVersion: 0.0.1. That could actually be the default to prevent 0.0.0 tags at all...

Similarly, if I have an existing package which already has a version, say 1.0.1, when I add the action to my workflow I would like it to start creating tags from minVersion: 1.1.0

Add support for custom changelog format

I'd like to use the default changelog as the message but the formatting of the changelog is something I'd like to customize.
So it'd be nice if this would accept another input with a custom format.

I imagine it could be some string with special tags that denote variables. For example:

  changelog_structure:
    description: "A string denoting changelog format. Supports `{{message}}`, `{{author}}` and `{{sha}}`. Defaults to `**1) {{message}}** {{author}}\n(SHA: {{sha}})\n` Only used when tag_message is empty."
    required: false

If you decide to go forward with this it would be really nice to be able to also include only the message headline instead of the full commit message since they can get verbose and changelogs work best as short summaries.

`GITHUB_TOKEN` is not configured as an accepted input

Issue:

How To Reproduce:

  1. Setup a github action that uses: butlerlogic/action-autotag@stable and specifies under with: the value GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}.
  2. See that github outputs a warning about unexpected input.

Expected Behavior:

Github should not output a warning.

Resource not available by integration

Issue:

There appears to be an error of the form "resource not available by integration".

Run butlerlogic/[email protected]
  with:
    strategy: regex
    root: src/dummy/__init__.py
    regex_pattern: __version__ = "(?<version>\d+\.\d+\.\d+)"
  env:
    GITHUB_TOKEN: ***
/usr/bin/docker run --name ea425b28648b99bcd842ce8d8d6c7bd7f9e46d_2cfd87 --label ea425b --workdir /github/workspace --rm -e "GITHUB_TOKEN" -e "INPUT_STRATEGY" -e "INPUT_ROOT" -e "INPUT_REGEX_PATTERN" -e "INPUT_PACKAGE_ROOT" -e "INPUT_TAG_PREFIX" -e "INPUT_TAG_SUFFIX" -e "INPUT_TAG_MESSAGE" -e "INPUT_COMMIT_MESSAGE_TEMPLATE" -e "INPUT_VERSION" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/test-autotag/test-autotag":"/github/workspace" ea425b:28648b99bcd842ce8d8d6c7bd7f9e46d
Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
Warning: Attempting to use regex version extraction strategy.
Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
Warning: Attempting to create 0.0.4 tag.
Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
Warning: Resource not accessible by integration
Warning: HttpError: Resource not accessible by integration
    at /app/node_modules/@octokit/request/dist-node/index.js:66:23
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Tag.push (file:///app/lib/tag.js:128:22)
    at async run (file:///app/main.js:69:5)
Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

How To Reproduce:

Example repo here, where main.yml reads:

name: Create Tag

on:
  push:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: butlerlogic/[email protected]
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
        with:
          strategy: regex
          root: src/dummy/__init__.py
          regex_pattern: '__version__ = "(?<version>\d+\.\d+\.\d+)"'

Expected Behavior:

A tag to be created. More specifically, 0.0.4 since src/dummy/__init__.py reads

__version__ = "0.0.4"

Not tagging the last commit

Goal

Working on pure-fish I aim to have a workflow that does:

  1. create a bump commit using thenativeweb/get-next-version action then push said commit to master
  2. checkout master and use autotag

Expectation

* cda6090 (HEAD -> master, tag: v4.4.0) chore: bump version 4.4.0
* 5c4af3a ci(version): tag on push on master and on PR merge
* bedae60 chore(lint): re-format

Actual

The tag is placed on the previous commit

* cda6090 (HEAD -> master) chore: bump version 4.4.0
* 5c4af3a (tag: v4.4.0) ci(version): tag on push on master and on PR merge
* bedae60 chore(lint): re-format

image

Workflow

name: Add New Tag After Merge

on:
  workflow_call: # allow this workflow to be called from other workflows

jobs:
  bump-version:
    # if: github.event_name == 'push' || github.event.pull_request.merged == true
    runs-on: ubuntu-latest
    steps:
      - name: Clone repository
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Get next version
        id: next_version
        uses: thenativeweb/get-next-version@main

      - name: Show the next version
        run: |
          echo ${{ steps.next_version.outputs.version }}
          echo ${{ steps.next_version.outputs.hasNextVersion }}

      - name: Bump version file
        if: steps.next_version.outputs.hasNextVersion == 'true'
        run: |
          perl -i -p -e \
            "s/(pure_version)\s(\d+(\.)?){3}/\1 ${{ steps.next_version.outputs.version }}/" \
            ./conf.d/pure.fish

      - name: Set git user metadata
        if: steps.next_version.outputs.hasNextVersion == 'true'
        run: |
          git config user.name github-actions
          git config user.email [email protected]

      - name: Commit new version file
        if: steps.next_version.outputs.hasNextVersion == 'true'
        run: |
          git add --verbose ./conf.d/pure.fish \
          && git commit --allow-empty --message "chore: bump version ${{ steps.next_version.outputs.version }}" \
          && git push

  add-version-tag:
    # if: github.event_name == 'push' || github.event.pull_request.merged == true
    needs: [bump-version]
    runs-on: ubuntu-latest
    steps:
      - name: Clone repository
        uses: actions/checkout@v3
        with:
          ref: "master"

      - uses: butlerlogic/action-autotag@stable
        with:
          root: "./conf.d/pure.fish"
          regex_pattern: "pure_version\\s(?<version>(\\d+(\\.)?){3})"
          tag_prefix: "v"
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

Question

How can I tag the latest commit?

When a tag is created, it won't trigger `on push tags` Github actions

Issue:
Whenever a tag is created using this action, it won't trigger my other actions that uses "On push tags" trigger. These actions work fine when I manually push the tag

How To Reproduce:

  1. Create a GH action that starts with:
on:
  push:
    tags:
      - 'v*.*.*'
  1. Create a tag from the action-autotag action
  2. The action from step 1 won't be triggered

Tagging Not Working

It seems as though the package.json's version is being picked up, but a tag is not being pushed.
I've attached a screenshot of what this looks like in actions.
image

dry_run option for on:pull_request

Thank you for the great action!

I would like to propose dry_run option. If this value is true, the tag will not be pushed.
This option can be used with on:pull_request to prevent forgetting to raise the version in package.json.

I'm using this option with my forked action, but it would be better if it was available in the original action.

SyntaxError: Unexpected token '?'

Related: might be related #45

Issue:

Run butlerlogic/action-autotag@stable
  with:
    root: ./conf.d/pure.fish
    regex_pattern: pure_version\s(?<version>(\d+(\.)?){3})
    tag_prefix: v
    strategy: package
  env:
    GITHUB_TOKEN: ***
/usr/bin/docker run --name bb0998910224fb162b475f9844bfa5b68581f8_f0313a --label bb0998 --workdir /github/workspace --rm -e "GITHUB_TOKEN" -e "INPUT_ROOT" -e "INPUT_REGEX_PATTERN" -e "INPUT_TAG_PREFIX" -e "INPUT_STRATEGY" -e "INPUT_PACKAGE_ROOT" -e "INPUT_TAG_SUFFIX" -e "INPUT_TAG_MESSAGE" -e "INPUT_COMMIT_MESSAGE_TEMPLATE" -e "INPUT_VERSION" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_ENVIRONMENT" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e "ACTIONS_RESULTS_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/pure/pure":"/github/workspace" bb0998:910224fb162b475f9844bfa5b68581f8
/app/node_modules/undici/lib/handler/RetryHandler.js:29
    } = retryOptions ?? {}
                      ^

SyntaxError: Unexpected token '?'
    at Object.compileFunction (vm.js:344:18)
    at wrapSafe (internal/modules/cjs/loader.js:1048:15)
    at Module._compile (internal/modules/cjs/loader.js:1082:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
    at Module.load (internal/modules/cjs/loader.js:982:32)
    at Function.Module._load (internal/modules/cjs/loader.js:875:14)
    at Module.require (internal/modules/cjs/loader.js:1022:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/app/node_modules/undici/index.js:18:22)
    at Module._compile (internal/modules/cjs/loader.js:1118:30)

How To Reproduce:

See failing pipeline
https://github.com/pure-fish/pure/actions/runs/7057904486/job/19212863526

Expected Behavior:

See working pipeline
https://github.com/pure-fish/pure/actions/runs/6312852399

Additional context:

Dynamic require of "os" is not supported

Issue:
Autotag version 1.1.4 does not create a new tag, but raises the following error when used as Github action:

Run butlerlogic/[email protected]
  with:
    strategy: package
    tag_message: ๐Ÿ› fix github actions build
    root: ./
    min_version: 0.0.1
  env:
    GITHUB_TOKEN: ***
file:///home/runner/work/_actions/butlerlogic/action-autotag/1.1.4/dist/main.js:1[2](https://github.com/kromitgmbh/titra/actions/runs/8294522044/job/22699699681#step:3:2)
  throw new Error('Dynamic require of "' + x + '" is not supported');
        ^

Error: Dynamic require of "os" is not supported
    at file:///home/runner/work/_actions/butlerlogic/action-autotag/1.1.4/dist/main.js:12:9
    at node_modules/@actions/core/lib/command.js (file:///home/runner/work/_actions/butlerlogic/action-autotag/1.1.4/dist/main.js:96:28)
    at __require2 (file:///home/runner/work/_actions/butlerlogic/action-autotag/1.1.4/dist/main.js:15:50)
    at node_modules/@actions/core/lib/core.js (file:///home/runner/work/_actions/butlerlogic/action-autotag/1.1.4/dist/main.js:18[3](https://github.com/kromitgmbh/titra/actions/runs/8294522044/job/22699699681#step:3:3)[4](https://github.com/kromitgmbh/titra/actions/runs/8294522044/job/22699699681#step:3:4)0:21)
    at __require2 (file:///home/runner/work/_actions/butlerlogic/action-autotag/1.1.4/dist/main.js:1[5](https://github.com/kromitgmbh/titra/actions/runs/8294522044/job/22699699681#step:3:5):50)
    at file:///home/runner/work/_actions/butlerlogic/action-autotag/1.1.4/dist/main.js:20944:21
    at ModuleJob.run (node:internal/modules/esm/module_job:217:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:31[6](https://github.com/kromitgmbh/titra/actions/runs/8294522044/job/22699699681#step:3:6):24)
    at async loadESM (node:internal/process/esm_loader:34:[7](https://github.com/kromitgmbh/titra/actions/runs/8294522044/job/22699699681#step:3:7))
    at async handleMainPromise (node:internal/modules/run_main:66:12)

Node.js v20.[8](https://github.com/kromitgmbh/titra/actions/runs/8294522044/job/22699699681#step:3:8).1

default tagmessage always contains all commits

Hi,
I am using autotag in one of my projects and without specifying a tagmessage, it always adds all commits. You can check it out here .

Not sure what's wrong, all feedback is appreciated!

Thanks,
Fabian

Manual Version Tag Being Ignored

I have the following code in my github actions. The run command from the first task here shows version 1.0.1, however the AutoTag task is using the version found in package.json which is 1.0.0.

How can I get Auto Tag to use a specific tag version?

      - name: Tag Version To Use
        run: echo "${{ steps.version_increment.outputs.version }}"

      - name: Auto Tag
        uses: butlerlogic/[email protected]
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
        with:
          version: "${{ steps.version_increment.outputs.version }}"`

The setup is being followed from here:

image

HttpError: Could not verify tag name

Issue:

I receive this error when trying to use action:

Skipping min version check. 1.17.0 (2022-11-11) is not valid SemVer
Notice: Recognized "1.17.0 (2022-[11](https://github.com/ultralisp/ultralisp/actions/runs/3448090317/jobs/5754777700#step:4:12)-11)" using the regex extraction with the /^(?<version>\d+\.\d+\.\d+(.+)?)\n?/gim pattern..
Attempting to create v1.17.0 (2022-11-11) tag.
Warning: Could not verify tag name
Warning: HttpError: Could not verify tag name
    at /home/runner/work/_actions/butlerlogic/action-autotag/8bc1ad456dcdee34e8c6ffbce991cc31793578c2/dist/main.js:7954:25
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Tag.push (/home/runner/work/_actions/butlerlogic/action-autotag/8bc1ad456dcdee34e8c6ffbce991cc31793578c2/dist/main.js:27[14](https://github.com/ultralisp/ultralisp/actions/runs/3448090317/jobs/5754777700#step:4:15)0:22)
    at async run (/home/runner/work/_actions/butlerlogic/action-autotag/8bc1ad456dcdee34e8c6ffbce991cc3[17](https://github.com/ultralisp/ultralisp/actions/runs/3448090317/jobs/5754777700#step:4:18)93578c2/dist/main.js:27290:7)

Here is the test run. There is a lannonbr/repo-permission-check-action step to check if current user has write permission.

This is the full content of the workflow:

name: Add Version Tag

on:
  pull_request:
  push:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: ${{ github.actor }} permission check to update release version
      uses: "lannonbr/[email protected]"
      with:
        permission: "write"
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    - uses: butlerlogic/action-autotag@8bc1ad456dcdee34e8c6ffbce991cc31793578c2
      with:
        regex_pattern: "^(?<version>\\d+\\.\\d+\\.\\d+(.+)?)\\n?"
        root: ./ChangeLog.rst
        tag_prefix: "v"
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Collaborate?

Hello!

I recently wrote https://github.com/marketplace/actions/tagging-strategy.

This action has a very similar purpose, but supports different features as yours.

Do you guys want to collaborate or potentially merge these two actions?

Collaboration to me would mean figuring out what the distinct scope/use-cases work best for each action, stating that use-case in README's, and then mentioning the other's actions in each README for when users find one but their use case matches the other.

Merging to me would be if both groups agree the scope and use case is the same, and both groups believe all features could exist in one action.

Interested in hearing your thoughts.

20221026: use supported libs to prevent output error

Is your feature request related to a problem? Please describe.

Running the lastest Release of the action brings up deprecation errors

Warning: The set-outputcommand is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

Describe the solution you'd like

Update to latest libs and use the new method of outputs

Describe alternatives you've considered

Currently i haven't

Additional context

Please use the reactions to cast a vote in favor of or against this feature suggestion ยป

Token from secrets.GITHUB_TOKEN does not work without a permission to write "contents"

When using job description from the README:

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

I've got "Resource not accessible" error in action logs:

Screenshot 2023-12-07 at 18 37 03

To solve this problem, permissions section should be added tot he job's declaration:

jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
    - uses: actions/checkout@v3
    - uses: butlerlogic/action-autotag@stable
      env:
        GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

Get tag from previous step output instead

Thanks for working on this awesome action.

I'd love to use this in a non-JavaScript project and therefore there is no package.json file. However I can easily get the version in a previous step and store it as an output.

For example I have written an Action which exposes a Helm Chart's metadata by reading the Chart.yaml file and exposing the values as outputs. I'd like to autotag if the version specified in my chart changes.

Therefore could an input be added here to allow you to specify the version and bypass the package.json logic?

Something like this

name: My Workflow

on: 
  push:
    branches:
    - master

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - uses: some/action@master  # This action exposes the app `version` as an output
      id: getversion
    - uses: butlerlogic/action-autotag@stable
      with:
        GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
        version: ${{ steps.getversion.outputs.version }}

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.