From a95e1727ac2191c59fec4ae20f30a0c1dc08c8bc Mon Sep 17 00:00:00 2001 From: Maximilian Franzke Date: Fri, 3 Jan 2025 14:46:25 +0100 Subject: [PATCH] refactor: migrated another script --- .github/scripts/get-release.js | 22 ++++++++++++++++++++ .github/scripts/get-release.sh | 17 --------------- .github/workflows/01-get-publish-version.yml | 7 ++++++- 3 files changed, 28 insertions(+), 18 deletions(-) create mode 100644 .github/scripts/get-release.js delete mode 100644 .github/scripts/get-release.sh diff --git a/.github/scripts/get-release.js b/.github/scripts/get-release.js new file mode 100644 index 00000000000..d5a4ea1a98e --- /dev/null +++ b/.github/scripts/get-release.js @@ -0,0 +1,22 @@ +import process from 'process'; + +const GITHUB_REF = process.env.GITHUB_REF; +const GITHUB_ACTOR = process.env.GITHUB_ACTOR; +const GITHUB_COMMITISH = process.env.GITHUB_COMMITISH; +const GITHUB_PRE_RELEASE = process.env.GITHUB_PRE_RELEASE === 'true'; + +if (GITHUB_REF && GITHUB_REF.startsWith('refs/tags/v')) { + if (GITHUB_ACTOR !== 'dependabot[bot]') { + if (GITHUB_COMMITISH === 'main' && !GITHUB_PRE_RELEASE) { + console.log('RELEASE'); + } else { + console.log('PRE_RELEASE'); + } + } else { + console.error('Dependabot has no permission to publish!'); + process.exit(1); + } +} else { + console.error("Your tag has to start with 'v'"); + process.exit(1); +} diff --git a/.github/scripts/get-release.sh b/.github/scripts/get-release.sh deleted file mode 100644 index 0b2b500d9b8..00000000000 --- a/.github/scripts/get-release.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -if [[ $GITHUB_REF == refs/tags/v* ]]; then - if [[ $GITHUB_ACTOR != 'dependabot[bot]' ]]; then - if [[ $GITHUB_COMMITISH == 'main' && $GITHUB_PRE_RELEASE == false ]]; then - echo "RELEASE" - else - echo "PRE_RELEASE" - fi - else - echo "Dependabot has no permission to publish!" - exit 1 - fi -else - echo "Your tag has to start with 'v'" - exit 1 -fi diff --git a/.github/workflows/01-get-publish-version.yml b/.github/workflows/01-get-publish-version.yml index 4a0caf59e4d..b6ad77d5eba 100644 --- a/.github/workflows/01-get-publish-version.yml +++ b/.github/workflows/01-get-publish-version.yml @@ -31,9 +31,14 @@ jobs: uses: ./.github/actions/npm-cache - name: 💃🕺 Check if release or prerelease + uses: actions/github-script@v7 id: releaseCheck + with: + script: | + const { default: getRelease } = await import('${{ github.workspace }}/.github/scripts/get-release.js'); + return await getRelease(); run: | - chmod +rx ./.github/scripts/get-release.sh + chmod +rx ./.github/scripts/ OUTPUT=$(./.github/scripts/get-release.sh) if [[ $OUTPUT == "RELEASE" ]]; then