All Projects → ButlerLogic → action-autotag

ButlerLogic / action-autotag

Licence: MIT License
Automatically generate a new tag when the manifest file (package.json, Dockerfile, custom file, etc) version changes.

Programming Languages

javascript
184084 projects - #8 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to action-autotag

upx-action
Strips and runs upx on binaries
Stars: ✭ 17 (-62.22%)
Mutual labels:  actions, action, github-actions
ssh2actions
Connect to GitHub Actions VM via SSH for interactive debugging
Stars: ✭ 62 (+37.78%)
Mutual labels:  actions, action, github-actions
action
📦📊 GitHub Action to reports on the size of your npm package
Stars: ✭ 36 (-20%)
Mutual labels:  package, actions, github-actions
action-homebrew-bump-formula
⚙️ A GitHub Action to easily bump Homebrew formula on new release
Stars: ✭ 68 (+51.11%)
Mutual labels:  actions, action, github-actions
rubocop-linter-action
Rubocop Linter Action: A GitHub Action to run Rubocop against your code!
Stars: ✭ 86 (+91.11%)
Mutual labels:  actions, action, github-actions
github-run-tests-action
mabl Github Actions implementation
Stars: ✭ 39 (-13.33%)
Mutual labels:  actions, action, github-actions
actions
Set of actions for implementing CI/CD with werf and GitHub Actions
Stars: ✭ 67 (+48.89%)
Mutual labels:  actions, action, github-actions
action-sync-node-meta
GitHub Action that syncs package.json with the repository metadata.
Stars: ✭ 25 (-44.44%)
Mutual labels:  actions, action, github-actions
clojure-dependency-update-action
A simple GitHub Actions job to create Pull Requests for outdated dependencies in clojure projects
Stars: ✭ 37 (-17.78%)
Mutual labels:  actions, action, github-actions
setup-jdk
(DEPRECATED) Set up your GitHub Actions workflow with a specific version of AdoptOpenJDK
Stars: ✭ 32 (-28.89%)
Mutual labels:  actions, action, github-actions
dart-package-publisher
Action to Publish Dart / Flutter Package To https://pub.dev When you need to publish a package, just bump the version in pubspec.yaml
Stars: ✭ 45 (+0%)
Mutual labels:  actions, action, github-actions
jest-github-action
Jest action adding checks with annotations to your pull requests and coverage table as comments
Stars: ✭ 134 (+197.78%)
Mutual labels:  actions, action, github-actions
actions
Collection of repetitive GitHub Actions
Stars: ✭ 12 (-73.33%)
Mutual labels:  actions, action, github-actions
assign-one-project-github-action
Automatically add an issue or pull request to specific GitHub Project(s) when you create and/or label them.
Stars: ✭ 140 (+211.11%)
Mutual labels:  actions, action, github-actions
jacoco-report
Github action that publishes the JaCoCo report as a comment in the Pull Request
Stars: ✭ 31 (-31.11%)
Mutual labels:  actions, github-actions
action-junit-report
Reports junit test results as GitHub Pull Request Check
Stars: ✭ 103 (+128.89%)
Mutual labels:  actions, github-actions
colab-badge-action
GitHub Action that generates "Open In Colab" Badges for you
Stars: ✭ 15 (-66.67%)
Mutual labels:  action, github-actions
vs-shell
GitHub action to set up the Visual Studio shell environment
Stars: ✭ 36 (-20%)
Mutual labels:  action, github-actions
gh-action-community
GitHub Action for the Community, from welcoming first timers to badges
Stars: ✭ 24 (-46.67%)
Mutual labels:  actions, action
release-helper
🤖 A GitHub Action that help you publish release.
Stars: ✭ 27 (-40%)
Mutual labels:  actions, github-actions

Autotag

This action will auto-generate a Github tag whenever a new version is detected. The following "detection strategies" are available:

  1. package: Monitor a package.json for new versions.
  2. docker: Monitor a Dockerfile for a LABEL version=x.x.x value.
  3. regex: Use a JavaScript regular expression with any file for your own custom extraction.

When a version is detected, it is compared to the current list of tags in the Github repository. If a tag does not exist, it will be created.

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@v2
    - uses: butlerlogic/action-autotag@stable
      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@v2
- uses: butlerlogic/action-autotag@stable

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

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
  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'll make it accessible (in plaintext) to anyone who ever views the repository (it will be in your git history).

Optional Configurations

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.

  1. package: Monitor a package.json for new versions. Use this for JavaScript projects based on Node modules (npm, yarn, etc).
  2. docker: Monitor a Dockerfile for a LABEL version=x.x.x value. USe this for container projects.
  3. 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 is defined, because it is assumed to be "regex".

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

root

Formerly package_root

Depending on the selected strategy, autotagger will look for the package.json or Dockerfile file 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 strategy:

- uses: butlerlogic/[email protected]
  with:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
    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]
  with:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
    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]
  with:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
    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]
  with:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
    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 simple one used. If you need a more complex one complete 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]
  with:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
    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]
  with:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
    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]
  with:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
    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]
  with:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
    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]
  with:
    GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
    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.

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

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

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 Butler Logic, Corey Butler, and Contributors.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].