Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions README.md
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thoroughly revisited this as a way to make it as clear as possible... please give it a read and lemme know otherwise.

Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,25 @@ end up being parsed as `23`, which is not equivalent.

#### Pre-release versions

For pre-release versions, such as `v1.11.0-rc.0`, use the full version
specifier (`v1.11.0-rc.0`) and set option `version-type` to `strict`. Pre-release versions are
opt-in, so `1.11.x` will not match a pre-release.
To use a pre-release version such as `v1.11.0-rc.0`, specify the exact version
(`v1.11.0-rc.0`) and set `version-type` to `strict`.
Note that pre-release versions are opt-in by default.
Patterns like `1.11.x` do not include pre-release versions unless `latest` is specified.

#### "Latest" versions

Set a tool's version to `latest` to retrieve the latest version of a given tool.
The latest version is (locally) calculated by the action based on the (retrieved) versions
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)
and some repositories might propose).
To retrieve the most recent available version of a tool, set the version to `latest`.
This may include pre-release versions such as release candidates.

If in doubt do a test run and compare the obtained release with the one you were expecting to
be the latest.
If you want to target only the latest stable release and exclude pre-releases, use a
version range like `> 0` instead.

Note that the `latest` version is determined locally by the action based on the versions it
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),
and some repositories may present different interpretations.

If you're unsure, perform a test run and compare the resolved version against the version you
expect to be considered the latest.

### Compatibility between Operating System and Erlang/OTP

Expand Down
19 changes: 15 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26323,6 +26323,7 @@ function validVersion(v) {
v.match(
new RegExp(`${knownBranches.join('|')}|${nonSpecificVersions.join('|')}`),
) == null &&
// these ones are for rebar3, which has alpha and beta releases
!v.startsWith('a') &&
!v.startsWith('b')
)
Expand All @@ -26349,7 +26350,12 @@ function getVersionFromSpec(spec0, versions0) {
const altVersions = {}
Object.entries(versions0).forEach(([version, altVersion]) => {
let coerced
if (isStrictVersion() || isRC(version)) {
if (
isStrictVersion() ||
isRC(version) ||
isKnownBranch(version) ||
isKnownVerBranch(version)
) {
Comment on lines +26353 to +26358
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the exception we use when building the comparison list. We don't want maint-27 in the same bucket as 27.0, for example. Or even 27.0-rc3 since we state these are opt-in and latest already takes care of that.

// If `version-type: strict` or version is RC, we just try to remove a potential initial v
coerced = maybeRemoveVPrefix(version)
} else {
Expand All @@ -26367,9 +26373,14 @@ function getVersionFromSpec(spec0, versions0) {
const rangeMax = semver.maxSatisfying(versions, rangeForMax)
let version = null

if (isStrictVersion() || isRC(spec0) || isKnownBranch(spec0)) {
if (
isStrictVersion() ||
isRC(spec0) ||
isKnownBranch(spec0) ||
isKnownVerBranch(spec0)
) {
Comment on lines +26376 to +26381
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, when the input is strict, and rc, ... we don't need to compare it in a range (done below), so we skip that entirely.

if (versions0[spec]) {
// If `version-type: strict` or version is RC, we obtain it directly
// We obtain it directly
version = versions0[spec]
}
} else if (spec0 === 'latest') {
Expand Down Expand Up @@ -26592,7 +26603,7 @@ function xyzAbcVersion(pref, suf) {
// https://www.erlang.org/doc/system_principles/versions.html
const dd = '\\.?(\\d+)?'
return new RegExp(
`${pref}v?(\\d+)${dd}${dd}${dd}${dd}${dd}(?:-rc\\.?\\d+)?(?:-otp-\\d+)?${suf}`,
`${pref}(?:OTP-)?v?(\\d+)${dd}${dd}${dd}${dd}${dd}(?:-rc\\.?\\d+)?(?:-otp-\\d+)?${suf}`,
)
}

Expand Down
19 changes: 15 additions & 4 deletions src/setup-beam.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ function validVersion(v) {
v.match(
new RegExp(`${knownBranches.join('|')}|${nonSpecificVersions.join('|')}`),
) == null &&
// these ones are for rebar3, which has alpha and beta releases
!v.startsWith('a') &&
!v.startsWith('b')
)
Expand All @@ -474,7 +475,12 @@ function getVersionFromSpec(spec0, versions0) {
const altVersions = {}
Object.entries(versions0).forEach(([version, altVersion]) => {
let coerced
if (isStrictVersion() || isRC(version)) {
if (
isStrictVersion() ||
isRC(version) ||
isKnownBranch(version) ||
isKnownVerBranch(version)
) {
// If `version-type: strict` or version is RC, we just try to remove a potential initial v
coerced = maybeRemoveVPrefix(version)
} else {
Expand All @@ -492,9 +498,14 @@ function getVersionFromSpec(spec0, versions0) {
const rangeMax = semver.maxSatisfying(versions, rangeForMax)
let version = null

if (isStrictVersion() || isRC(spec0) || isKnownBranch(spec0)) {
if (
isStrictVersion() ||
isRC(spec0) ||
isKnownBranch(spec0) ||
isKnownVerBranch(spec0)
) {
if (versions0[spec]) {
// If `version-type: strict` or version is RC, we obtain it directly
// We obtain it directly
version = versions0[spec]
}
} else if (spec0 === 'latest') {
Expand Down Expand Up @@ -717,7 +728,7 @@ function xyzAbcVersion(pref, suf) {
// https://www.erlang.org/doc/system_principles/versions.html
const dd = '\\.?(\\d+)?'
return new RegExp(
`${pref}v?(\\d+)${dd}${dd}${dd}${dd}${dd}(?:-rc\\.?\\d+)?(?:-otp-\\d+)?${suf}`,
`${pref}(?:OTP-)?v?(\\d+)${dd}${dd}${dd}${dd}${dd}(?:-rc\\.?\\d+)?(?:-otp-\\d+)?${suf}`,
)
}

Expand Down
20 changes: 20 additions & 0 deletions test/setup-beam.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -875,11 +875,31 @@ describe('.getVersionFromSpec(_)', () => {
got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-20.04'])
assert.deepStrictEqual(got, expected)

spec = 'maint-24'
expected = 'maint-24'
got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-22.04'])
assert.deepStrictEqual(got, expected)

spec = '> 0'
expected = 'OTP-26.2.5'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below we can see that latest is with RC, but considering a range is without it.

got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-22.04'])
assert.deepStrictEqual(got, expected)

spec = 'latest'
expected = 'OTP-27.0-rc3'
got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-22.04'])
assert.deepStrictEqual(got, expected)

spec = 'maint-26'
expected = 'maint-26'
got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-22.04'])
assert.deepStrictEqual(got, expected)

spec = '> 0'
expected = 'OTP-27.0'
got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-24.04'])
assert.deepStrictEqual(got, expected)

spec = 'latest'
expected = 'OTP-27.0'
got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-24.04'])
Expand Down