From 777bb37cd6f50651b9fd926dcb4876bb5611fb04 Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Thu, 11 Jan 2024 20:50:30 +0000 Subject: [PATCH 1/4] Do a bit of YAMLlint'ing --- .github/workflows/ubuntu.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index d29cc45d..a047ae81 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -108,11 +108,11 @@ jobs: version-type: 'strict' - elixir-version: 'main' otp-version: '23.1' - os: 'ubuntu-20.04' + os: 'ubuntu-20.04' version-type: 'strict' - elixir-version: 'main' otp-version: '25' - os: 'ubuntu-20.04' + os: 'ubuntu-20.04' version-type: 'strict' - gleam-version: '0.23' otp-version: '24' @@ -126,7 +126,7 @@ jobs: otp-version: false os: 'ubuntu-latest' 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' os: 'ubuntu-latest' disable_problem_matchers: true From 92c99b254ec17b9b261df284a089838e187dd925 Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Thu, 11 Jan 2024 20:53:06 +0000 Subject: [PATCH 2/4] 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... --- .github/workflows/action.yml | 17 +++++++++++++++++ README.md | 15 +++++++++++++++ action.yml | 2 ++ dist/index.js | 4 ++++ src/setup-beam.js | 4 ++++ 5 files changed, 42 insertions(+) diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index d428e8e2..f2251660 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -7,6 +7,23 @@ env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} 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: | + SHA=$(git rev-parse --short HEAD) + sed -i'.bak' \ + -e "s/const setupBeamVersion = '.*'/const setupBeamVersion = '${SHA}'/g" \ + dist/index.js + 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: name: Expected local npm actions runs-on: ubuntu-latest diff --git a/README.md b/README.md index 983679f6..c63d72e9 100644 --- a/README.md +++ b/README.md @@ -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..outputs.}}`, +e.g. `${{steps.setup-beam.outputs.erlang-version}}` + ### Version file A version file is specified via input `version-file` (e.g.`.tool-versions`). This diff --git a/action.yml b/action.yml index d44d7adb..173f4c6d 100644 --- a/action.yml +++ b/action.yml @@ -58,6 +58,8 @@ outputs: description: Exact version of Gleam that was installed rebar3-version: description: Exact version of rebar3 that was installed + setup-beam-version: + description: The commit unique id of the execution action version runs: using: node16 main: dist/index.js diff --git a/dist/index.js b/dist/index.js index 8a2f193c..fbcb6654 100644 --- a/dist/index.js +++ b/dist/index.js @@ -9868,6 +9868,10 @@ async function main() { await maybeInstallGleam(gleamSpec) 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) { diff --git a/src/setup-beam.js b/src/setup-beam.js index 2ffa14e5..6d992f05 100644 --- a/src/setup-beam.js +++ b/src/setup-beam.js @@ -47,6 +47,10 @@ async function main() { await maybeInstallGleam(gleamSpec) 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) { From 795fadfc80b41b82838fff32d2831e2197ddda2e Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Thu, 11 Jan 2024 21:13:01 +0000 Subject: [PATCH 3/4] Remove duplicates --- .github/workflows/ubuntu.yml | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index a047ae81..f2ac8ab5 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -24,7 +24,7 @@ jobs: os: 'ubuntu-latest' version-type: 'strict' - otp-version: '25.2' - elixir-version: '1.14.3' + elixir-version: '1.14.2' os: 'ubuntu-latest' - otp-version: '25.2' elixir-version: '1.14.3' @@ -66,14 +66,6 @@ jobs: otp-version: '21' rebar3-version: '3.12' 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' otp-version: '22' rebar3-version: '3.13' @@ -86,18 +78,10 @@ jobs: otp-version: '25.0.2' rebar3-version: '3.19' os: 'ubuntu-20.04' - - elixir-version: 'v1.10' - otp-version: '23' - rebar3-version: '3.14' - os: 'ubuntu-20.04' - elixir-version: 'v1.12' otp-version: '24' rebar3-version: '3.15' 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' otp-version: '22.3.4.2' os: 'ubuntu-20.04' From 828adb791d4ff8ea1e8fd9ca21b83fa340dc0323 Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Thu, 11 Jan 2024 21:13:19 +0000 Subject: [PATCH 4/4] Do further validations for robustness --- .github/workflows/action.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index f2251660..2b173d14 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -15,10 +15,18 @@ jobs: - 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