Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jaliborc/action-general-autotag
:octocat: Automatically generate new tags by extracting their names from a given source file
https://github.com/jaliborc/action-general-autotag
action automation autotag github-actions node nodejs package tag
Last synced: 8 days ago
JSON representation
:octocat: Automatically generate new tags by extracting their names from a given source file
- Host: GitHub
- URL: https://github.com/jaliborc/action-general-autotag
- Owner: Jaliborc
- License: mit
- Created: 2019-09-11T20:54:06.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-12T02:55:55.000Z (over 1 year ago)
- Last Synced: 2024-11-07T08:04:42.803Z (8 days ago)
- Topics: action, automation, autotag, github-actions, node, nodejs, package, tag
- Language: JavaScript
- Homepage:
- Size: 498 KB
- Stars: 7
- Watchers: 3
- Forks: 3
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# General AutoTag :bookmark_tabs:
[![](https://img.shields.io/npm/v/general-autotag.svg)](https://www.npmjs.com/package/general-autotag) [![](https://github.com/jaliborc/scrap/workflows/tag/badge.svg)](https://github.com/jaliborc/scrap/actions) ![](https://david-dm.org/jaliborc/general-autotag.svg) ![](https://img.shields.io/npm/l/general-autotag.svg)This action will read a chosen source file and extract the current version from it. It will then compare it to the project's known tags and, if a corresponding tag does not exist, it will be created.
Forked from [Autotag](https://github.com/ButlerLogic/action-autotag), which worked specifically with Node projects. This approach is more flexible and works with different programming languages.
## Usage
The following is an example `.github/main.workflow` that will execute when a `push` to the `master` branch occurs. It will extract the current version number from `package.json`:
```yaml
name: My Workflowon:
push:
paths:
- package.json
branches:
- masterjobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: jaliborc/[email protected]
with:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
source_file: "package.json"
extraction_regex: "\\s*\"version\"s*:\\s*\"([\\d\\.]+)\""
```To make this work, the workflow must have the checkout action _before_ the tagging action.
This **order** is important!
```yaml
- uses: actions/checkout@master
- uses: jaliborc/[email protected]
```> If the repository is not checked out first, the action cannot find the chosen source file.
## Configuration
### MandatoryThe `GITHUB_TOKEN`, a `source_file` and an `extraction_regex` 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:
```yaml
- uses: jaliborc/[email protected]
with:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
source_file: # the file in your repository that contains the version name
extraction_regex: # some regex pattern
```The action will automatically extract the github 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 will be in your git history).
### Optional
There are a few options to customize how the tag is created.1. `tag_format`
By default, the action will tag versions exactly as matched in the source file. Prefixes and suffixes can be used to add text around the tag name. For example, if the current version is `1.0.0` and the `tag_format` is set to `v{version} (beta)`, then the tag would be labeled as `v1.0.0 (beta)`.
```yaml
- uses: jaliborc/[email protected]
with:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
source_file: "package.json"
extraction_regex: "(\\d+\\.\\d+\\.\\d+)"
tag_format: "v{version} (beta)"
```1. `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.
```yaml
- uses: jaliborc/[email protected]
with:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
source_file: "project.toc"
extraction_regex: "Version:\\s*(\\d+)"
tag_message: "Custom message goes here."
```## Output
If you are building an action that runs after this one, be aware this action produces several [outputs](https://help.github.com/en/articles/metadata-syntax-for-github-actions#outputs):1. `tagname` will be empty if no tag was created, or it will be the value of the new tag.
1. `tagsha`: The SHA of the new tag.
1. `taguri`: The URI/URL of the new tag reference.
1. `tagmessage`: The message applied to the tag reference (this is what shows up on the tag screen on GitHub).
1. `version` will be the version attribute found in the chosen source file.