diff --git a/.github/workflows/pr-validate-changesets.yaml b/.github/workflows/pr-validate-changesets.yaml index 89097f56329..f0e7cf0b9a5 100644 --- a/.github/workflows/pr-validate-changesets.yaml +++ b/.github/workflows/pr-validate-changesets.yaml @@ -59,6 +59,37 @@ jobs: - name: CI Setup uses: ./.github/actions/ci-setup + - name: Bump and Collect Versions + run: | + echo "CURRENT_VERSION=v$(sed -nE 's/^\s*"version": "(.*?)",$/\1/p' packages/fuels/package.json)" >> $GITHUB_ENV + pnpm changeset version + echo "RELEASE_VERSION=v$(sed -nE 's/^\s*"version": "(.*?)",$/\1/p' packages/fuels/package.json)" >> $GITHUB_ENV + git log -1 + COMMIT_MSG=$(git log -1 --format=%B) + echo ${{ github.event.head_commit.message }} + echo workflow_run + echo ${{ github.event.workflow_run.head_commit.message }} + echo $COMMIT_MSG + echo "COMMIT_MSG=$COMMIT_MSG" >> $GITHUB_ENV + git reset --hard + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create Release Pull Request or Publish to npm + if: | + ${{ env.RELEASE_VERSION != env.CURRENT_VERSION }} || + startsWith(env.COMMIT_MSG, 'ci(changesets)') + run: | + git log -1 + git show --format='commit %H%nAuthor: %an <%ae>%nDate: %ad%n%n %s' + echo $COMMIT_MSG + echo $RELEASE_VERSION + echo $CURRENT_VERSION + env: + COMMIT_MSG: ${{ env.COMMIT_MSG }} + RELEASE_VERSION: ${{ env.RELEASE_VERSION }} + CURRENT_VERSION: ${{ env.CURRENT_VERSION }} + - name: Validate Changeset run: pnpm changeset status --since=origin/${{ github.base_ref }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d8a91401583..c9d3bf16d2b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -37,10 +37,12 @@ jobs: # if there are changesets present, package.json will be bumped - name: Bump and Collect Versions run: | + echo "CURRENT_VERSION=v$(sed -nE 's/^\s*"version": "(.*?)",$/\1/p' packages/fuels/package.json)" >> $GITHUB_ENV pnpm changeset version echo "RELEASE_VERSION=v$(sed -nE 's/^\s*"version": "(.*?)",$/\1/p' packages/fuels/package.json)" >> $GITHUB_ENV echo "FUEL_CORE_VERSION=$(cat ./internal/fuel-core/VERSION)" >> $GITHUB_ENV echo "FORC_VERSION=$(cat ./internal/forc/VERSION)" >> $GITHUB_ENV + echo "COMMIT_MSG=$(git log -n 1 --format=%B)" >> $GITHUB_ENV git reset --hard env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -65,6 +67,7 @@ jobs: - name: Create Release Pull Request or Publish to npm id: changesets + if: ${{ env.RELEASE_VERSION != env.CURRENT_VERSION && !startsWith(env.COMMIT_MSG, "ci(changesets)") }} uses: FuelLabs/changesets-action@main with: publish: pnpm changeset:publish ${{ env.RELEASE_VERSION }} ${{ github.ref_name }}