-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f54689c
Showing
5 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
on: | ||
push: | ||
tags: | ||
- v[0-9]+.[0-9]+.[0-9]+ | ||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: ./ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
The MIT License (MIT) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# additional-tags-action | ||
|
||
**A [GitHub Action](https://github.com/features/actions) to create major and minor git tags from the last tag.** | ||
|
||
![GitHub tag](https://img.shields.io/github/v/tag/vweevers/additional-tags-action?sort=semver) | ||
[![License](https://img.shields.io/github/license/vweevers/additional-tags-action)](LICENSE) | ||
|
||
## Usage | ||
|
||
```yaml | ||
on: | ||
push: | ||
tags: | ||
- v[0-9]+.[0-9]+.[0-9]+ | ||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: vweevers/additional-tags-action@v1 | ||
``` | ||
If your tag is `v2.4.8` (for example) then this action will create 2 additional tags (`v2` and `v2.4`) and push them to GitHub, replacing existing tags. If the tag is a prerelease (not x.x.x) or not prefixed with `v` then nothing happens. | ||
|
||
## Why | ||
|
||
Useful to release actions. Consumers of your action can now pin to either a: | ||
|
||
- Major version (`uses: my-action@v2`) | ||
- Minor version (`uses: [email protected]`) | ||
- Exact version (`uses: [email protected]`) | ||
|
||
## Inputs | ||
|
||
None. | ||
|
||
## License | ||
|
||
[MIT](LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name: Additional Tags | ||
description: Create major and minor git tags from the last tag | ||
runs: | ||
using: node12 | ||
main: index.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict' | ||
|
||
const { execFileSync } = require('child_process') | ||
|
||
try { | ||
const maxBuffer = 1024 * 1024 * 16 | ||
const tags = execFileSync('git', ['tag'], { maxBuffer, encoding: 'utf8' }) | ||
const tag = tags.split(/\r?\n/).filter(Boolean).pop() | ||
|
||
if (!tag) { | ||
// Nothing to do | ||
} else if (!/^v\d+\.\d+\.\d+$/.test(tag)) { | ||
console.log('Skipping tag %s', tag) | ||
} else { | ||
const [major, minor] = tag.slice(1).split('.') | ||
const majorTag = 'v' + major | ||
const minorTag = 'v' + major + '.' + minor | ||
|
||
execFileSync('git', ['config', 'user.name', 'github-actions']) | ||
execFileSync('git', ['config', 'user.email', '[email protected]']) | ||
execFileSync('git', ['tag', '-fa', majorTag, '-m', majorTag]) | ||
execFileSync('git', ['tag', '-fa', minorTag, '-m', minorTag]) | ||
execFileSync('git', ['push', '--tags', '-f']) | ||
} | ||
} catch (err) { | ||
console.log('::error::%s', err.message || String(err)) | ||
process.exit(1) | ||
} |