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:
TURBO_VERSION: 2.9.4
NODE_LTS_VERSION: 20
permissions: {}
jobs:
start:
if: github.repository_owner == 'vercel'
......@@ -85,36 +87,45 @@ jobs:
env:
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
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: |
if [ "$LATEST_TAG_COMMIT" = "$LATEST_COMMIT" ]; then
echo "No new commits. Exiting..."
exit 1
set -euo pipefail
# Stable releases and forced runs release regardless of new commits.
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
echo "has_new_commits=$has_new_commits" >> "$GITHUB_OUTPUT"
# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
if: steps.new-commits.outputs.has_new_commits == 'true'
run: sudo ethtool -K eth0 tx off rx off
- name: Setup corepack
if: steps.new-commits.outputs.has_new_commits == 'true'
run: |
npm i -g corepack@0.31
corepack enable
pnpm --version
- id: get-store-path
if: steps.new-commits.outputs.has_new_commits == 'true'
run: echo STORE_PATH=$(pnpm store path) >> $GITHUB_OUTPUT
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
if: steps.new-commits.outputs.has_new_commits == 'true'
timeout-minutes: 5
id: cache-pnpm-store
with:
......@@ -122,9 +133,11 @@ jobs:
key: pnpm-store-root-v1-${{ hashFiles('pnpm-lock.yaml') }}
# 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:
RELEASE_GITHUB_TOKEN: ${{ steps.release-app-token.outputs.token }}
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