-
Notifications
You must be signed in to change notification settings - Fork 27
CRAFT-2033: updates to release and preview release workflows for trusted publishing #3219
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 all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
acd6642
fix(release): updates to release and preview release workflows for tr…
tylermorrisford b62f863
fix(release): add caller for preview release
tylermorrisford 2b77a58
fix(release): clarify release workflow as entry point
tylermorrisford e228f38
fix(release): update preview release filename
tylermorrisford 8c26e6f
fix(release): rm branch name requirement for previews
tylermorrisford 760fb61
fix(release): rm provenance arg
tylermorrisford 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
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,94 @@ | ||
| name: Publish Release | ||
| # Reusable workflow that handles official releases: | ||
| # - Versions packages using changesets and publishes to npm | ||
| # - Creates GitHub releases | ||
| # - Publishes canary releases if no official release was created | ||
|
|
||
| on: | ||
| workflow_call: | ||
|
|
||
| jobs: | ||
| publish-release: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| # Get GitHub token via the CT Changesets App | ||
| - name: Generate GitHub token (via CT Changesets App) | ||
| id: generate_github_token | ||
| uses: tibdex/github-app-token@v2.1.0 | ||
| with: | ||
| app_id: ${{ secrets.CT_CHANGESETS_APP_ID }} | ||
| private_key: ${{ secrets.CT_CHANGESETS_APP_PEM }} | ||
|
|
||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| # Pass a personal access token (using our `ct-release-bot` account) to be able to trigger | ||
| # other workflows | ||
| # https://help.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token | ||
| # https://github.bokerqi.topmunity/t/action-does-not-trigger-another-on-push-tag-action/17148/8 | ||
| token: ${{ steps.generate_github_token.outputs.token }} | ||
|
|
||
| - name: Setup Node (uses version in .nvmrc) | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| registry-url: 'https://registry.npmjs.org' | ||
|
|
||
| - name: Get yarn cache | ||
| id: yarn-cache | ||
| run: echo "::set-output name=dir::$(yarn config get cacheFolder)" | ||
|
|
||
| - name: Verify npm version | ||
| run: | | ||
| npm --version | ||
| # Ensure latest npm is installed for trusted publishing (OIDC) | ||
|
|
||
| - uses: actions/cache@v5 | ||
| with: | ||
| path: ${{ steps.yarn-cache.outputs.dir }} | ||
| key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock', 'patches/*.patch') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-yarn- | ||
|
|
||
| - name: Install dependencies | ||
| run: yarn install --immutable | ||
|
|
||
| - name: Building packages | ||
| run: yarn build | ||
|
|
||
| - name: Building package READMEs | ||
| run: yarn generate-readmes | ||
| env: | ||
| CI: true | ||
|
|
||
| - name: Storing release version for changeset | ||
| id: release_version | ||
| run: echo "VALUE=$(./scripts/print_release_version.sh)" >> $GITHUB_OUTPUT | ||
| shell: bash | ||
| env: | ||
| GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }} | ||
|
|
||
| - name: Create Release Pull Request or Publish to npm | ||
| id: changesets | ||
| uses: changesets/action@v1.7.0 | ||
| with: | ||
| commit: 'ci(changesets): version packages' | ||
| publish: yarn changeset publish | ||
| version: yarn changeset:version-and-format | ||
| createGithubReleases: aggregate | ||
| githubReleaseName: v${{ steps.release_version.outputs.VALUE }} | ||
| githubTagName: v${{ steps.release_version.outputs.VALUE }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }} | ||
| SKIP_POSTINSTALL_DEV_SETUP: true | ||
|
|
||
| # Publish canary releases only if the packages weren't published already | ||
| - name: Publishing canary releases to npm registry | ||
| if: steps.changesets.outputs.published != 'true' | ||
| run: | | ||
| git checkout main | ||
| yarn changeset version --snapshot canary | ||
| yarn changeset publish --tag canary | ||
| env: | ||
| GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }} |
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,96 +1,30 @@ | ||
| name: Release | ||
| # Entry workflow that coordinates release processes: | ||
| # - Publishes official releases when code is pushed to main, adhering to the single workflow, npm trusted publishing/OIDC pattern | ||
| # - Publishes preview releases when triggered via PR comment with [preview_deployment] | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| issue_comment: | ||
| types: [created] | ||
|
|
||
| jobs: | ||
| release: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| # Get GitHub token via the CT Changesets App | ||
| - name: Generate GitHub token (via CT Changesets App) | ||
| id: generate_github_token | ||
| uses: tibdex/github-app-token@v2.1.0 | ||
| with: | ||
| app_id: ${{ secrets.CT_CHANGESETS_APP_ID }} | ||
| private_key: ${{ secrets.CT_CHANGESETS_APP_PEM }} | ||
|
|
||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| # Pass a personal access token (using our `ct-release-bot` account) to be able to trigger | ||
| # other workflows | ||
| # https://help.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token | ||
| # https://github.bokerqi.topmunity/t/action-does-not-trigger-another-on-push-tag-action/17148/8 | ||
| token: ${{ steps.generate_github_token.outputs.token }} | ||
|
|
||
| - name: Setup Node (uses version in .nvmrc) | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
|
|
||
| - name: Get yarn cache | ||
| id: yarn-cache | ||
| run: echo "::set-output name=dir::$(yarn config get cacheFolder)" | ||
|
|
||
|
|
||
| - name: Verify npm version | ||
| run: | | ||
| npm --version | ||
| # Ensure latest npm is installed for trusted publishing (OIDC) | ||
|
|
||
| - uses: actions/cache@v5 | ||
| with: | ||
| path: ${{ steps.yarn-cache.outputs.dir }} | ||
| key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock', 'patches/*.patch') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-yarn- | ||
|
|
||
| - name: Install dependencies | ||
| run: yarn install --immutable | ||
|
|
||
| - name: Building packages | ||
| run: yarn build | ||
|
|
||
| - name: Building package READMEs | ||
| run: yarn generate-readmes | ||
| env: | ||
| CI: true | ||
|
|
||
| - name: Storing release version for changeset | ||
| id: release_version | ||
| run: echo "VALUE=$(./scripts/print_release_version.sh)" >> $GITHUB_OUTPUT | ||
| shell: bash | ||
| env: | ||
| GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }} | ||
|
|
||
| - name: Create Release Pull Request or Publish to npm | ||
| id: changesets | ||
| uses: dotansimha/changesets-action@v1.5.2 | ||
| with: | ||
| commit: 'ci(changesets): version packages' | ||
| publish: yarn changeset publish | ||
| version: yarn changeset:version-and-format | ||
| createGithubReleases: aggregate | ||
| githubReleaseName: v${{ steps.release_version.outputs.VALUE }} | ||
| githubTagName: v${{ steps.release_version.outputs.VALUE }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }} | ||
| SKIP_POSTINSTALL_DEV_SETUP: true | ||
|
|
||
| # Publish canary releases only if the packages weren't published already | ||
| - name: Publishing canary releases to npm registry | ||
| if: steps.changesets.outputs.published != 'true' | ||
| run: | | ||
| git checkout main | ||
| yarn changeset version --snapshot canary | ||
| yarn changeset publish --tag canary | ||
| env: | ||
| GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }} | ||
| publish-release: | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
| uses: ./.github/workflows/publish-release.yml | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| secrets: inherit | ||
|
|
||
| publish-preview: | ||
| if: github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '[preview_deployment]') | ||
| uses: ./.github/workflows/preview-release-on-comment.yml | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| pull-requests: write | ||
| issues: write | ||
| secrets: inherit |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should name the file `preview-release-on-comment, and update the file to match the same patterns as in app-kit