8000 Add support for latest release by JanEricNitschke · Pull Request #323 · erlef/setup-beam · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add support for latest release #323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
67 changes: 36 additions & 31 deletions README.md
8000
Original file line number Diff line number Diff line change
Expand Up @@ -56,29 +56,34 @@ 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.

#### "Latest" versions
#### "latest" versions

Set a tool's version to `latest` to retrieve the latest version of a given tool.
Set a tool's version to `latest` to retrieve the latest non-RC 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).

If in doubt do a test run and compare the obtained release with the one you were expecting to
be the latest.

#### "latest-rc" versions

Similar to `latest`, except that release candidates are also considered.
To target these, set a tool's version to `latest-rc`.

### Compatibility between Operating System and Erlang/OTP

This list presents the known working version combos between the target operating system
and Erlang/OTP.

| Operating system | Erlang/OTP | OTP Architecture | Status
|- |- | - |-
| `ubuntu-18.04` | 17.0 - 25.3 | x86_64, arm64 | ✅
| `ubuntu-20.04` | 21.0 - 27 | x86_64, arm64 | ✅
| `ubuntu-22.04` | 24.2 - 27 | x86_64, arm64 | ✅
| `ubuntu-24.04` | 24.3 - 27 | x86_64, arm64 | ✅
| `windows-2019` | 21\* - 25 | x86_64, x86 | ✅
| `windows-2022` | 21\* - 27 | x86_64, x86 | ✅
| Operating system | Erlang/OTP | OTP Architecture | Status |
| ---------------- | ----------- | ---------------- | ------ |
| `ubuntu-18.04` | 17.0 - 25.3 | x86_64, arm64 | ✅ |
| `ubuntu-20.04` | 21.0 - 27 | x86_64, arm64 | ✅ |
| `ubuntu-22.04` | 24.2 - 27 | x86_64, arm64 | ✅ |
| `ubuntu-24.04` | 24.3 - 27 | x86_64, arm64 | ✅ |
| `windows-2019` | 21\* - 25 | x86_64, x86 | ✅ |
| `windows-2022` | 21\* - 27 | x86_64, x86 | ✅ |

**Note** \*: prior to 23, Windows builds are only available for minor versions, e.g. 21.0, 21.3,
22.0, etc.
Expand All @@ -88,14 +93,14 @@ and Erlang/OTP.
Self-hosted runners need to set env. variable `ImageOS` to one of the following, since the action
uses that to download assets:

| ImageOS | Operating system
|- |-
| `ubuntu18` | `ubuntu-18.04`
| `ubuntu20` | `ubuntu-20.04`
| `ubuntu22` | `ubuntu-22.04`
| `ubuntu24` | `ubuntu-24.04`
| `win19` | `windows-2019`
| `win22` | `windows-2022`
| ImageOS | Operating system |
| ---------- | ---------------- |
| `ubuntu18` | `ubuntu-18.04` |
| `ubuntu20` | `ubuntu-20.04` |
| `ubuntu22` | `ubuntu-22.04` |
| `ubuntu24` | `ubuntu-24.04` |
| `win19` | `windows-2019` |
| `win22` | `windows-2022` |

as per the following example:

Expand All @@ -117,13 +122,13 @@ jobs:

The action provides the following outputs:

| Output | Content
|- |-
| `otp-version` | The Erlang version, e.g. `OTP-26.0`
| `elixir-version` | The Elixir version, e.g. `v1.14-otp-26`
| `gleam-version` | The Gleam version, e.g. `v1.5.1`
| `rebar3-version` | The `rebar3` version, e.g. `3.18.0`
| `setup-beam-version` | The commit unique id of the executed action version, e.g. `a34c98f`
| Output | Content |
| -------------------- | ------------------------------------------------------------------- |
| `otp-version` | The Erlang version, e.g. `OTP-26.0` |
| `elixir-version` | The Elixir version, e.g. `v1.14-otp-26` |
| `gleam-version` | The Gleam version, e.g. `v1.5.1` |
| `rebar3-version` | The `rebar3` version, e.g. `3.18.0` |
| `setup-beam-version` | The commit unique id of the executed action version, e.g. `a34c98f` |

accessible as `${{steps.<setup-beam-step-id>.outputs.<Output>}}`,
e.g. `${{steps.setup-beam.outputs.erlang-version}}`
Expand All @@ -146,12 +151,12 @@ with the following correspondence.

#### `.tool-versions` format

| YML | `.tool-versions`
|- |-
| `otp-version` | `erlang`
| `elixir-version` | `elixir`
| `gleam-version` | `gleam`
| `rebar3-version` | `rebar`
| YML | `.tool-versions` |
| ---------------- | ---------------- |
| `otp-version` | `erlang` |
| `elixir-version` | `elixir` |
| `gleam-version` | `gleam` |
| `rebar3-version` | `rebar` |

### Alternative hex.pm mirrors

