Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 60 additions & 5 deletions .github/workflows/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,89 @@ on:
jobs:
run:
name: Version
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: master
ref: '${{ github.event.pull_request.base.sha }}'

- name: Compare pull request
env:
BASE_SHA: '${{ github.event.pull_request.base.sha }}'
HEAD_SHA: '${{ github.event.pull_request.merge_commit_sha }}'
run: |
set -euo pipefail

if [[ -z "${BASE_SHA}" || -z "${HEAD_SHA}" ]]; then
echo '::error::Pull request comparison identity is incomplete.'
exit 1
fi

echo "Fetching pull request head ${HEAD_SHA} from base ${BASE_SHA}."
git fetch --no-tags origin "${HEAD_SHA}"
git checkout --detach "${HEAD_SHA}"

checked_out_sha="$(git rev-parse HEAD)"

if [[ "${checked_out_sha}" != "${HEAD_SHA}" ]]; then
echo "::error::Checked out ${checked_out_sha}, expected ${HEAD_SHA}."
exit 1
fi

if ! git merge-base --is-ancestor "${BASE_SHA}" "${HEAD_SHA}"; then
echo "::error::Pull request base ${BASE_SHA} is not an ancestor of ${HEAD_SHA}."
exit 1
fi

echo "Pull request comparison: ${BASE_SHA}..${HEAD_SHA}"
git diff --name-status --find-renames "${BASE_SHA}" "${HEAD_SHA}"

- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '18.13'

- name: Install
run: yarn install
run: yarn install --immutable
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'

- name: Select workspaces
id: workspaces
env:
BASE_SHA: '${{ github.event.pull_request.base.sha }}'
run: |
set -euo pipefail

selected="$(yarn workspaces list --since="${BASE_SHA}" --no-private --json)"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve version bumps for public dependents

When a PR changes only a private workspace used to build @atls/grpc-playground-app—for example, index-page is private but is a workspace dependency of the published renderer (grpc-playground/pages/index-page/package.json:2-12, grpc-playground/entrypoints/renderer/package.json:2-24)—the checked-in Yarn's workspaces list --help confirms that --since selects only workspaces modified since the ref; applying --no-private here therefore makes selected empty and skips Version and Commit. The previous custom workspaces changed foreach expanded reverse dependents, so preserve that expansion before filtering or functional changes in these private packages will receive no app version fragment and will not be published.

Useful? React with 👍 / 👎.


if [[ -z "${selected}" ]]; then
echo 'No non-private workspaces selected.'
echo 'selected=false' >> "${GITHUB_OUTPUT}"
exit 0
fi

echo 'Selected non-private workspaces:'
echo "${selected}"
echo 'selected=true' >> "${GITHUB_OUTPUT}"

- name: Version
run: yarn workspaces changed foreach --no-private --verbose version patch --deferred
if: steps.workspaces.outputs.selected == 'true'
run: yarn workspaces foreach --since="${BASE_SHA}" --no-private --verbose version patch --deferred
env:
BASE_SHA: '${{ github.event.pull_request.base.sha }}'
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'

- name: Commit changes
if: steps.workspaces.outputs.selected == 'true'
uses: EndBug/add-and-commit@v7
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
with:
add: '.yarn/versions'
author_name: github-actions
author_email: github-bot@atls.team
message: 'chore(common): versions'
Expand Down