neiam
/action-setup-beam
action-setup-beam
public · Issues · Pulls · Labels · Forks · Compare · Actions queued
⭐
Log in to mark this repository.
Test for updated doc. on `latest` / ranges / `-rc` (#349)
6a38171 · Paulo F. Oliveira · 2025-06-26 19:39
Message
{commit_body(@commit)}
Files changed
modified
README.md
+15
−9
@@ -53,19 +53,25 @@ end up being parsed as `23`, which is not equivalent.
| 53 | 53 | |
| 54 | 54 | #### Pre-release versions |
| 55 | 55 | |
| 56 | −For pre-release versions, such as `v1.11.0-rc.0`, use the full version | |
| 57 | −specifier (`v1.11.0-rc.0`) and set option `version-type` to `strict`. Pre-release versions are | |
| 58 | −opt-in, so `1.11.x` will not match a pre-release. | |
| 56 | +To use a pre-release version such as `v1.11.0-rc.0`, specify the exact version | |
| 57 | +(`v1.11.0-rc.0`) and set `version-type` to `strict`. | |
| 58 | +Note that pre-release versions are opt-in by default. | |
| 59 | +Patterns like `1.11.x` do not include pre-release versions unless `latest` is specified. | |
| 59 | 60 | |
| 60 | 61 | #### "Latest" versions |
| 61 | 62 | |
| 62 | −Set a tool's version to `latest` to retrieve the latest version of a given tool. | |
| 63 | −The latest version is (locally) calculated by the action based on the (retrieved) versions | |
| 64 | −it knows (**note**: it is not the same as [GitHub considers it](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository) | |
| 65 | −and some repositories might propose). | |
| 63 | +To retrieve the most recent available version of a tool, set the version to `latest`. | |
| 64 | +This may include pre-release versions such as release candidates. | |
| 66 | 65 | |
| 67 | −If in doubt do a test run and compare the obtained release with the one you were expecting to | |
| 68 | −be the latest. | |
| 66 | +If you want to target only the latest stable release and exclude pre-releases, use a | |
| 67 | +version range like `> 0` instead. | |
| 68 | + | |
| 69 | +Note that the `latest` version is determined locally by the action based on the versions it | |
| 70 | +has retrieved. This may differ from how [GitHub defines "latest"](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository), | |
| 71 | +and some repositories may present different interpretations. | |
| 72 | + | |
| 73 | +If you're unsure, perform a test run and compare the resolved version against the version you | |
| 74 | +expect to be considered the latest. | |
| 69 | 75 | |
| 70 | 76 | ### Compatibility between Operating System and Erlang/OTP |
| 71 | 77 |
modified
dist/index.js
+15
−4
@@ -26323,6 +26323,7 @@ function validVersion(v) {
| 26323 | 26323 | v.match( |
| 26324 | 26324 | new RegExp(`${knownBranches.join('|')}|${nonSpecificVersions.join('|')}`), |
| 26325 | 26325 | ) == null && |
| 26326 | + // these ones are for rebar3, which has alpha and beta releases | |
| 26326 | 26327 | !v.startsWith('a') && |
| 26327 | 26328 | !v.startsWith('b') |
| 26328 | 26329 | ) |
@@ -26349,7 +26350,12 @@ function getVersionFromSpec(spec0, versions0) {
| 26349 | 26350 | const altVersions = {} |
| 26350 | 26351 | Object.entries(versions0).forEach(([version, altVersion]) => { |
| 26351 | 26352 | let coerced |
| 26352 | − if (isStrictVersion() || isRC(version)) { | |
| 26353 | + if ( | |
| 26354 | + isStrictVersion() || | |
| 26355 | + isRC(version) || | |
| 26356 | + isKnownBranch(version) || | |
| 26357 | + isKnownVerBranch(version) | |
| 26358 | + ) { | |
| 26353 | 26359 | // If `version-type: strict` or version is RC, we just try to remove a potential initial v |
| 26354 | 26360 | coerced = maybeRemoveVPrefix(version) |
| 26355 | 26361 | } else { |
@@ -26367,9 +26373,14 @@ function getVersionFromSpec(spec0, versions0) {
| 26367 | 26373 | const rangeMax = semver.maxSatisfying(versions, rangeForMax) |
| 26368 | 26374 | let version = null |
| 26369 | 26375 | |
| 26370 | − if (isStrictVersion() || isRC(spec0) || isKnownBranch(spec0)) { | |
| 26376 | + if ( | |
| 26377 | + isStrictVersion() || | |
| 26378 | + isRC(spec0) || | |
| 26379 | + isKnownBranch(spec0) || | |
| 26380 | + isKnownVerBranch(spec0) | |
| 26381 | + ) { | |
| 26371 | 26382 | if (versions0[spec]) { |
| 26372 | − // If `version-type: strict` or version is RC, we obtain it directly | |
| 26383 | + // We obtain it directly | |
| 26373 | 26384 | version = versions0[spec] |
| 26374 | 26385 | } |
| 26375 | 26386 | } else if (spec0 === 'latest') { |
@@ -26592,7 +26603,7 @@ function xyzAbcVersion(pref, suf) {
| 26592 | 26603 | // https://www.erlang.org/doc/system_principles/versions.html |
| 26593 | 26604 | const dd = '\\.?(\\d+)?' |
| 26594 | 26605 | return new RegExp( |
| 26595 | − `${pref}v?(\\d+)${dd}${dd}${dd}${dd}${dd}(?:-rc\\.?\\d+)?(?:-otp-\\d+)?${suf}`, | |
| 26606 | + `${pref}(?:OTP-)?v?(\\d+)${dd}${dd}${dd}${dd}${dd}(?:-rc\\.?\\d+)?(?:-otp-\\d+)?${suf}`, | |
| 26596 | 26607 | ) |
| 26597 | 26608 | } |
| 26598 | 26609 |
modified
src/setup-beam.js
+15
−4
@@ -448,6 +448,7 @@ function validVersion(v) {
| 448 | 448 | v.match( |
| 449 | 449 | new RegExp(`${knownBranches.join('|')}|${nonSpecificVersions.join('|')}`), |
| 450 | 450 | ) == null && |
| 451 | + // these ones are for rebar3, which has alpha and beta releases | |
| 451 | 452 | !v.startsWith('a') && |
| 452 | 453 | !v.startsWith('b') |
| 453 | 454 | ) |
@@ -474,7 +475,12 @@ function getVersionFromSpec(spec0, versions0) {
| 474 | 475 | const altVersions = {} |
| 475 | 476 | Object.entries(versions0).forEach(([version, altVersion]) => { |
| 476 | 477 | let coerced |
| 477 | − if (isStrictVersion() || isRC(version)) { | |
| 478 | + if ( | |
| 479 | + isStrictVersion() || | |
| 480 | + isRC(version) || | |
| 481 | + isKnownBranch(version) || | |
| 482 | + isKnownVerBranch(version) | |
| 483 | + ) { | |
| 478 | 484 | // If `version-type: strict` or version is RC, we just try to remove a potential initial v |
| 479 | 485 | coerced = maybeRemoveVPrefix(version) |
| 480 | 486 | } else { |
@@ -492,9 +498,14 @@ function getVersionFromSpec(spec0, versions0) {
| 492 | 498 | const rangeMax = semver.maxSatisfying(versions, rangeForMax) |
| 493 | 499 | let version = null |
| 494 | 500 | |
| 495 | − if (isStrictVersion() || isRC(spec0) || isKnownBranch(spec0)) { | |
| 501 | + if ( | |
| 502 | + isStrictVersion() || | |
| 503 | + isRC(spec0) || | |
| 504 | + isKnownBranch(spec0) || | |
| 505 | + isKnownVerBranch(spec0) | |
| 506 | + ) { | |
| 496 | 507 | if (versions0[spec]) { |
| 497 | − // If `version-type: strict` or version is RC, we obtain it directly | |
| 508 | + // We obtain it directly | |
| 498 | 509 | version = versions0[spec] |
| 499 | 510 | } |
| 500 | 511 | } else if (spec0 === 'latest') { |
@@ -717,7 +728,7 @@ function xyzAbcVersion(pref, suf) {
| 717 | 728 | // https://www.erlang.org/doc/system_principles/versions.html |
| 718 | 729 | const dd = '\\.?(\\d+)?' |
| 719 | 730 | return new RegExp( |
| 720 | − `${pref}v?(\\d+)${dd}${dd}${dd}${dd}${dd}(?:-rc\\.?\\d+)?(?:-otp-\\d+)?${suf}`, | |
| 731 | + `${pref}(?:OTP-)?v?(\\d+)${dd}${dd}${dd}${dd}${dd}(?:-rc\\.?\\d+)?(?:-otp-\\d+)?${suf}`, | |
| 721 | 732 | ) |
| 722 | 733 | } |
| 723 | 734 |
modified
test/setup-beam.test.js
+20
−0
@@ -875,11 +875,31 @@ describe('.getVersionFromSpec(_)', () => {
| 875 | 875 | got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-20.04']) |
| 876 | 876 | assert.deepStrictEqual(got, expected) |
| 877 | 877 | |
| 878 | + spec = 'maint-24' | |
| 879 | + expected = 'maint-24' | |
| 880 | + got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-22.04']) | |
| 881 | + assert.deepStrictEqual(got, expected) | |
| 882 | + | |
| 883 | + spec = '> 0' | |
| 884 | + expected = 'OTP-26.2.5' | |
| 885 | + got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-22.04']) | |
| 886 | + assert.deepStrictEqual(got, expected) | |
| 887 | + | |
| 878 | 888 | spec = 'latest' |
| 879 | 889 | expected = 'OTP-27.0-rc3' |
| 880 | 890 | got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-22.04']) |
| 881 | 891 | assert.deepStrictEqual(got, expected) |
| 882 | 892 | |
| 893 | + spec = 'maint-26' | |
| 894 | + expected = 'maint-26' | |
| 895 | + got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-22.04']) | |
| 896 | + assert.deepStrictEqual(got, expected) | |
| 897 | + | |
| 898 | + spec = '> 0' | |
| 899 | + expected = 'OTP-27.0' | |
| 900 | + got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-24.04']) | |
| 901 | + assert.deepStrictEqual(got, expected) | |
| 902 | + | |
| 883 | 903 | spec = 'latest' |
| 884 | 904 | expected = 'OTP-27.0' |
| 885 | 905 | got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-24.04']) |
Parents: 75edbb8