Expand Down
13 changes: 10 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9489,7 +9489,7 @@ function gt(left, right) {

function validVersion(v) {
return (
v.match(/main|master|nightly|latest/g) == null &&
v.match(/main|master|nightly|latest|latest-rc/g) == null &&
!v.startsWith('a') &&
!v.startsWith('b')
)
Expand All @@ -9505,12 +9505,17 @@ function parseVersion(v) {

function getVersionFromSpec(spec0, versions0) {
let latest
let latestRC
Object.keys(versions0).forEach((v) => {
if (validVersion(v)) {
latest = latest && gt(latest, v) ? latest : v
latestRC = latestRC && gt(latestRC, v) ? latestRC : v
if (!isRC(v)) {
latest = latest && gt(latest, v) ? latest : v
}
}
})
versions0.latest = latest
versions0.latestRC = latestRC
const spec = maybeRemoveVPrefix(spec0)

const altVersions = {}
Expand Down Expand Up @@ -9539,6 +9544,8 @@ function getVersionFromSpec(spec0, versions0) {
// If `version-type: strict` or version is RC, we obtain it directly
version = versions0[spec]
}
} else if (spec0 === 'latest-rc') {
version = versions0[versions0.latestRC]
} else if (spec0 === 'latest') {
version = versions0[versions0.latest]
} else if (rangeMax !== null) {
Expand Down Expand Up @@ -9605,7 +9612,7 @@ function sortVersions(left, right) {
}

function isRC(ver) {
return ver.match(xyzAbcVersion('^', '(?:-rc\\.?\\d+)'))
return ver.match(xyzAbcVersion('', '(?:-rc\\.?\\d+)'))
}

function isKnownBranch(ver) {
Expand Down
13 changes: 10 additions & 3 deletions src/setup-beam.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ function gt(left, right) {

function validVersion(v) {
return (
v.match(/main|master|nightly|latest/g) == null &&
v.match(/main|master|nightly|latest|latest-rc/g) == null &&
!v.startsWith('a') &&
!v.startsWith('b')
)
Expand All @@ -405,12 +405,17 @@ function parseVersion(v) {

function getVersionFromSpec(spec0, versions0) {
let latest
let latestRC
Object.keys(versions0).forEach((v) => {
if (validVersion(v)) {
latest = latest && gt(latest, v) ? latest : v
latestRC = latestRC && gt(latestRC, v) ? latestRC : v
if (!isRC(v)) {
latest = latest && gt(latest, v) ? latest : v
}
}
})
versions0.latest = latest
versions0.latestRC = latestRC
const spec = maybeRemoveVPrefix(spec0)

const altVersions = {}
Expand Down Expand Up @@ -439,6 +444,8 @@ function getVersionFromSpec(spec0, versions0) {
// If `version-type: strict` or version is RC, we obtain it directly
version = versions0[spec]
}
} else if (spec0 === 'latest-rc') {
version = versions0[versions0.latestRC]
} else if (spec0 === 'latest') {
version = versions0[versions0.latest]
} else if (rangeMax !== null) {
Expand Down Expand Up @@ -505,7 +512,7 @@ function sortVersions(left, right) {
}

function isRC(ver) {
return ver.match(xyzAbcVersion('^', '(?:-rc\\.?\\d+)'))
return ver.match(xyzAbcVersion('', '(?:-rc\\.?\\d+)'))
}

function isKnownBranch(ver) {
Expand Down
41 changes: 33 additions & 8 deletions test/setup-beam.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,11 @@ describe('.getVersionFromSpec(_)', () => {
assert.deepStrictEqual(got, expected)
simulateInput('version-type', before)

spec = 'latest-rc'
expected = '24.0'
got = setupBeam.getVersionFromSpec(spec, versions)
assert.deepStrictEqual(got, expected)

spec = 'latest'
expected = '24.0'
got = setupBeam.getVersionFromSpec(spec, versions)
Expand All @@ -796,63 +801,83 @@ describe('.getVersionFromSpec(_)', () => {
'27.0.0-rc3': '27.0.0-rc3',
'27.0.0-rc2': '27.0.0-rc2',
}
spec = 'latest'
spec = 'latest-rc'
expected = '27.0.0-rc3'
got = setupBeam.getVersionFromSpec(spec, versions)
assert.deepStrictEqual(got, expected)

spec = 'latest'
expected = null
got = setupBeam.getVersionFromSpec(spec, versions)
assert.deepStrictEqual(got, expected)

versions = {
'27.0.0-rc3': '27.0.0-rc3',
'27.0.0-rc2': '27.0.0-rc2',
'27.0.0': '27.0.0',
}
spec = 'latest'
spec = 'latest-rc'
expected = '27.0.0'
got = setupBeam.getVersionFromSpec(spec, versions)
assert.deepStrictEqual(got, expected)

versions = { '25.3.2.8': '25.3.2.8', '25.3.2.12': '25.3.2.12' }
spec = 'latest'
spec = 'latest-rc'
expected = '25.3.2.12'
got = setupBeam.getVersionFromSpec(spec, versions)
assert.deepStrictEqual(got, expected)

spec = 'latest'
spec = 'latest-rc'
expected = 'OTP-26.2.1'
got = setupBeam.getVersionFromSpec(spec, matrix.otp['ubuntu-18.04'])
assert.deepStrictEqual(got, expected)

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

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

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

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

spec = 'latest-rc'
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'])
assert.deepStrictEqual(got, expected)

spec = 'latest-rc'
expected = '27.0-rc3'
got = setupBeam.getVersionFromSpec(spec, matrix.otp.windows)
assert.deepStrictEqual(got, expected)

spec = 'latest'
spec = 'latest-rc'
expected = 'v1.16.2'
got = setupBeam.getVersionFromSpec(spec, matrix.elixir)
assert.deepStrictEqual(got, expected)

spec = 'latest'
spec = 'latest-rc'
expected = 'v1.1.0'
got = setupBeam.getVersionFromSpec(spec, matrix.gleam)
assert.deepStrictEqual(got, expected)

spec = 'latest'
spec = 'latest-rc'
expected = '3.23.0'
got = setupBeam.getVersionFromSpec(spec, matrix.rebar3)
assert.deepStrictEqual(got, expected)
Expand Down
0