mirror of
https://github.com/erlef/setup-beam.git
synced 2026-07-22 22:56:07 +00:00
Have the action output a versioning element so it could be used as part of the cache restore key (#239)
* Do a bit of YAMLlint'ing * Ease consumer cache invalidation By providing an output with the action version we ease cache invalidation on consumer, due to the fact we can now stop worrying about changes to the action's cache itself Might also be interesting for self-hosted runners... * Remove duplicates * Do further validations for robustness
This commit is contained in:
committed by
GitHub
parent
a34c98fd51
commit
4678b57fab
@@ -7,6 +7,31 @@ env:
|
|||||||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
version:
|
||||||
|
name: Version with commit unique id
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.ref == 'refs/heads/main'
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Version it!
|
||||||
|
run: |
|
||||||
|
# We expect a string such as const setupBeamVersion = 'undefined' in the code
|
||||||
|
SHA=$(git rev-parse --short HEAD)
|
||||||
|
sed -i'.bak' \
|
||||||
|
-e "s/const setupBeamVersion = '.*'/const setupBeamVersion = '${SHA}'/g" \
|
||||||
|
dist/index.js
|
||||||
|
# it always starts by being 'undefined'
|
||||||
|
NEWVER=$(grep -oE "const setupBeamVersion = '.*'" dist/index.js | cut -d\' -f2)
|
||||||
|
if [ "$NEWVER" == "undefined" ]; then
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Continuing... new version is ${NEWVER}"
|
||||||
|
fi
|
||||||
|
git config user.name "GitHub Actions"
|
||||||
|
git config user.email "actions@user.noreply.github.com"
|
||||||
|
git add dist/index.js
|
||||||
|
git commit -m "Update setup-beam version output to ${SHA}"
|
||||||
|
git push origin main
|
||||||
check_integrity:
|
check_integrity:
|
||||||
name: Expected local npm actions
|
name: Expected local npm actions
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ jobs:
|
|||||||
os: 'ubuntu-latest'
|
os: 'ubuntu-latest'
|
||||||
version-type: 'strict'
|
version-type: 'strict'
|
||||||
- otp-version: '25.2'
|
- otp-version: '25.2'
|
||||||
elixir-version: '1.14.3'
|
elixir-version: '1.14.2'
|
||||||
os: 'ubuntu-latest'
|
os: 'ubuntu-latest'
|
||||||
- otp-version: '25.2'
|
- otp-version: '25.2'
|
||||||
elixir-version: '1.14.3'
|
elixir-version: '1.14.3'
|
||||||
@@ -66,14 +66,6 @@ jobs:
|
|||||||
otp-version: '21'
|
otp-version: '21'
|
||||||
rebar3-version: '3.12'
|
rebar3-version: '3.12'
|
||||||
os: 'ubuntu-20.04'
|
os: 'ubuntu-20.04'
|
||||||
- elixir-version: 'v1.6'
|
|
||||||
otp-version: '21'
|
|
||||||
rebar3-version: '3.12'
|
|
||||||
os: 'ubuntu-20.04'
|
|
||||||
- elixir-version: 'v1.7'
|
|
||||||
otp-version: '22'
|
|
||||||
rebar3-version: '3.13'
|
|
||||||
os: 'ubuntu-20.04'
|
|
||||||
- elixir-version: 'v1.7'
|
- elixir-version: 'v1.7'
|
||||||
otp-version: '22'
|
otp-version: '22'
|
||||||
rebar3-version: '3.13'
|
rebar3-version: '3.13'
|
||||||
@@ -86,18 +78,10 @@ jobs:
|
|||||||
otp-version: '25.0.2'
|
otp-version: '25.0.2'
|
||||||
rebar3-version: '3.19'
|
rebar3-version: '3.19'
|
||||||
os: 'ubuntu-20.04'
|
os: 'ubuntu-20.04'
|
||||||
- elixir-version: 'v1.10'
|
|
||||||
otp-version: '23'
|
|
||||||
rebar3-version: '3.14'
|
|
||||||
os: 'ubuntu-20.04'
|
|
||||||
- elixir-version: 'v1.12'
|
- elixir-version: 'v1.12'
|
||||||
otp-version: '24'
|
otp-version: '24'
|
||||||
rebar3-version: '3.15'
|
rebar3-version: '3.15'
|
||||||
os: 'ubuntu-20.04'
|
os: 'ubuntu-20.04'
|
||||||
- elixir-version: 'v1.13.4'
|
|
||||||
otp-version: '25.0.2'
|
|
||||||
rebar3-version: '3.19'
|
|
||||||
os: 'ubuntu-20.04'
|
|
||||||
- elixir-version: 'v1.11.0'
|
- elixir-version: 'v1.11.0'
|
||||||
otp-version: '22.3.4.2'
|
otp-version: '22.3.4.2'
|
||||||
os: 'ubuntu-20.04'
|
os: 'ubuntu-20.04'
|
||||||
@@ -108,11 +92,11 @@ jobs:
|
|||||||
version-type: 'strict'
|
version-type: 'strict'
|
||||||
- elixir-version: 'main'
|
- elixir-version: 'main'
|
||||||
otp-version: '23.1'
|
otp-version: '23.1'
|
||||||
os: 'ubuntu-20.04'
|
os: 'ubuntu-20.04'
|
||||||
version-type: 'strict'
|
version-type: 'strict'
|
||||||
- elixir-version: 'main'
|
- elixir-version: 'main'
|
||||||
otp-version: '25'
|
otp-version: '25'
|
||||||
os: 'ubuntu-20.04'
|
os: 'ubuntu-20.04'
|
||||||
version-type: 'strict'
|
version-type: 'strict'
|
||||||
- gleam-version: '0.23'
|
- gleam-version: '0.23'
|
||||||
otp-version: '24'
|
otp-version: '24'
|
||||||
@@ -126,7 +110,7 @@ jobs:
|
|||||||
otp-version: false
|
otp-version: false
|
||||||
os: 'ubuntu-latest'
|
os: 'ubuntu-latest'
|
||||||
disable_problem_matchers: true
|
disable_problem_matchers: true
|
||||||
- gleam-version: '0.22.0' # Version with Gleam's old archive naming convention
|
- gleam-version: '0.22.0' # Version with Gleam's old archive naming convention
|
||||||
otp-version: '24'
|
otp-version: '24'
|
||||||
os: 'ubuntu-latest'
|
os: 'ubuntu-latest'
|
||||||
disable_problem_matchers: true
|
disable_problem_matchers: true
|
||||||
|
|||||||
@@ -88,6 +88,21 @@ jobs:
|
|||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Outputs
|
||||||
|
|
||||||
|
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. `v0.23.0`
|
||||||
|
| 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}}`
|
||||||
|
|
||||||
### Version file
|
### Version file
|
||||||
|
|
||||||
A version file is specified via input `version-file` (e.g.`.tool-versions`). This
|
A version file is specified via input `version-file` (e.g.`.tool-versions`). This
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ outputs:
|
|||||||
description: Exact version of Gleam that was installed
|
description: Exact version of Gleam that was installed
|
||||||
rebar3-version:
|
rebar3-version:
|
||||||
description: Exact version of rebar3 that was installed
|
description: Exact version of rebar3 that was installed
|
||||||
|
setup-beam-version:
|
||||||
|
description: The commit unique id of the execution action version
|
||||||
runs:
|
runs:
|
||||||
using: node16
|
using: node16
|
||||||
main: dist/index.js
|
main: dist/index.js
|
||||||
|
|||||||
Vendored
+4
@@ -9868,6 +9868,10 @@ async function main() {
|
|||||||
|
|
||||||
await maybeInstallGleam(gleamSpec)
|
await maybeInstallGleam(gleamSpec)
|
||||||
await maybeInstallRebar3(rebar3Spec)
|
await maybeInstallRebar3(rebar3Spec)
|
||||||
|
|
||||||
|
// undefined is replaced by a function, post- main branch merge
|
||||||
|
const setupBeamVersion = 'undefined'
|
||||||
|
core.setOutput('setup-beam-version', setupBeamVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function installOTP(otpSpec, osVersion) {
|
async function installOTP(otpSpec, osVersion) {
|
||||||
|
|||||||
@@ -47,6 +47,10 @@ async function main() {
|
|||||||
|
|
||||||
await maybeInstallGleam(gleamSpec)
|
await maybeInstallGleam(gleamSpec)
|
||||||
await maybeInstallRebar3(rebar3Spec)
|
await maybeInstallRebar3(rebar3Spec)
|
||||||
|
|
||||||
|
// undefined is replaced by a function, post- main branch merge
|
||||||
|
const setupBeamVersion = 'undefined'
|
||||||
|
core.setOutput('setup-beam-version', setupBeamVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function installOTP(otpSpec, osVersion) {
|
async function installOTP(otpSpec, osVersion) {
|
||||||
|
|||||||
Reference in New Issue
Block a user