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

[cd] publish on release tags instead of branch push (#95085)

That way we can push multiple commits when doing a release. For
canaries, nothing will change.

In a follow-up, we'll start cutting `@preview` from the `canary` branch.
To support that case, we need to immediately revert the version in
`lerna.json`. We shouldn't push commits indidually to avoid having an
incomplete release if something else is pushed between `@preview`
version bumps and `@canary` version reverts.

## test plan

After merge, the next canary release should publish from the
`v…-canary.N` tag run (`deploy-target = production`), while the canary
branch push for the same commit shows `skipped` — exactly one production
run per release.



<!-- NEXT_JS_LLM_PR -->
parent 16db9d05
...@@ -3,9 +3,13 @@ name: build-and-deploy ...@@ -3,9 +3,13 @@ name: build-and-deploy
on: on:
push: push:
# Don't run when tags or graphite base branches are pushed # Don't run when graphite base branches are pushed
branches-ignore: branches-ignore:
- 'graphite-base/**' - 'graphite-base/**'
# Run on release tags so publishing is driven by the tag push rather than
# the release-commit branch push (see the deploy-target step).
tags:
- 'v*'
# we need the preview tarball for deploy tests # we need the preview tarball for deploy tests
pull_request: pull_request:
types: [opened, synchronize] types: [opened, synchronize]
...@@ -13,8 +17,11 @@ on: ...@@ -13,8 +17,11 @@ on:
concurrency: concurrency:
# Limit concurrent runs to 1 per PR, # Limit concurrent runs to 1 per PR,
# but allow concurrent runs on push if they potentially use different source code # but allow concurrent runs on push if they potentially use different source code.
group: ${{ github.event_name == 'pull_request' && format('{0}-pr-{1}', github.workflow, github.ref_name) || format('{0}-sha-{1}', github.workflow, github.sha) }} # The push group includes github.ref so that the branch push and tag push of
# the same release commit (same sha) don't share a group -- otherwise the
# skipped branch run could cancel the production tag run.
group: ${{ github.event_name == 'pull_request' && format('{0}-pr-{1}', github.workflow, github.ref_name) || format('{0}-{1}-{2}', github.workflow, github.ref, github.sha) }}
cancel-in-progress: true cancel-in-progress: true
env: env:
...@@ -72,6 +79,13 @@ jobs: ...@@ -72,6 +79,13 @@ jobs:
if [[ "$RELEASE_VERSION" == v* ]]; if [[ "$RELEASE_VERSION" == v* ]];
then then
if [[ "$GIT_REF" != refs/tags/* ]];
then
# The release commit reached a branch (e.g. its push to canary).
# Publishing is driven by the tag push for that same commit, so
# skip here to avoid a duplicate production build on the same sha.
echo "value=skipped" >> $GITHUB_OUTPUT
else
echo "value=production" >> $GITHUB_OUTPUT echo "value=production" >> $GITHUB_OUTPUT
if [[ "$RELEASE_VERSION" == *-canary.* ]]; if [[ "$RELEASE_VERSION" == *-canary.* ]];
then then
...@@ -92,6 +106,7 @@ jobs: ...@@ -92,6 +106,7 @@ jobs:
exit 1 exit 1
fi fi
echo "release_environment=$RELEASE_ENVIRONMENT" >> $GITHUB_OUTPUT echo "release_environment=$RELEASE_ENVIRONMENT" >> $GITHUB_OUTPUT
fi
elif [ ''"${GIT_REF}"'' == 'refs/heads/canary' ] elif [ ''"${GIT_REF}"'' == 'refs/heads/canary' ]
then then
echo "value=staging" >> $GITHUB_OUTPUT echo "value=staging" >> $GITHUB_OUTPUT
......
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