-
Notifications
You must be signed in to change notification settings - Fork 41
[Chore] Better changesets release flow #434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 31 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
c0da4d4
[poc] multiversion with changeset
art-alexeyenko 8aceded
Add cascade versioning
art-alexeyenko 0a80801
finalize base release flow
art-alexeyenko c46a675
Merge branch 'dev' of https://github.com/Sitecore/content-sdk into po…
art-alexeyenko a4f0360
Potential fix for code scanning alert no. 31: Workflow does not conta…
art-alexeyenko bab51e2
Potential fix for code scanning alert no. 30: Workflow does not conta…
art-alexeyenko b19119c
Prep-release flow for patch releases
art-alexeyenko 5e36e5d
Merge branch 'dev' of https://github.com/Sitecore/content-sdk into po…
art-alexeyenko 5813d32
custom canary dist tag for patches
art-alexeyenko d03d107
fix yarn lock
art-alexeyenko df9c9e3
Simplify both hotfix and latest release flows
art-alexeyenko dea91c0
Small cleanup across monorepo
art-alexeyenko 0c1b571
Merge branch 'dev' of https://github.com/Sitecore/content-sdk into po…
art-alexeyenko de2a0ec
Better changelog management & wf fixes
art-alexeyenko c94396b
Better cascade version
art-alexeyenko 925fe15
Integrate with new packages
art-alexeyenko 1943e1c
better comments, naming and covered packages in actions. yarn lock fix
art-alexeyenko cf14b2c
Use preminor lerna version update after main publish
art-alexeyenko 474ace2
Only patch cascade bumps for 'create-content-sdk` package
art-alexeyenko 571733b
Split PR and publish actions
art-alexeyenko 996be6e
Revert "Split PR and publish actions"
art-alexeyenko 36a96db
Better hotfix prep "next steps" section
art-alexeyenko 9237252
Fix release PR automerge. Fix release PR having merge conflicts
art-alexeyenko 4d42264
Merge branch 'dev' of https://github.com/Sitecore/content-sdk into po…
art-alexeyenko 0fbb984
fix yarn deps
art-alexeyenko 0c4b614
Merge branch 'dev' of https://github.com/Sitecore/content-sdk into po…
art-alexeyenko 2b96acc
apply caret version on create-content-sdk
art-alexeyenko 75ed95a
yarn sync
art-alexeyenko eaec730
content-sdk specific changesets readme
art-alexeyenko 32d1d7a
Alternative canary flow
art-alexeyenko 1d9ff8a
Merge branch 'dev' of https://github.com/Sitecore/content-sdk into ch…
art-alexeyenko 69f60c5
fix create* package name in hotfix prep
art-alexeyenko cf61d91
Unit test cascade versioning
art-alexeyenko 7d50393
Merge branch 'dev' of https://github.com/Sitecore/content-sdk into ch…
art-alexeyenko 606faa3
fix yarn
art-alexeyenko 939df46
force typescript version in analytics-core
art-alexeyenko 534545a
force typescript version in events, personalize
art-alexeyenko 86dfe83
minor spelling mistake
art-alexeyenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Changesets | ||
|
|
||
| Changesets allows flexible management of multiple packages in a monorepo | ||
|
|
||
| [Changeset docs](https://github.com/changesets/changesets) | ||
| [Common questions](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) | ||
|
|
||
| Quick references: | ||
| - `yarn changeset` add a changeset for current changes. | ||
| - `yarn changeset:cascade-version` - apply version changes from current changesets onto the monrepo (usually runs via CI) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "$schema": "https://unpkg.com/@changesets/config@3.1.2/schema.json", | ||
| "changelog": "../scripts/changesets/changelog.ts", | ||
| "commit": false, | ||
| "access": "public", | ||
| "baseBranch": "dev", | ||
| "ignore": [], | ||
| "snapshot": { | ||
| "useCalculatedVersion": true, | ||
| "prereleaseTemplate": "{tag}.{datetime}" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| name: Prepare Hotfix Release | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| package_name: | ||
| description: 'Full package name' | ||
| required: true | ||
| type: choice | ||
| options: | ||
| - '@sitecore-content-sdk/nextjs' | ||
| - '@sitecore-content-sdk/cli' | ||
| - '@sitecore-content-sdk/react' | ||
| - '@sitecore-content-sdk/search' | ||
| - 'create-content-sdk' | ||
| - '@sitecore-content-sdk/core' | ||
| - '@sitecore-content-sdk/content' | ||
| - '@sitecore-content-sdk/analytics-core' | ||
| - '@sitecore-content-sdk/events' | ||
| - '@sitecore-content-sdk/personalize' | ||
|
|
||
| version: | ||
| description: 'Base version to hotfix' | ||
| required: true | ||
| type: string | ||
|
|
||
| jobs: | ||
| prep-release: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Generate GitHub App Token | ||
| id: generate-token | ||
| uses: actions/create-github-app-token@v2 | ||
| with: | ||
| app-id: ${{ secrets.GH_APP_ID }} | ||
| private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} | ||
| owner: ${{ github.repository_owner }} | ||
|
|
||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| persist-credentials: false | ||
| token: ${{ steps.generate-token.outputs.token }} | ||
|
|
||
| - name: Set git configuration | ||
| run: | | ||
| git config --global user.email builds@sitecore.com | ||
| git config --global user.name "content-sdk-bot" | ||
| git remote set-url origin https://x-access-token:${{ steps.generate-token.outputs.token }}@github.com/${{ github.repository }} | ||
|
|
||
| - name: Use Node.js 24 | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 24 | ||
|
|
||
| - name: Setup GH action | ||
| id: setup-gh-action | ||
| run: | | ||
| BASE_RELEASE="${{ inputs.package_name }}@${{ inputs.version }}" | ||
|
|
||
| if ! git rev-parse "refs/tags/$BASE_RELEASE" >/dev/null 2>&1; then | ||
| echo "Release tag $BASE_RELEASE not found. Please validate your inputs." | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "base_release=$BASE_RELEASE" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Create release branch | ||
| id: create-branch | ||
| run: | | ||
| BRANCH_NAME="release/${{ steps.setup-gh-action.outputs.base_release }}-hotfix" | ||
|
|
||
| if git ls-remote --heads origin "$BRANCH_NAME" | grep -q .; then | ||
| echo "Hotfix branch $BRANCH_NAME already exists" | ||
| echo "Please check if this is expected. Delete the branch and run action again if not." | ||
| exit 1 | ||
| else | ||
| git checkout -b "$BRANCH_NAME" "${{ steps.setup-gh-action.outputs.base_release }}" | ||
| git push -u origin "$BRANCH_NAME" | ||
| echo "Branch $BRANCH_NAME created and pushed" | ||
| fi | ||
|
|
||
| - name: Summary | ||
| run: | | ||
| BRANCH_NAME="${{ steps.create-branch.outputs.branch_name }}" | ||
| BASE_RELEASE="${{ steps.setup-gh-action.outputs.base_release }}" | ||
|
|
||
| echo "## Release Branch Prepared" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "| Property | Value |" >> $GITHUB_STEP_SUMMARY | ||
| echo "|----------|-------|" >> $GITHUB_STEP_SUMMARY | ||
| echo "| **Target Package** | \`$BASE_RELEASE\` |" >> $GITHUB_STEP_SUMMARY | ||
| echo "| **Release Branch** | \`$BRANCH_NAME\` |" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "### Next Steps:" >> $GITHUB_STEP_SUMMARY | ||
| echo "1. Checkout the branch: \`git checkout $BRANCH_NAME\`" >> $GITHUB_STEP_SUMMARY | ||
| echo "2. Cherrypick or add patch changes" >> $GITHUB_STEP_SUMMARY | ||
| echo "3. Add changesets (\`yarn changeset\`)" >> $GITHUB_STEP_SUMMARY | ||
| echo "4. Prepare PR(s) with hotfix changes" >> $GITHUB_STEP_SUMMARY | ||
| echo "5. Push changes. This will update pre-patch canaries and automatically create the hotfix release PR" >> $GITHUB_STEP_SUMMARY | ||
| echo "6. Merge hotfix release PR to trigger the release" >> $GITHUB_STEP_SUMMARY | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,70 +1,182 @@ | ||
| name: Publish | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - dev | ||
| - 'release/**' | ||
| paths: | ||
| - '**' | ||
|
|
||
| jobs: | ||
| publish: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| env: | ||
| YARN_ENABLE_IMMUTABLE_INSTALLS: false | ||
| steps: | ||
| - name: Generate GitHub App Token | ||
| id: generate-token | ||
| uses: actions/create-github-app-token@v2 | ||
| with: | ||
| app-id: ${{ secrets.GH_APP_ID }} | ||
| private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} | ||
| owner: ${{ github.repository_owner }} | ||
|
|
||
| - uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.ref }} | ||
| fetch-depth: 0 | ||
| persist-credentials: false | ||
| token: ${{ steps.generate-token.outputs.token }} | ||
|
|
||
| - name: Set git configuration | ||
| run: | | ||
| git config --global user.email builds@sitecore.com | ||
| git config --global user.name "content-sdk-bot" | ||
| git remote set-url origin https://x-access-token:${{ steps.generate-token.outputs.token }}@github.com/${{ github.repository }} | ||
|
|
||
| - name: Use Node.js 24 | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 24 | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| yarn cache clean --all | ||
| yarn install --immutable | ||
|
|
||
| - name: Build packages | ||
| run: npm run build | ||
|
|
||
| - name: Generate API docs | ||
| run: | | ||
| yarn generate-docs | ||
| git add ./ref-docs/**/* | ||
| git commit -m "Update API docs" | ||
|
|
||
| - name: Pre-release version update | ||
| run: | | ||
| npx lerna version prerelease --exact --preid canary --force-publish --message "%s [skip ci]" --yes | ||
| env: | ||
| GH_TOKEN: ${{ steps.generate-token.outputs.token }} | ||
|
|
||
| - name: Pre-release canary publish | ||
| run: | | ||
| echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc | ||
| npx lerna publish from-git --exact --canary --pre-dist-tag canary --preid canary --no-verify-access --yes | ||
| env: | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| name: Publish | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| on: | ||
| # Trigger for canary and stable releases: | ||
| # - Stable prod release: When PR from changeset-release/* branch is merged with [release] prefix | ||
| # - Canary release: Push to dev or release/* branches (not from changeset-release merge) | ||
| push: | ||
| branches: | ||
| - dev | ||
| - 'release/**' | ||
| paths: | ||
| - '**' | ||
|
|
||
| # changesets/action runs csdk:prep-release which consumes .changeset/*.md in that runner. | ||
| # Canary snapshot must run in a separate job with its own checkout so changesets still exist. | ||
| jobs: | ||
| stable-release-pre: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| YARN_ENABLE_IMMUTABLE_INSTALLS: false | ||
| steps: | ||
| - name: Generate GitHub App Token | ||
| id: generate-token | ||
| uses: actions/create-github-app-token@v2 | ||
| with: | ||
| app-id: ${{ secrets.GH_APP_ID }} | ||
| private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} | ||
| owner: ${{ github.repository_owner }} | ||
|
|
||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.ref }} | ||
| fetch-depth: 0 | ||
| persist-credentials: false | ||
| token: ${{ steps.generate-token.outputs.token }} | ||
|
|
||
| - name: Set git configuration | ||
| run: | | ||
| git config --global user.email builds@sitecore.com | ||
| git config --global user.name "content-sdk-bot" | ||
| git remote set-url origin https://x-access-token:${{ steps.generate-token.outputs.token }}@github.com/${{ github.repository }} | ||
|
|
||
| - name: Use Node.js 24 | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 24 | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| yarn cache clean --all | ||
| yarn install --immutable | ||
|
|
||
| - name: Build packages | ||
| run: npm run build | ||
|
|
||
| - name: Generate API docs | ||
| run: | | ||
| yarn generate-docs | ||
| if [ -n "$(git status --porcelain)" ]; then | ||
| git add ./ref-docs/**/* | ||
| git commit -m "Update API docs [skip ci]" || echo "⚠️ Failed to commit API docs (may already be committed)" | ||
| git push origin HEAD:${{ github.ref_name }} || echo "⚠️ Failed to push API docs (may already be pushed or no changes)" | ||
| else | ||
| echo "No API doc changes to commit" | ||
| fi | ||
|
|
||
| - name: Creating .npmrc | ||
| run: | | ||
| NPM_REGISTRY="${NPM_REGISTRY%/}" | ||
| NPM_REGISTRY="${NPM_REGISTRY}/" | ||
| write_npmrc() { | ||
| { | ||
| echo "@sitecore-content-sdk:registry=https://$NPM_REGISTRY" | ||
| echo "registry=https://$NPM_REGISTRY" | ||
| echo "//$NPM_REGISTRY:_authToken=$NPM_TOKEN" | ||
| } > "$1" | ||
| } | ||
| write_npmrc "$GITHUB_WORKSPACE/.npmrc" | ||
| env: | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| NPM_REGISTRY: ${{ secrets.NPM_REGISTRY }} | ||
|
|
||
| - name: Prepare and Process Changesets Release | ||
| id: changesets | ||
| uses: changesets/action@v1 | ||
| with: | ||
| version: yarn csdk:prep-release | ||
| publish: yarn changeset:publish --tag latest | ||
| commit: '[release][ci] Version bump and changelog' | ||
| title: ${{ github.ref_name == 'dev' && '[csdk] latest release' || format('[csdk] patch release - {0}', github.ref_name) }} | ||
| env: | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| NPM_REGISTRY: ${{ secrets.NPM_REGISTRY }} | ||
| GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} | ||
|
|
||
| canary-snapshot: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| YARN_ENABLE_IMMUTABLE_INSTALLS: false | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.ref }} | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Use Node.js 24 | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 24 | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| yarn cache clean --all | ||
| yarn install --immutable | ||
|
|
||
| - name: Build packages | ||
| run: npm run build | ||
|
|
||
| - name: Creating .npmrc | ||
|
art-alexeyenko marked this conversation as resolved.
|
||
| run: | | ||
| NPM_REGISTRY="${NPM_REGISTRY%/}" | ||
| NPM_REGISTRY="${NPM_REGISTRY}/" | ||
| write_npmrc() { | ||
| { | ||
| echo "@sitecore-content-sdk:registry=https://$NPM_REGISTRY" | ||
| echo "registry=https://$NPM_REGISTRY" | ||
| echo "//$NPM_REGISTRY:_authToken=$NPM_TOKEN" | ||
| } > "$1" | ||
| } | ||
| write_npmrc "$GITHUB_WORKSPACE/.npmrc" | ||
| env: | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| NPM_REGISTRY: ${{ secrets.NPM_REGISTRY }} | ||
|
|
||
| - name: Pre-release canary publish | ||
| id: canary_snapshot | ||
| run: yarn changeset:cascade-snapshot-version | ||
|
|
||
| - name: Compute snapshot npm dist-tag | ||
| id: snapshot_tag | ||
| if: steps.canary_snapshot.outputs.snapshot_publish == 'true' | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const sha = context.sha; | ||
| const short = sha.slice(0, 7); | ||
| const { data } = await github.rest.repos.listPullRequestsAssociatedWithCommit({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| commit_sha: sha, | ||
| }); | ||
| const prNums = data.map((p) => p.number).filter((n) => n != null); | ||
| const prLabel = prNums.length ? String(Math.max(...prNums)) : 'no-pr'; | ||
| const tagPr = `canary.pr-${prLabel}`; | ||
| const tagSha = `canary.commit-${short}`; | ||
| core.setOutput('tag_pr', tagPr); | ||
| core.setOutput('tag_sha', tagSha); | ||
| core.info(`Snapshot npm dist-tags: ${tagPr} + ${tagSha}`); | ||
|
|
||
| - name: Publish canary snapshot packages to npm | ||
| if: steps.canary_snapshot.outputs.snapshot_publish == 'true' | ||
| env: | ||
| COMMIT_NPM_TAG: ${{ steps.snapshot_tag.outputs.tag_sha }} | ||
| PR_NPM_TAG: ${{ steps.snapshot_tag.outputs.tag_pr }} | ||
| run: | | ||
| BRANCH_NAME="${{ github.ref_name }}" | ||
| if [[ "$BRANCH_NAME" =~ ^release/ ]]; then | ||
| NPM_TAG="hotfix-canary" | ||
| else | ||
| NPM_TAG="canary" | ||
| fi | ||
| yarn changeset:publish --tag $NPM_TAG --no-git-tag | ||
| VERSION=$(node -p "require('./packages/create-content-sdk-app/package.json').version") | ||
| npm dist-tag add create-content-sdk-app@$VERSION $COMMIT_NPM_TAG | ||
| npm dist-tag add create-content-sdk-app@$VERSION $PR_NPM_TAG | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,7 @@ | ||
| { | ||
| "lerna": "3.22.1", | ||
| "packages": ["packages/*", "samples/*"], | ||
| "version": "independent", | ||
| "npmClient": "yarn", | ||
| "useWorkspaces": true | ||
| "$schema": "node_modules/lerna/schemas/lerna-schema.json" | ||
| } | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.