Skip to content

Commit 3ea589e

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 1ac5925 commit 3ea589e

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

Diff for: dist/index.js

+25-17
Original file line numberDiff line numberDiff line change
@@ -8226,7 +8226,7 @@ class SemVer {
82268226

82278227
if (version instanceof SemVer) {
82288228
if (version.loose === !!options.loose &&
8229-
version.includePrerelease === !!options.includePrerelease) {
8229+
version.includePrerelease === !!options.includePrerelease) {
82308230
return version
82318231
} else {
82328232
version = version.version
@@ -8392,6 +8392,19 @@ class SemVer {
83928392
// preminor will bump the version up to the next minor release, and immediately
83938393
// down to pre-release. premajor and prepatch work the same way.
83948394
inc (release, identifier, identifierBase) {
8395+
if (release.startsWith('pre')) {
8396+
if (!identifier && identifierBase === false) {
8397+
throw new Error('invalid increment argument: identifier is empty')
8398+
}
8399+
// Avoid an invalid semver results
8400+
if (identifier) {
8401+
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE])
8402+
if (!match || match[1] !== identifier) {
8403+
throw new Error(`invalid identifier: ${identifier}`)
8404+
}
8405+
}
8406+
}
8407+
83958408
switch (release) {
83968409
case 'premajor':
83978410
this.prerelease.length = 0
@@ -8422,6 +8435,12 @@ class SemVer {
84228435
}
84238436
this.inc('pre', identifier, identifierBase)
84248437
break
8438+
case 'release':
8439+
if (this.prerelease.length === 0) {
8440+
throw new Error(`version ${this.raw} is not a prerelease`)
8441+
}
8442+
this.prerelease.length = 0
8443+
break
84258444

84268445
case 'major':
84278446
// If this is a pre-major version, bump up to the same major version.
@@ -8465,10 +8484,6 @@ class SemVer {
84658484
case 'pre': {
84668485
const base = Number(identifierBase) ? 1 : 0
84678486

8468-
if (!identifier && identifierBase === false) {
8469-
throw new Error('invalid increment argument: identifier is empty')
8470-
}
8471-
84728487
if (this.prerelease.length === 0) {
84738488
this.prerelease = [base]
84748489
} else {
@@ -8727,20 +8742,13 @@ const diff = (version1, version2) => {
87278742
return 'major'
87288743
}
87298744

8730-
// Otherwise it can be determined by checking the high version
8731-
8732-
if (highVersion.patch) {
8733-
// anything higher than a patch bump would result in the wrong version
8745+
// If the main part has no difference
8746+
if (lowVersion.compareMain(highVersion) === 0) {
8747+
if (lowVersion.minor && !lowVersion.patch) {
8748+
return 'minor'
8749+
}
87348750
return 'patch'
87358751
}
8736-
8737-
if (highVersion.minor) {
8738-
// anything higher than a minor bump would result in the wrong version
8739-
return 'minor'
8740-
}
8741-
8742-
// bumping major/minor/patch all have same result
8743-
return 'major'
87448752
}
87458753

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

0 commit comments

Comments
 (0)