Skip to content

Commit 259089b

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 c94ee1c commit 259089b

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
@@ -9957,35 +9957,43 @@ const coerce = (version, options) => {
99579957

99589958
let match = null
99599959
if (!options.rtl) {
9960-
match = version.match(re[t.COERCE])
9960+
match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE])
99619961
} else {
99629962
// Find the right-most coercible string that does not share
99639963
// a terminus with a more left-ward coercible string.
99649964
// Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
9965+
// With includePrerelease option set, '1.2.3.4-rc' wants to coerce '2.3.4-rc', not '2.3.4'
99659966
//
99669967
// Walk through the string checking with a /g regexp
99679968
// Manually set the index so as to pick up overlapping matches.
99689969
// Stop when we get a match that ends at the string end, since no
99699970
// coercible string can be more right-ward without the same terminus.
9971+
const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL]
99709972
let next
9971-
while ((next = re[t.COERCERTL].exec(version)) &&
9973+
while ((next = coerceRtlRegex.exec(version)) &&
99729974
(!match || match.index + match[0].length !== version.length)
99739975
) {
99749976
if (!match ||
99759977
next.index + next[0].length !== match.index + match[0].length) {
99769978
match = next
99779979
}
9978-
re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length
9980+
coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length
99799981
}
99809982
// leave it in a clean state
9981-
re[t.COERCERTL].lastIndex = -1
9983+
coerceRtlRegex.lastIndex = -1
99829984
}
99839985

99849986
if (match === null) {
99859987
return null
99869988
}
99879989

9988-
return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options)
9990+
const major = match[2]
9991+
const minor = match[3] || '0'
9992+
const patch = match[4] || '0'
9993+
const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : ''
9994+
const build = options.includePrerelease && match[6] ? `+${match[6]}` : ''
9995+
9996+
return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options)
99899997
}
99909998
module.exports = coerce
99919999

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

1067810686
// Coercion.
1067910687
// Extract anything that could conceivably be a part of a valid semver
10680-
createToken('COERCE', `${'(^|[^\\d])' +
10688+
createToken('COERCEPLAIN', `${'(^|[^\\d])' +
1068110689
'(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
1068210690
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
10683-
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
10691+
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`)
10692+
createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`)
10693+
createToken('COERCEFULL', src[t.COERCEPLAIN] +
10694+
`(?:${src[t.PRERELEASE]})?` +
10695+
`(?:${src[t.BUILD]})?` +
1068410696
`(?:$|[^\\d])`)
1068510697
createToken('COERCERTL', src[t.COERCE], true)
10698+
createToken('COERCERTLFULL', src[t.COERCEFULL], true)
1068610699

1068710700
// Tilde ranges.
1068810701
// Meaning is "reasonably at or greater than"

0 commit comments

Comments
 (0)