Unverified Commit c418b7aa authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

[cd] Skip the release job when no new commits warrant a release (#98664)

parent 3874b55d
...@@ -36,6 +36,8 @@ env: ...@@ -36,6 +36,8 @@ env:
TURBO_VERSION: 2.9.4 TURBO_VERSION: 2.9.4
NODE_LTS_VERSION: 20 NODE_LTS_VERSION: 20
permissions: {}
jobs: jobs:
start: start:
if: github.repository_owner == 'vercel' if: github.repository_owner == 'vercel'
...@@ -85,36 +87,45 @@ jobs: ...@@ -85,36 +87,45 @@ jobs:
env: env:
GH_TOKEN: ${{ steps.release-app-token.outputs.token }} GH_TOKEN: ${{ steps.release-app-token.outputs.token }}
- name: Get commit of the latest tag
run: |
latest_tag="$(git describe --tags --abbrev=0)"
echo "LATEST_TAG_COMMIT=$(git rev-list -n 1 "$latest_tag")" >> $GITHUB_ENV
- name: Get latest commit
run: echo "LATEST_COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Check if new commits since last tag - name: Check if new commits since last tag
if: ${{ github.event.inputs.releaseType != 'stable' && inputs.force != true }} id: new-commits
env:
INPUT_RELEASETYPE: ${{ github.event.inputs.releaseType || '' }}
INPUT_FORCE: ${{ github.event.inputs.force || false }}
run: | run: |
if [ "$LATEST_TAG_COMMIT" = "$LATEST_COMMIT" ]; then set -euo pipefail
echo "No new commits. Exiting..." # Stable releases and forced runs release regardless of new commits.
exit 1 if [ "$INPUT_RELEASETYPE" = "stable" ] || [ "$INPUT_FORCE" = "true" ]; then
has_new_commits=true
else
latest_tag="$(git describe --tags --abbrev=0)"
if [ "$(git rev-list -n 1 "$latest_tag")" = "$(git rev-parse HEAD)" ]; then
echo "No new commits since $latest_tag. Skipping release."
has_new_commits=false
else
has_new_commits=true
fi
fi fi
echo "has_new_commits=$has_new_commits" >> "$GITHUB_OUTPUT"
# https://github.com/actions/virtual-environments/issues/1187 # https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network - name: tune linux network
if: steps.new-commits.outputs.has_new_commits == 'true'
run: sudo ethtool -K eth0 tx off rx off run: sudo ethtool -K eth0 tx off rx off
- name: Setup corepack - name: Setup corepack
if: steps.new-commits.outputs.has_new_commits == 'true'
run: | run: |
npm i -g corepack@0.31 npm i -g corepack@0.31
corepack enable corepack enable
pnpm --version pnpm --version
- id: get-store-path - id: get-store-path
if: steps.new-commits.outputs.has_new_commits == 'true'
run: echo STORE_PATH=$(pnpm store path) >> $GITHUB_OUTPUT run: echo STORE_PATH=$(pnpm store path) >> $GITHUB_OUTPUT
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
if: steps.new-commits.outputs.has_new_commits == 'true'
timeout-minutes: 5 timeout-minutes: 5
id: cache-pnpm-store id: cache-pnpm-store
with: with:
...@@ -122,9 +133,11 @@ jobs: ...@@ -122,9 +133,11 @@ jobs:
key: pnpm-store-root-v1-${{ hashFiles('pnpm-lock.yaml') }} key: pnpm-store-root-v1-${{ hashFiles('pnpm-lock.yaml') }}
# Do not use restore-keys since it leads to indefinite growth of the cache. # Do not use restore-keys since it leads to indefinite growth of the cache.
- run: pnpm install - if: steps.new-commits.outputs.has_new_commits == 'true'
run: pnpm install
- run: node ./scripts/start-release.js --release-type "${INPUT_RELEASETYPE}" --semver-type "${INPUT_SEMVERTYPE}" - if: steps.new-commits.outputs.has_new_commits == 'true'
run: node ./scripts/start-release.js --release-type "${INPUT_RELEASETYPE}" --semver-type "${INPUT_SEMVERTYPE}"
env: env:
RELEASE_GITHUB_TOKEN: ${{ steps.release-app-token.outputs.token }} RELEASE_GITHUB_TOKEN: ${{ steps.release-app-token.outputs.token }}
RELEASE_GITHUB_APP_SLUG: ${{ steps.release-app-token.outputs.app-slug }} RELEASE_GITHUB_APP_SLUG: ${{ steps.release-app-token.outputs.app-slug }}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment