Compare commits
26 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
9d35d648e8 | |
|
|
17d01dc92c | |
|
|
f36074fe49 | |
|
|
f40d7eefd8 | |
|
|
1bf7977a3d | |
|
|
5a16d14432 | |
|
|
71c3689659 | |
|
|
a079ba461d | |
|
|
86301c823d | |
|
|
5bd9038fd1 | |
|
|
ac8cb38838 | |
|
|
664437484d | |
|
|
87d9c10c43 | |
|
|
dbd80d2e9d | |
|
|
a1afa112d3 | |
|
|
3f9dffdaa0 | |
|
|
c4f56e7003 | |
|
|
923acce875 | |
|
|
c5ababce46 | |
|
|
e923a6115f | |
|
|
8bee2b2289 | |
|
|
92dc56ebab | |
|
|
15886d3d8c | |
|
|
f1a52e6b0e | |
|
|
672968b48d | |
|
|
ba54fd76a5 |
|
|
@ -0,0 +1 @@
|
|||
github: [mathieudutour]
|
||||
|
|
@ -9,7 +9,10 @@ jobs:
|
|||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: package.json
|
||||
- run: npm ci
|
||||
- run: npm run test
|
||||
- run: npm run check
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ jobs:
|
|||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- name: Bump version and push tag
|
||||
id: tag_version
|
||||
uses: mathieudutour/github-tag-action@v6.0
|
||||
uses: mathieudutour/github-tag-action@v6.2
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Create a GitHub release
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ outputs:
|
|||
description: "Generated tag without the prefix"
|
||||
previous_tag:
|
||||
description: "Previous tag (or `0.0.0`)"
|
||||
previous_version:
|
||||
description: "The value of the previous tag (or 0.0.0 if none) without the prefix. Note that if custom_tag is set, this will be undefined."
|
||||
release_type:
|
||||
description: "The computed release type (`major`, `minor`, `patch` or `custom` - can be prefixed with `pre`)"
|
||||
changelog:
|
||||
|
|
@ -61,7 +63,7 @@ inputs:
|
|||
default: "false"
|
||||
|
||||
runs:
|
||||
using: "node12"
|
||||
using: "node20"
|
||||
main: "lib/main.js"
|
||||
branding:
|
||||
icon: "git-merge"
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "github-tag-action",
|
||||
"version": "6.0.0",
|
||||
"version": "6.2.0",
|
||||
"private": true,
|
||||
"description": "A GitHub Action to automatically bump and tag master, on merge, with the latest SemVer formatted version.",
|
||||
"main": "lib/main.js",
|
||||
|
|
@ -18,10 +18,13 @@
|
|||
"node",
|
||||
"setup"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"author": "Mathieu Dutour",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.6.0",
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/exec": "^1.1.0",
|
||||
"@actions/github": "^4.0.0",
|
||||
"@semantic-release/commit-analyzer": "^8.0.1",
|
||||
|
|
@ -33,7 +36,7 @@
|
|||
"@octokit/rest": "^18.12.0",
|
||||
"@types/jest": "^27.0.2",
|
||||
"@types/js-yaml": "^4.0.4",
|
||||
"@types/node": "^16.11.7",
|
||||
"@types/node": "^20.11.16",
|
||||
"@types/semver": "^7.3.9",
|
||||
"jest": "^27.3.1",
|
||||
"jest-circus": "^27.3.1",
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@ export default async function main() {
|
|||
const releaseBranches = core.getInput('release_branches');
|
||||
const preReleaseBranches = core.getInput('pre_release_branches');
|
||||
const appendToPreReleaseTag = core.getInput('append_to_pre_release_tag');
|
||||
const createAnnotatedTag = !!core.getInput('create_annotated_tag');
|
||||
const createAnnotatedTag = /true/i.test(
|
||||
core.getInput('create_annotated_tag')
|
||||
);
|
||||
const dryRun = core.getInput('dry_run');
|
||||
const customReleaseRules = core.getInput('custom_release_rules');
|
||||
const shouldFetchAllTags = core.getInput('fetch_all_tags');
|
||||
|
|
|
|||
14
src/utils.ts
14
src/utils.ts
|
|
@ -15,13 +15,17 @@ export async function getValidTags(
|
|||
const tags = await listTags(shouldFetchAllTags);
|
||||
|
||||
const invalidTags = tags.filter(
|
||||
(tag) => !valid(tag.name.replace(prefixRegex, ''))
|
||||
(tag) =>
|
||||
!prefixRegex.test(tag.name) || !valid(tag.name.replace(prefixRegex, ''))
|
||||
);
|
||||
|
||||
invalidTags.forEach((name) => core.debug(`Found Invalid Tag: ${name}.`));
|
||||
|
||||
const validTags = tags
|
||||
.filter((tag) => valid(tag.name.replace(prefixRegex, '')))
|
||||
.filter(
|
||||
(tag) =>
|
||||
prefixRegex.test(tag.name) && valid(tag.name.replace(prefixRegex, ''))
|
||||
)
|
||||
.sort((a, b) =>
|
||||
rcompare(a.name.replace(prefixRegex, ''), b.name.replace(prefixRegex, ''))
|
||||
);
|
||||
|
|
@ -59,7 +63,11 @@ export function getLatestTag(
|
|||
tagPrefix: string
|
||||
) {
|
||||
return (
|
||||
tags.find((tag) => !prerelease(tag.name.replace(prefixRegex, ''))) || {
|
||||
tags.find(
|
||||
(tag) =>
|
||||
prefixRegex.test(tag.name) &&
|
||||
!prerelease(tag.name.replace(prefixRegex, ''))
|
||||
) || {
|
||||
name: `${tagPrefix}0.0.0`,
|
||||
commit: {
|
||||
sha: 'HEAD',
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ describe('utils', () => {
|
|||
node_id: 'string',
|
||||
},
|
||||
{
|
||||
name: '1.2.3',
|
||||
name: 'v1.2.3',
|
||||
commit: { sha: 'string', url: 'string' },
|
||||
zipball_url: 'string',
|
||||
tarball_url: 'string',
|
||||
|
|
@ -86,28 +86,28 @@ describe('utils', () => {
|
|||
*/
|
||||
const testTags = [
|
||||
{
|
||||
name: '1.2.4-prerelease.1',
|
||||
name: 'v1.2.4-prerelease.1',
|
||||
commit: { sha: 'string', url: 'string' },
|
||||
zipball_url: 'string',
|
||||
tarball_url: 'string',
|
||||
node_id: 'string',
|
||||
},
|
||||
{
|
||||
name: '1.2.4-prerelease.2',
|
||||
name: 'v1.2.4-prerelease.2',
|
||||
commit: { sha: 'string', url: 'string' },
|
||||
zipball_url: 'string',
|
||||
tarball_url: 'string',
|
||||
node_id: 'string',
|
||||
},
|
||||
{
|
||||
name: '1.2.4-prerelease.0',
|
||||
name: 'v1.2.4-prerelease.0',
|
||||
commit: { sha: 'string', url: 'string' },
|
||||
zipball_url: 'string',
|
||||
tarball_url: 'string',
|
||||
node_id: 'string',
|
||||
},
|
||||
{
|
||||
name: '1.2.3',
|
||||
name: 'v1.2.3',
|
||||
commit: { sha: 'string', url: 'string' },
|
||||
zipball_url: 'string',
|
||||
tarball_url: 'string',
|
||||
|
|
@ -128,7 +128,55 @@ describe('utils', () => {
|
|||
*/
|
||||
expect(mockListTags).toHaveBeenCalled();
|
||||
expect(validTags[0]).toEqual({
|
||||
name: '1.2.4-prerelease.2',
|
||||
name: 'v1.2.4-prerelease.2',
|
||||
commit: { sha: 'string', url: 'string' },
|
||||
zipball_url: 'string',
|
||||
tarball_url: 'string',
|
||||
node_id: 'string',
|
||||
});
|
||||
});
|
||||
|
||||
it('returns only prefixed tags', async () => {
|
||||
/*
|
||||
* Given
|
||||
*/
|
||||
const testTags = [
|
||||
{
|
||||
name: 'app2/5.0.0',
|
||||
commit: { sha: 'string', url: 'string' },
|
||||
zipball_url: 'string',
|
||||
tarball_url: 'string',
|
||||
node_id: 'string',
|
||||
},
|
||||
{
|
||||
name: '7.0.0',
|
||||
commit: { sha: 'string', url: 'string' },
|
||||
zipball_url: 'string',
|
||||
tarball_url: 'string',
|
||||
node_id: 'string',
|
||||
},
|
||||
{
|
||||
name: 'app1/3.0.0',
|
||||
commit: { sha: 'string', url: 'string' },
|
||||
zipball_url: 'string',
|
||||
tarball_url: 'string',
|
||||
node_id: 'string',
|
||||
},
|
||||
];
|
||||
const mockListTags = jest
|
||||
.spyOn(github, 'listTags')
|
||||
.mockImplementation(async () => testTags);
|
||||
/*
|
||||
* When
|
||||
*/
|
||||
const validTags = await getValidTags(/^app1\//, false);
|
||||
/*
|
||||
* Then
|
||||
*/
|
||||
expect(mockListTags).toHaveBeenCalled();
|
||||
expect(validTags).toHaveLength(1);
|
||||
expect(validTags[0]).toEqual({
|
||||
name: 'app1/3.0.0',
|
||||
commit: { sha: 'string', url: 'string' },
|
||||
zipball_url: 'string',
|
||||
tarball_url: 'string',
|
||||
|
|
|
|||
Loading…
Reference in New Issue