Skip to content

Commit 020be30

Browse files
committed
Repackage action following semver bump
GitHub downloads each action run in a workflow during runtime and executes it as a complete package of code before you can use workflow commands like run to interact with the runner machine. This means that we must provide all JavaScript package dependencies as part of the distributed action in order for it to be usable in workflows. A naive approach to doing this is checking in the `node_modules` folder. However, this approach results in a huge amount of frequently changing external content being included in the repository, much of which is not even part of the executed program. A far better approach is to use the excellent ncc tool to compile the program, including all the relevant code from the dependencies, into a single file. We use a "continuous packaging" approach, where the packaged action code that is generated via ncc is always kept in sync with the development source code and dependencies. This allows a beta version of the action to be easily used in workflows by beta testers or those who need changes not in the release simply by using the name of the branch as the action ref (e.g., `uses: arduino/arduino-lint-action@main` will cause the version of the action from the tip of the `main` branch to be used by the workflow run). The update of the package dependency results in a change to the packaged code, so the packaging is here updated accordingly.
1 parent 873cb4d commit 020be30

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

dist/index.js

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8980,7 +8980,7 @@ class SemVer {
89808980

89818981
if (version instanceof SemVer) {
89828982
if (version.loose === !!options.loose &&
8983-
version.includePrerelease === !!options.includePrerelease) {
8983+
version.includePrerelease === !!options.includePrerelease) {
89848984
return version
89858985
} else {
89868986
version = version.version
@@ -9146,6 +9146,19 @@ class SemVer {
91469146
// preminor will bump the version up to the next minor release, and immediately
91479147
// down to pre-release. premajor and prepatch work the same way.
91489148
inc (release, identifier, identifierBase) {
9149+
if (release.startsWith('pre')) {
9150+
if (!identifier && identifierBase === false) {
9151+
throw new Error('invalid increment argument: identifier is empty')
9152+
}
9153+
// Avoid an invalid semver results
9154+
if (identifier) {
9155+
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE])
9156+
if (!match || match[1] !== identifier) {
9157+
throw new Error(`invalid identifier: ${identifier}`)
9158+
}
9159+
}
9160+
}
9161+
91499162
switch (release) {
91509163
case 'premajor':
91519164
this.prerelease.length = 0
@@ -9176,6 +9189,12 @@ class SemVer {
91769189
}
91779190
this.inc('pre', identifier, identifierBase)
91789191
break
9192+
case 'release':
9193+
if (this.prerelease.length === 0) {
9194+
throw new Error(`version ${this.raw} is not a prerelease`)
9195+
}
9196+
this.prerelease.length = 0
9197+
break
91799198

91809199
case 'major':
91819200
// If this is a pre-major version, bump up to the same major version.
@@ -9219,10 +9238,6 @@ class SemVer {
92199238
case 'pre': {
92209239
const base = Number(identifierBase) ? 1 : 0
92219240

9222-
if (!identifier && identifierBase === false) {
9223-
throw new Error('invalid increment argument: identifier is empty')
9224-
}
9225-
92269241
if (this.prerelease.length === 0) {
92279242
this.prerelease = [base]
92289243
} else {
@@ -9481,20 +9496,13 @@ const diff = (version1, version2) => {
94819496
return 'major'
94829497
}
94839498

9484-
// Otherwise it can be determined by checking the high version
9485-
9486-
if (highVersion.patch) {
9487-
// anything higher than a patch bump would result in the wrong version
9499+
// If the main part has no difference
9500+
if (lowVersion.compareMain(highVersion) === 0) {
9501+
if (lowVersion.minor && !lowVersion.patch) {
9502+
return 'minor'
9503+
}
94889504
return 'patch'
94899505
}
9490-
9491-
if (highVersion.minor) {
9492-
// anything higher than a minor bump would result in the wrong version
9493-
return 'minor'
9494-
}
9495-
9496-
// bumping major/minor/patch all have same result
9497-
return 'major'
94989506
}
94999507

95009508
// add the `pre` prefix if we are going to a prerelease version

0 commit comments

Comments
 (0)