From a1bc8229d94258fe66ede440ebd38afdd5c35f7f Mon Sep 17 00:00:00 2001 From: Ayoub Date: Tue, 22 Oct 2024 11:39:08 +0100 Subject: [PATCH] ci: add extract old and new versions extraction step for the Release PR --- .github/workflows/create-release-pr.yaml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/create-release-pr.yaml b/.github/workflows/create-release-pr.yaml index c1fbd113..2bffbb87 100644 --- a/.github/workflows/create-release-pr.yaml +++ b/.github/workflows/create-release-pr.yaml @@ -55,14 +55,29 @@ jobs: with: install-nodejs: 'true' + - name: Extract the old and new versions of the package + id: extract-package-versions + run: | + # Using `--since` flag in the `status` step on the same branch returns empty release file and doesn't reflect the upcoming changes, hence we override the `baseBranch` in the config file. + jq '.baseBranch = "${{ steps.branch-check.outputs.branch_name }}"' ./.changeset/config.json > temp.json + mv temp.json ./.changeset/config.json + npm run cs -- status --output=release.json + + NEW_PACKAGE_VERSION=$(jq -r '.releases[0].newVersion' release.json) + OLD_PACKAGE_VERSION=$(jq -r '.releases[0].oldVersion' release.json) + rm release.json + + echo "new_package_version=${NEW_PACKAGE_VERSION}" >> "$GITHUB_OUTPUT" + echo "old_package_version=${OLD_PACKAGE_VERSION}" >> "$GITHUB_OUTPUT" + # Keep the version of the PRs up-to-date - name: Create Release Pull Request id: release-pr uses: changesets/action@aba318e9165b45b7948c60273e0b72fce0a64eb9 # v1.4.7 with: - # This branch context is ignored in this step: https://github.com/changesets/action/blob/50750fa876cc1e54c7cb972db5e2f7271fc53d99/src/run.ts#L328, therefore the usage of `branch` + # This branch context is ignored in this step: `https://github.com/changesets/action/blob/50750fa876cc1e54c7cb972db5e2f7271fc53d99/src/run.ts#L328`, therefore the usage of `branch` selection in the workflow trigger. branch: ${{ steps.branch-check.outputs.branch_name }} - title: 'chore(release): bump version and update changelog' - commit: 'chore(release): bump version and update changelog' + title: 'chore(release): bump version from `${{ steps.extract-package-versions.outputs.old_package_version }}` to `${{ steps.extract-package-versions.outputs.new_package_version }}`' + commit: 'chore(release): bump version from `${{ steps.extract-package-versions.outputs.old_package_version }}` to `${{ steps.extract-package-versions.outputs.new_package_version }}`' env: GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}