Skip to content

Commit cfe3923

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 4edb987 commit cfe3923

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

dist/index.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9404,35 +9404,43 @@ const coerce = (version, options) => {
94049404

94059405
let match = null
94069406
if (!options.rtl) {
9407-
match = version.match(re[t.COERCE])
9407+
match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE])
94089408
} else {
94099409
// Find the right-most coercible string that does not share
94109410
// a terminus with a more left-ward coercible string.
94119411
// Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
9412+
// With includePrerelease option set, '1.2.3.4-rc' wants to coerce '2.3.4-rc', not '2.3.4'
94129413
//
94139414
// Walk through the string checking with a /g regexp
94149415
// Manually set the index so as to pick up overlapping matches.
94159416
// Stop when we get a match that ends at the string end, since no
94169417
// coercible string can be more right-ward without the same terminus.
9418+
const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL]
94179419
let next
9418-
while ((next = re[t.COERCERTL].exec(version)) &&
9420+
while ((next = coerceRtlRegex.exec(version)) &&
94199421
(!match || match.index + match[0].length !== version.length)
94209422
) {
94219423
if (!match ||
94229424
next.index + next[0].length !== match.index + match[0].length) {
94239425
match = next
94249426
}
9425-
re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length
9427+
coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length
94269428
}
94279429
// leave it in a clean state
9428-
re[t.COERCERTL].lastIndex = -1
9430+
coerceRtlRegex.lastIndex = -1
94299431
}
94309432

94319433
if (match === null) {
94329434
return null
94339435
}
94349436

9435-
return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options)
9437+
const major = match[2]
9438+
const minor = match[3] || '0'
9439+
const patch = match[4] || '0'
9440+
const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : ''
9441+
const build = options.includePrerelease && match[6] ? `+${match[6]}` : ''
9442+
9443+
return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options)
94369444
}
94379445
module.exports = coerce
94389446

@@ -10124,12 +10132,17 @@ createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`)
1012410132

1012510133
// Coercion.
1012610134
// Extract anything that could conceivably be a part of a valid semver
10127-
createToken('COERCE', `${'(^|[^\\d])' +
10135+
createToken('COERCEPLAIN', `${'(^|[^\\d])' +
1012810136
'(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
1012910137
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
10130-
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
10138+
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`)
10139+
createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`)
10140+
createToken('COERCEFULL', src[t.COERCEPLAIN] +
10141+
`(?:${src[t.PRERELEASE]})?` +
10142+
`(?:${src[t.BUILD]})?` +
1013110143
`(?:$|[^\\d])`)
1013210144
createToken('COERCERTL', src[t.COERCE], true)
10145+
createToken('COERCERTLFULL', src[t.COERCEFULL], true)
1013310146

1013410147
// Tilde ranges.
1013510148
// Meaning is "reasonably at or greater than"

0 commit comments

Comments
 (0)