From fd56fdb83d1148ddaf024e20094e3e17e9c241bd Mon Sep 17 00:00:00 2001 From: John Hobbs Date: Mon, 7 Oct 2024 14:44:06 -0500 Subject: [PATCH] Move next version into environment variable for Sentry --- .github/workflows/release.yml | 9 ++++++++- scripts/getNextVersion.mjs | 17 +++++++++++++++++ scripts/versionAndBuild.mjs | 6 +++++- 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100755 scripts/getNextVersion.mjs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 19f399d14..5f37a9be7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,10 +39,17 @@ jobs: - run: corepack enable - name: Install dependencies run: yarn install --immutable - + - name: Get Next Version + id: next_version + run: | + export NEXT_VERSION="$(node ./scripts/getNextVersion.mjs)" + echo "Next Version: $NEXT_VERSION" + echo "version=$NEXT_VERSION" >> "$GITHUB_OUTPUT" - name: Create Release run: yarn run release env: GH_TOKEN: ${{ secrets.GH_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + NEXT_VERSION: ${{ steps.next_version.outputs.version }} + SENTRY_RELEASE: ${{ steps.next_version.outputs.version }} diff --git a/scripts/getNextVersion.mjs b/scripts/getNextVersion.mjs new file mode 100755 index 000000000..fbf756815 --- /dev/null +++ b/scripts/getNextVersion.mjs @@ -0,0 +1,17 @@ +#!/usr/bin/env node + +import { $ } from 'execa'; + +async function main() { + const { stdout: status } = await $`git status --porcelain`; + if (status) { + console.error(`❗️ Working directory is not clean:\n${status}`); + return; + } + + const { stdout: nextVersion } = await $`auto shipit --dry-run --quiet`; + + console.log(nextVersion); +} + +main(); diff --git a/scripts/versionAndBuild.mjs b/scripts/versionAndBuild.mjs index 328284923..4a9245a1c 100755 --- a/scripts/versionAndBuild.mjs +++ b/scripts/versionAndBuild.mjs @@ -9,7 +9,11 @@ async function main() { return; } - const { stdout: nextVersion } = await $`auto shipit --dry-run --quiet`; + const nextVersion = process.env.NEXT_VERSION; + if (nextVersion === undefined) { + console.error('❗️ NEXT_VERSION environment variable is required'); + return; + } console.info(`📌 Temporarily bumping version to '${nextVersion}' for build step`); await $`npm --no-git-tag-version version ${nextVersion}`;