-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework node version tags workflow (#33)
This PR makes the following changes: - ***Important:*** Removed the building and publishing of `terascope/node-base-core` images - This is because there isn't a known use-case for this image - Updated the following github actions: - **actions/checkout** from `v3` to `v4` - **docker/login-action** from `v2` to `v3` - **docker/setup-buildx-action** from `v2` to `v3` - **docker/build-push-action** from `v4` to `v6` - Added new workflow that will build and update image tags based off of the latest major node versions - Added the following labels to the image: - `node_version` - `kafka_connector_version` Ref to issue terascope/teraslice#3683 --------- Co-authored-by: Austin Godber <[email protected]>
- Loading branch information
Showing
6 changed files
with
215 additions
and
38 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
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
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
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
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
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,54 @@ | ||
'use strict' | ||
|
||
let rawSemver = process.argv[2]; | ||
const type = process.argv[3]; | ||
|
||
function isValidSemver(version) { | ||
// Remove leading 'v' if present | ||
if (version.startsWith('v')) { | ||
version = version.slice(1); | ||
} | ||
const semverRegex = /^([0-9]+)\.([0-9]+)\.([0-9]+)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/; | ||
return semverRegex.test(version); | ||
} | ||
|
||
if (rawSemver === undefined || rawSemver === null) { | ||
throw new Error(`Input of first arg is undefined! Input a valid semver.`); | ||
} else if (typeof rawSemver !== 'string') { | ||
throw new Error(`Input must be a string! Got ${typeof rawSemver}`); | ||
} else if (!isValidSemver(rawSemver)) { | ||
throw new Error(`Input ${rawSemver} is not a valid semver format`); | ||
} | ||
|
||
if ( | ||
type === undefined || | ||
type === null || | ||
(type !== 'minor' && type !== 'patch' && type !== 'major') | ||
) { | ||
throw new Error('You must define a type of either "major" "minor" or "patch" as the second argument.'); | ||
} | ||
|
||
function getSemverPart(semver, part) { | ||
// Remove leading 'v' if present | ||
if (semver.startsWith('v')) { | ||
semver = semver.slice(1); | ||
} | ||
const semverRegex = /^([0-9]+)\.([0-9]+)\.([0-9]+)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/; | ||
const match = semver.match(semverRegex); | ||
if (!match) { | ||
throw new Error('Invalid semver format'); | ||
} | ||
switch (part) { | ||
case 'major': | ||
return parseInt(match[1], 10); | ||
case 'minor': | ||
return parseInt(match[2], 10); | ||
case 'patch': | ||
return parseInt(match[3], 10); | ||
default: | ||
throw new Error('Invalid part specified. Use "major", "minor" or "patch".'); | ||
} | ||
} | ||
|
||
|
||
process.stdout.write(getSemverPart(rawSemver, type).toString()); |