From 9e52fc8db71abf5c037bd06bce383a2dcea99de4 Mon Sep 17 00:00:00 2001 From: Huw Wilkins Date: Thu, 29 Aug 2024 11:02:15 +1000 Subject: [PATCH] ci: add release preview action --- .github/workflows/release-preview.yml | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/release-preview.yml diff --git a/.github/workflows/release-preview.yml b/.github/workflows/release-preview.yml new file mode 100644 index 00000000..501585ce --- /dev/null +++ b/.github/workflows/release-preview.yml @@ -0,0 +1,33 @@ +name: Preview release +on: + pull_request: + branches: + - main + +jobs: + release: + name: Preview release + runs-on: ubuntu-latest + outputs: + new-release-version: ${{ steps.dry-run.outputs.new-release-version }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "lts/*" + - name: Install dependencies + run: yarn install + - name: Preview release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + id: dry-run + run: | + OUTPUT=$(unset GITHUB_ACTIONS && npx semantic-release --dry-run --no-ci --branches "$GITHUB_HEAD_REF" --repository-url "$github.event.pull_request.head.repo.git_url") + VERSION=$(echo "$OUTPUT" | grep -o "The next release version is [0-9]*\.[0-9]*\.[0-9]*" | awk '{print $6}') + echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT" + - name: Next version + run: echo "The next version will be ${{ steps.dry-ryb.outputs.new-release-version }}"