Support version tags that don't start with v for semantic versioning (#303)

* Fixes #242

* Update semver version

* Update husky

* Update husky pre-commit hook

* Update dependencies

* Update dependencies

* Remove git add since changes will be automatically added

* Restore git add

* Update dependencies

* Update test
This commit is contained in:
David Finol 2022-01-02 15:31:48 -06:00 committed by GitHub
parent a3e783f430
commit c45cd78d0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 1021 additions and 962 deletions

1
.husky/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
_

7
.husky/pre-commit Normal file
View File

@ -0,0 +1,7 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged
yarn test
yarn build
git add dist/index.*

BIN
dist/index.js generated vendored

Binary file not shown.

BIN
dist/index.js.map generated vendored

Binary file not shown.

BIN
dist/licenses.txt generated vendored

Binary file not shown.

View File

@ -11,22 +11,24 @@
"build": "tsc && ncc build lib --source-map --license licenses.txt",
"lint": "prettier --check \"src/**/*.{js,ts}\" && eslint src/**/*.ts",
"format": "prettier --write \"src/**/*.{js,ts}\"",
"test": "jest"
"test": "jest",
"prepare": "husky install"
},
"dependencies": {
"@actions/core": "^1.2.6",
"@actions/exec": "^1.0.4",
"@actions/github": "^2.2.0",
"@octokit/core": "^3.5.1",
"aws-sdk": "^2.812.0",
"base-64": "^1.0.0",
"kubernetes-client": "^9.0.0",
"nanoid": "3.1.20",
"semver": "^7.3.2"
"nanoid": "^3.1.20",
"semver": "^7.3.5"
},
"devDependencies": {
"@types/jest": "^26.0.15",
"@types/node": "^14.14.9",
"@types/semver": "^7.3.4",
"@types/semver": "^7.3.5",
"@typescript-eslint/parser": "^4.8.1",
"@vercel/ncc": "^0.25.1",
"eslint": "^7.17.0",
@ -35,20 +37,15 @@
"eslint-plugin-jest": "^24.1.3",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-unicorn": "^28.0.2",
"husky": "4.2.5",
"husky": "^7.0.4",
"jest": "^26.6.3",
"jest-circus": "^26.6.3",
"js-yaml": "^3.14.0",
"lint-staged": "^10.5.4",
"lint-staged": "^12.1.2",
"prettier": "^2.2.1",
"ts-jest": "^26.4.4",
"typescript": "^4.1.3"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged && yarn build && git add dist/index.*"
}
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
"prettier --write",
@ -62,6 +59,7 @@
],
"*.sh": [
"git update-index --chmod=+x"
]
],
"*.js": "eslint --cache --fix"
}
}

View File

@ -128,6 +128,13 @@ describe('Versioning', () => {
},
);
test.each(['1.1-1-g12345678', '0.1-2-g12345678', '0.0-500-gA9B6C3D0-dirty'])(
'accepts valid semantic versions without v-prefix %s',
(description) => {
expect(Versioning.descriptionRegex1.test(description)).toBeTruthy();
},
);
test.each(['v0', 'v0.1', 'v0.1.2', 'v0.1-2', 'v0.1-2-g'])('does not like %s', (description) => {
expect(Versioning.descriptionRegex1.test(description)).toBeFalsy();
// Also never expect without the v to work for any of these cases.

View File

@ -68,15 +68,15 @@ export default class Versioning {
* Regex to parse version description into separate fields
*/
static get descriptionRegex1() {
return /^v([\d.]+)-(\d+)-g(\w+)-?(\w+)*/g;
return /^v?([\d.]+)-(\d+)-g(\w+)-?(\w+)*/g;
}
static get descriptionRegex2() {
return /^v([\d.]+-\w+)-(\d+)-g(\w+)-?(\w+)*/g;
return /^v?([\d.]+-\w+)-(\d+)-g(\w+)-?(\w+)*/g;
}
static get descriptionRegex3() {
return /^v([\d.]+-\w+\.\d+)-(\d+)-g(\w+)-?(\w+)*/g;
return /^v?([\d.]+-\w+\.\d+)-(\d+)-g(\w+)-?(\w+)*/g;
}
static async determineVersion(strategy: string, inputVersion: string) {

1940
yarn.lock

File diff suppressed because it is too large Load Diff