From 0f9641f331f2a9d00a6ed2eb8b7570142bbdb11f Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Mon, 4 Mar 2024 11:38:44 -0600 Subject: [PATCH 1/3] chore(ci): set --tag on release --- .github/workflows/release.yml | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eb5cd362e54b..17fe1203c5d4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,6 @@ env: jobs: changelog: name: Changelog PR or Release - if: ${{ github.repository_owner == 'withastro' }} runs-on: ubuntu-latest permissions: contents: write @@ -43,14 +42,32 @@ jobs: - name: Build Packages run: pnpm run build + + - name: Set PUBLISH_FLAGS variable + id: tag + run: | + BRANCH_NAME="${GITHUB_REF##*/}" + if [ "$BRANCH_NAME" = "main" ]; then + # do not set any flags (`latest` is the default) + echo "PUBLISH_FLAGS=" >> $GITHUB_ENV + elif [ "$BRANCH_NAME" = "next" ]; then + # just use `--tag next` + echo "PUBLISH_FLAGS=--tag next" >> $GITHUB_ENV + else + # extract the integer prefix from the branch name + VERSION_NUMBER="${BRANCH_NAME%%-*}" + # pass a shorthand tag like `--tag v3` + echo "PUBLISH_FLAGS=--tag v$VERSION_NUMBER" >> $GITHUB_ENV + fi - name: Create Release Pull Request or Publish id: changesets uses: changesets/action@v1 with: - # Note: pnpm install after versioning is necessary to refresh lockfile + # Note: Run custom version script which runs pnpm install + # the install step is necessary to refresh lockfile after versioning version: pnpm run version - publish: pnpm exec changeset publish + publish: pnpm exec changeset publish $PUBLISH_FLAGS commit: "[ci] release" title: "[ci] release" env: From 23c0b0fcf1f2a41f421472134e16bbb001246469 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Mon, 4 Mar 2024 12:01:32 -0600 Subject: [PATCH 2/3] chore: revert deletion --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 17fe1203c5d4..175380cca8d2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -61,6 +61,7 @@ jobs: fi - name: Create Release Pull Request or Publish + if: ${{ github.repository_owner == 'withastro' }} id: changesets uses: changesets/action@v1 with: From 0cb6d1bc6534b462c6ba4394739e525dcbee366d Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Tue, 5 Mar 2024 16:33:28 -0600 Subject: [PATCH 3/3] fix: ignore job on forks --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 175380cca8d2..7a9e8d6cb06e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,6 +20,7 @@ env: jobs: changelog: + if: ${{ github.repository_owner == 'withastro' }} name: Changelog PR or Release runs-on: ubuntu-latest permissions: @@ -61,7 +62,6 @@ jobs: fi - name: Create Release Pull Request or Publish - if: ${{ github.repository_owner == 'withastro' }} id: changesets uses: changesets/action@v1 with: