Migrate to ESM and upgrade dependencies (#135)

* Migrate to ESM

* Use default semver import and root SemVer type

---------

Co-authored-by: gowridurgad <gowridurgad@gmail.com>
This commit is contained in:
gowridurgad
2026-07-22 09:49:51 -05:00
committed by GitHub
co-authored by gowridurgad
parent b699377fdc
commit f7054ee0e4
44 changed files with 13740 additions and 10148 deletions
-6
View File
@@ -1,6 +0,0 @@
# Ignore list
/*
# Do not ignore these folders:
!__tests__/
!src/
-51
View File
@@ -1,51 +0,0 @@
// This is a reusable configuration file copied from https://github.com/actions/reusable-workflows/tree/main/reusable-configurations. Please don't make changes to this file as it's the subject of an automatic update.
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:eslint-plugin-jest/recommended',
'eslint-config-prettier'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'eslint-plugin-node', 'eslint-plugin-jest'],
rules: {
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-ignore': 'allow-with-description'
}
],
'no-console': 'error',
'yoda': 'error',
'prefer-const': [
'error',
{
destructuring: 'all'
}
],
'no-control-regex': 'off',
'no-constant-condition': ['error', {checkLoops: false}],
'node/no-extraneous-import': 'error'
},
overrides: [
{
files: ['**/*{test,spec}.ts'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'jest/no-standalone-expect': 'off',
'jest/no-conditional-expect': 'off',
'no-console': 'off',
}
}
],
env: {
node: true,
es6: true,
'jest/globals': true
}
};
+1
View File
@@ -12,3 +12,4 @@ allowed:
reviewed:
npm:
- "@actions/http-client"
+1 -1
View File
@@ -1,6 +1,6 @@
---
name: "@actions/core"
version: 2.0.3
version: 3.0.1
type: npm
summary: Actions core lib
homepage: https://github.com/actions/toolkit/tree/main/packages/core
+1 -1
View File
@@ -1,6 +1,6 @@
---
name: "@actions/exec"
version: 2.0.0
version: 3.0.0
type: npm
summary: Actions exec lib
homepage: https://github.com/actions/toolkit/tree/main/packages/exec
+1 -1
View File
@@ -1,6 +1,6 @@
---
name: "@actions/github"
version: 7.0.0
version: 9.1.1
type: npm
summary: Actions github lib
homepage: https://github.com/actions/toolkit/tree/main/packages/github
@@ -4,7 +4,7 @@ version: 3.0.2
type: npm
summary: Actions Http Client
homepage: https://github.com/actions/toolkit/tree/main/packages/http-client
license: mit
license: other
licenses:
- sources: LICENSE
text: |
+32
View File
@@ -0,0 +1,32 @@
---
name: "@actions/http-client"
version: 4.0.1
type: npm
summary: Actions Http Client
homepage: https://github.com/actions/toolkit/tree/main/packages/http-client
license: other
licenses:
- sources: LICENSE
text: |
Actions Http Client for Node.js
Copyright (c) GitHub, Inc.
All rights reserved.
MIT License
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.
notices: []
+1 -1
View File
@@ -1,6 +1,6 @@
---
name: "@actions/io"
version: 2.0.0
version: 3.0.2
type: npm
summary: Actions io lib
homepage: https://github.com/actions/toolkit/tree/main/packages/io
+1 -1
View File
@@ -1,6 +1,6 @@
---
name: "@octokit/auth-token"
version: 4.0.0
version: 6.0.0
type: npm
summary: GitHub API token authentication for browsers and Node.js
homepage:
+1 -1
View File
@@ -1,6 +1,6 @@
---
name: "@octokit/core"
version: 5.2.2
version: 7.0.6
type: npm
summary: Extendable client for GitHub's REST & GraphQL APIs
homepage:
+1 -1
View File
@@ -1,6 +1,6 @@
---
name: "@octokit/endpoint"
version: 9.0.6
version: 11.0.3
type: npm
summary: Turns REST API endpoints into generic request options
homepage:
+1 -1
View File
@@ -1,6 +1,6 @@
---
name: "@octokit/graphql"
version: 7.1.1
version: 9.0.3
type: npm
summary: GitHub GraphQL API client for browsers and Node
homepage:
-20
View File
@@ -1,20 +0,0 @@
---
name: "@octokit/openapi-types"
version: 20.0.0
type: npm
summary: Generated TypeScript definitions based on GitHub's OpenAPI spec for api.github.com
homepage:
license: mit
licenses:
- sources: LICENSE
text: |-
Copyright 2020 Gregor Martynus
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.
- sources: README.md
text: "[MIT](LICENSE)"
notices: []
@@ -1,14 +1,14 @@
---
name: "@octokit/openapi-types"
version: 24.2.0
version: 27.0.0
type: npm
summary: Generated TypeScript definitions based on GitHub's OpenAPI spec for api.github.com
homepage:
license: mit
licenses:
- sources: LICENSE
text: |-
Copyright 2020 Gregor Martynus
text: |
Copyright (c) GitHub 2025 - Licensed as 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:
+1 -1
View File
@@ -1,6 +1,6 @@
---
name: "@octokit/plugin-paginate-rest"
version: 9.2.2
version: 14.0.0
type: npm
summary: Octokit plugin to paginate REST API endpoint responses
homepage:
+1 -1
View File
@@ -1,6 +1,6 @@
---
name: "@octokit/plugin-rest-endpoint-methods"
version: 10.4.1
version: 17.0.0
type: npm
summary: Octokit plugin adding one method for all of api.github.com REST API endpoints
homepage:
+1 -1
View File
@@ -1,6 +1,6 @@
---
name: "@octokit/request-error"
version: 5.1.1
version: 7.1.0
type: npm
summary: Error class for Octokit request errors
homepage:
+1 -1
View File
@@ -1,6 +1,6 @@
---
name: "@octokit/request"
version: 8.4.1
version: 10.0.11
type: npm
summary: Send parameterized requests to GitHub's APIs with sensible defaults in browsers
and Node
-20
View File
@@ -1,20 +0,0 @@
---
name: "@octokit/types"
version: 13.10.0
type: npm
summary: Shared TypeScript definitions for Octokit projects
homepage:
license: mit
licenses:
- sources: LICENSE
text: |
MIT License Copyright (c) 2019 Octokit contributors
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 (including the next paragraph) 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.
- sources: README.md
text: "[MIT](LICENSE)"
notices: []
@@ -1,6 +1,6 @@
---
name: "@octokit/types"
version: 12.6.0
version: 16.0.0
type: npm
summary: Shared TypeScript definitions for Octokit projects
homepage:
+1 -1
View File
@@ -1,6 +1,6 @@
---
name: before-after-hook
version: 2.2.3
version: 4.0.0
type: npm
summary: asynchronous before/error/after hooks for internal functionality
homepage:
+47
View File
@@ -0,0 +1,47 @@
---
name: content-type
version: 2.0.0
type: npm
summary: Create and parse HTTP Content-Type header
homepage:
license: mit
licenses:
- sources: LICENSE
text: |
(The MIT License)
Copyright (c) 2015 Douglas Christopher Wilson
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.
- sources: README.md
text: |-
[MIT](LICENSE)
[npm-image]: https://img.shields.io/npm/v/content-type
[npm-url]: https://npmjs.org/package/content-type
[downloads-image]: https://img.shields.io/npm/dm/content-type
[downloads-url]: https://npmjs.org/package/content-type
[build-image]: https://img.shields.io/github/actions/workflow/status/jshttp/content-type/ci.yml?branch=master
[build-url]: https://github.com/jshttp/content-type/actions/workflows/ci.yml?query=branch%3Amaster
[coverage-image]: https://img.shields.io/codecov/c/gh/jshttp/content-type
[coverage-url]: https://codecov.io/gh/jshttp/content-type
[license-image]: http://img.shields.io/npm/l/content-type.svg?style=flat
[license-url]: LICENSE
notices: []
-28
View File
@@ -1,28 +0,0 @@
---
name: deprecation
version: 2.3.1
type: npm
summary: Log a deprecation message with stack
homepage: https://github.com/gr2m/deprecation#readme
license: isc
licenses:
- sources: LICENSE
text: |
The ISC License
Copyright (c) Gregor Martynus and contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- sources: README.md
text: "[ISC](LICENSE)"
notices: []
+33
View File
@@ -0,0 +1,33 @@
---
name: json-with-bigint
version: 3.5.8
type: npm
summary: JS library that allows you to easily serialize and deserialize data with
BigInt values
homepage:
license: mit
licenses:
- sources: LICENSE
text: |
MIT License
Copyright (c) 2023 Ivan Korolenko
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.
notices: []
-26
View File
@@ -1,26 +0,0 @@
---
name: once
version: 1.4.0
type: npm
summary: Run a function exactly one time
homepage: https://github.com/isaacs/once#readme
license: isc
licenses:
- sources: LICENSE
text: |
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
notices: []
+1 -1
View File
@@ -1,6 +1,6 @@
---
name: semver
version: 7.7.1
version: 7.8.5
type: npm
summary: The semantic version parser used by npm.
homepage:
+3 -3
View File
@@ -1,8 +1,8 @@
---
name: universal-user-agent
version: 6.0.1
version: 7.0.3
type: npm
summary: Get a user agent string in both browser and node
summary: Get a user agent string across all JavaScript Runtime Environments
homepage:
license: isc
licenses:
@@ -10,7 +10,7 @@ licenses:
text: |
# [ISC License](https://spdx.org/licenses/ISC)
Copyright (c) 2018, Gregor Martynus (https://github.com/gr2m)
Copyright (c) 2018-2021, Gregor Martynus (https://github.com/gr2m)
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
-26
View File
@@ -1,26 +0,0 @@
---
name: wrappy
version: 1.0.2
type: npm
summary: Callback wrapping utility
homepage: https://github.com/npm/wrappy
license: isc
licenses:
- sources: LICENSE
text: |
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
notices: []
-11
View File
@@ -1,11 +0,0 @@
// This is a reusable configuration file copied from https://github.com/actions/reusable-workflows/tree/main/reusable-configurations. Please don't make changes to this file as it's the subject of an automatic update.
module.exports = {
printWidth: 80,
tabWidth: 2,
useTabs: false,
semi: true,
singleQuote: true,
trailingComma: 'none',
bracketSpacing: false,
arrowParens: 'avoid'
};
+10
View File
@@ -0,0 +1,10 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid"
}
+13 -6
View File
@@ -1,13 +1,20 @@
import {jest, describe, it, expect, beforeEach, afterEach} from '@jest/globals';
import * as github from '@actions/github';
import * as apiUtils from '../src/api-utils';
import * as apiUtils from '../src/api-utils.js';
import prereleaseData from './data/pre-release.json';
import releaseData from './data/release.json';
import prereleaseData from './data/pre-release.json' with {type: 'json'};
import releaseData from './data/release.json' with {type: 'json'};
const token = 'faketoken';
const octokitClient = github.getOctokit(token);
let getReleaseSpy: jest.SpyInstance;
type GetReleaseByTagResponse = Awaited<
ReturnType<typeof octokitClient.rest.repos.getReleaseByTag>
>;
let getReleaseSpy: jest.SpiedFunction<
typeof octokitClient.rest.repos.getReleaseByTag
>;
process.env.GITHUB_REPOSITORY = 'test/repository';
@@ -17,7 +24,7 @@ describe('validateIfReleaseIsPublished', () => {
});
it('throw if release is marked as pre-release', async () => {
getReleaseSpy.mockReturnValue(prereleaseData);
getReleaseSpy.mockResolvedValue(prereleaseData as GetReleaseByTagResponse);
expect.assertions(1);
await expect(
@@ -28,7 +35,7 @@ describe('validateIfReleaseIsPublished', () => {
});
it('validate that release is published', async () => {
getReleaseSpy.mockReturnValue(releaseData);
getReleaseSpy.mockResolvedValue(releaseData as GetReleaseByTagResponse);
expect.assertions(1);
await expect(
+6 -5
View File
@@ -1,8 +1,9 @@
import * as versionUtils from '../src/version-utils';
import stableSemver from './data/stable-semver.json';
import stableBuildSemver from './data/stable-build-semver.json';
import prereleaseSemver from './data/prerelease-semver.json';
import prereleaseBuildSemver from './data/prerelease-build-semver.json';
import {describe, it, expect} from '@jest/globals';
import * as versionUtils from '../src/version-utils.js';
import stableSemver from './data/stable-semver.json' with {type: 'json'};
import stableBuildSemver from './data/stable-build-semver.json' with {type: 'json'};
import prereleaseSemver from './data/prerelease-semver.json' with {type: 'json'};
import prereleaseBuildSemver from './data/prerelease-build-semver.json' with {type: 'json'};
describe('isStableSemverVersion', () => {
it('validate if a version is stable', () => {
+10515 -8087
View File
File diff suppressed because one or more lines are too long
+3
View File
@@ -0,0 +1,3 @@
{
"type": "module"
}
+74
View File
@@ -0,0 +1,74 @@
// This is a reusable configuration file copied from https://github.com/actions/reusable-workflows/tree/main/reusable-configurations. Please don't make changes to this file as it's the subject of an automatic update.
import js from '@eslint/js';
import tsParser from '@typescript-eslint/parser';
import tsPlugin from '@typescript-eslint/eslint-plugin';
import jest from 'eslint-plugin-jest';
import n from 'eslint-plugin-n';
import prettier from 'eslint-config-prettier';
import globals from 'globals';
export default [
{
ignores: ['**/*', '!src/**', '!__tests__/**']
},
js.configs.recommended,
{
files: ['**/*.ts'],
languageOptions: {
parser: tsParser,
ecmaVersion: 2022,
sourceType: 'module',
globals: {
...globals.node,
...globals.es2015
}
},
plugins: {
'@typescript-eslint': tsPlugin,
n
},
rules: {
...tsPlugin.configs.recommended.rules,
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-ignore': 'allow-with-description'
}
],
'no-console': 'error',
yoda: 'error',
'prefer-const': [
'error',
{
destructuring: 'all'
}
],
'no-control-regex': 'off',
'no-constant-condition': ['error', {checkLoops: false}],
'no-undef': 'off',
'no-useless-assignment': 'off',
'n/no-extraneous-import': 'error'
}
},
{
files: ['**/*{test,spec}.ts'],
plugins: {jest},
languageOptions: {
globals: {
...globals.jest
}
},
rules: {
...jest.configs['flat/recommended'].rules,
'@typescript-eslint/no-unused-vars': 'off',
'jest/no-standalone-expect': 'off',
'jest/no-conditional-expect': 'off',
'no-console': 'off'
}
},
prettier
];
-11
View File
@@ -1,11 +0,0 @@
module.exports = {
clearMocks: true,
moduleFileExtensions: ['js', 'ts'],
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
testRunner: 'jest-circus/runner',
transform: {
'^.+\\.ts$': 'ts-jest'
},
verbose: true
}
+27
View File
@@ -0,0 +1,27 @@
import type {JestConfigWithTsJest} from 'ts-jest';
const jestConfig: JestConfigWithTsJest = {
clearMocks: true,
moduleFileExtensions: ['js', 'ts'],
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
extensionsToTreatAsEsm: ['.ts'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1'
},
transform: {
'^.+\\.ts$': [
'ts-jest',
{
useESM: true,
diagnostics: {
ignoreCodes: [151002]
}
}
]
},
transformIgnorePatterns: ['node_modules/(?!(@actions)/)'],
verbose: true
};
export default jestConfig;
+2904 -1780
View File
File diff suppressed because it is too large Load Diff
+29 -29
View File
@@ -1,18 +1,19 @@
{
"name": "publish-action",
"version": "0.4.0",
"version": "0.5.0",
"type": "module",
"description": "Update the major version tag (v1, v2, etc.) to point to the specified tag",
"main": "lib/main.js",
"main": "dist/index.js",
"engines": {
"node": ">=24.0.0"
},
"scripts": {
"build": "tsc && ncc build",
"test": "jest",
"format": "prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --write \"**/*.{ts,yml,yaml}\"",
"format-check": "prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --check \"**/*.{ts,yml,yaml}\"",
"lint": "eslint --config ./.eslintrc.js \"**/*.ts\"",
"lint:fix": "eslint --config ./.eslintrc.js \"**/*.ts\" --fix"
"build": "tsc && ncc build src/main.ts -o dist",
"test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --runInBand",
"format": "prettier --no-error-on-unmatched-pattern --write \"**/*.{ts,yml,yaml}\"",
"format-check": "prettier --no-error-on-unmatched-pattern --check \"**/*.{ts,yml,yaml}\"",
"lint": "eslint \"**/*.ts\"",
"lint:fix": "eslint \"**/*.ts\" --fix"
},
"repository": {
"type": "git",
@@ -29,28 +30,27 @@
},
"homepage": "https://github.com/actions/publish-action#readme",
"dependencies": {
"@actions/core": "^2.0.3",
"@actions/github": "^7.0.0",
"@actions/http-client": "^3.0.2",
"semver": "^7.7.1"
"@actions/core": "^3.0.1",
"@actions/github": "^9.1.1",
"@actions/http-client": "^4.0.1",
"semver": "^7.8.5"
},
"devDependencies": {
"@types/jest": "^29.5.14",
"@types/semver": "^7.5.8",
"@typescript-eslint/eslint-plugin": "^8.31.1",
"@typescript-eslint/parser": "^8.31.1",
"@vercel/ncc": "^0.38.1",
"eslint": "^8.35.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-jest": "^28.11.0",
"eslint-plugin-node": "^11.1.0",
"jest": "^29.7.0",
"jest-circus": "^29.7.0",
"prettier": "^3.5.3",
"ts-jest": "^29.1.1",
"typescript": "^5.3.2"
},
"overrides": {
"undici": "^6.24.1"
"@eslint/js": "^10.0.1",
"@jest/globals": "^30.4.1",
"@types/node": "^26.1.1",
"@types/semver": "^7.7.1",
"@typescript-eslint/eslint-plugin": "^8.63.0",
"@typescript-eslint/parser": "^8.63.0",
"@vercel/ncc": "^0.44.1",
"eslint": "^10.6.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-jest": "^29.15.4",
"eslint-plugin-n": "^18.2.1",
"globals": "^17.7.0",
"jest": "^30.4.2",
"prettier": "^3.9.4",
"ts-jest": "^29.4.11",
"typescript": "^6.0.3"
}
}
+14 -11
View File
@@ -1,8 +1,10 @@
import * as core from '@actions/core';
import * as github from '@actions/github';
import {context} from '@actions/github';
import {GitHub} from '@actions/github/lib/utils';
import {HttpClient} from '@actions/http-client';
type Octokit = ReturnType<typeof github.getOctokit>;
interface GitRef {
ref: string;
node_id: string;
@@ -20,7 +22,7 @@ interface ErrorStatus extends Error {
async function findTag(
tag: string,
octokitClient: InstanceType<typeof GitHub>
octokitClient: Octokit
): Promise<GitRef | null> {
try {
const {data: foundTag} = await octokitClient.rest.git.getRef({
@@ -34,16 +36,14 @@ async function findTag(
return null;
} else {
throw new Error(
`Retrieving refs failed with the following error: ${err}`
`Retrieving refs failed with the following error: ${err}`,
{cause: err}
);
}
}
}
async function getTagSHA(
tag: string,
octokitClient: InstanceType<typeof GitHub>
): Promise<string> {
async function getTagSHA(tag: string, octokitClient: Octokit): Promise<string> {
const foundTag = await findTag(tag, octokitClient);
if (!foundTag) {
throw new Error(`The '${tag}' tag does not exist in the remote repository`);
@@ -54,7 +54,7 @@ async function getTagSHA(
export async function validateIfReleaseIsPublished(
tag: string,
octokitClient: InstanceType<typeof GitHub>
octokitClient: Octokit
): Promise<void> {
try {
const {data: foundRelease} = await octokitClient.rest.repos.getReleaseByTag(
@@ -71,10 +71,13 @@ export async function validateIfReleaseIsPublished(
}
} catch (err) {
if ((err as ErrorStatus).status === 404) {
throw new Error(`No GitHub release found for the ${tag} tag`);
throw new Error(`No GitHub release found for the ${tag} tag`, {
cause: err
});
} else {
throw new Error(
`Retrieving releases failed with the following error: ${err}`
`Retrieving releases failed with the following error: ${err}`,
{cause: err}
);
}
}
@@ -83,7 +86,7 @@ export async function validateIfReleaseIsPublished(
export async function updateTag(
sourceTag: string,
targetTag: string,
octokitClient: InstanceType<typeof GitHub>
octokitClient: Octokit
): Promise<void> {
const sourceTagSHA = await getTagSHA(sourceTag, octokitClient);
const foundTargetTag = await findTag(targetTag, octokitClient);
+2 -2
View File
@@ -5,11 +5,11 @@ import {
updateTag,
validateIfReleaseIsPublished,
postMessageToSlack
} from './api-utils';
} from './api-utils.js';
import {
validateSemverVersionFromTag,
getMajorTagFromFullTag
} from './version-utils';
} from './version-utils.js';
async function run(): Promise<void> {
try {
+3 -3
View File
@@ -1,5 +1,5 @@
import semverParse from 'semver/functions/parse';
import SemVer from 'semver/classes/semver';
import semver from 'semver';
import type {SemVer} from 'semver';
export function isStableSemverVersion(version: SemVer): boolean {
return version.prerelease.length === 0;
@@ -10,7 +10,7 @@ export function getMajorTagFromFullTag(fullTag: string): string {
}
export function validateSemverVersionFromTag(tag: string): void {
const semverVersion = semverParse(tag);
const semverVersion = semver.parse(tag);
if (!semverVersion) {
throw new Error(
`The '${tag}' doesn't satisfy semantic versioning specification`
+5 -4
View File
@@ -1,7 +1,8 @@
{
"compilerOptions": {
"target": "ES2019",
"module": "commonjs",
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"outDir": "./lib",
"rootDir": "./src",
"esModuleInterop": true,
@@ -16,5 +17,5 @@
"noImplicitReturns": true
},
"include": ["./src/**/*.ts"],
"exclude": ["node_modules"]
}
"exclude": ["node_modules", "**/*.test.ts", "jest.config.ts"]
}