Handle long text in dropdown components #120
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
| name: Release | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| inputs: | |
| run_type: | |
| description: "The type of publish to test" | |
| required: true | |
| default: "snapshot" | |
| type: choice | |
| options: | |
| - snapshot | |
| - release | |
| pull_request: | |
| # edited is needed because that's the trigger when the base branch is | |
| # changed on a PR | |
| # The rest are the defaults. | |
| types: [edited, opened, synchronize, reopened] | |
| # IMPORTANT! We set concurrency to this workflow and the branch (github.ref), | |
| # meaning that this workflow can only run one instance, per branch, at a time. | |
| # This prevents us from having two production releases publishing at the same | |
| # time, creating a race condition, and from trying to publish multiple snapshots | |
| # for the same PR at the same time (potentially publishing an earlier commit as | |
| # "latest" and causing confusion). | |
| # | |
| # We also do not want to cancel in-progress runs, because we don't want a | |
| # production publish to be interrupted by a snapshot publish ever. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| # IMPORTANT! We do not want to cancel in-progress runs, because we don't | |
| # want a production publish to be interrupted by a snapshot publish ever. | |
| cancel-in-progress: false | |
| jobs: | |
| # This workflow will run changesets depending on two different scenarios: | |
| # | |
| # 1. If we are landing a specific commit into main (Author PR), then | |
| # changesets will check if there are changes verifying the Markdown files | |
| # generated automatically: | |
| # | |
| # a) There are new versions and there's NO Release PR, then the changesets | |
| # action will create a new Release PR. | |
| # | |
| # b) There's a Release PR, then the changesets action will update the | |
| # existing Release PR with the new commit. | |
| # | |
| # NOTE: (in both cases, changesets will modify the new version in | |
| # package.json for each package, and will remove the MD files as part of the | |
| # Release PR). | |
| # | |
| # 2. If we are landing the Release PR into main, then the changesets action | |
| # will publish the changes to npm. | |
| # | |
| # For more info about this workflow, see: | |
| # https://github.com/changesets/action#usage | |
| release: | |
| name: Release | |
| if: | | |
| (github.event_name == 'workflow_dispatch' && inputs.run_type == 'release') || | |
| (github.event_name == 'push' && github.ref == 'refs/heads/main') | |
| runs-on: ${{ matrix.os }} | |
| permissions: | |
| id-token: write # For trusted publishing to npm (includes provenance) | |
| contents: write # For GitHub pages and creating release PRs | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest] | |
| node-version: [20.x] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| fetch-depth: 0 | |
| - name: Install & cache node_modules | |
| uses: ./.github/actions/shared-node-cache | |
| with: | |
| node-version: 20.x | |
| - name: ⬆️ Upgrade npm for OIDC support | |
| shell: bash | |
| run: | | |
| # npm trusted publishing requires npm CLI v11.5.1+ | |
| # Node.js 22 ships with npm 10.x, so we need to upgrade | |
| npm install -g npm@latest | |
| echo "✅ npm upgraded to $(npm --version)" | |
| - name: Create Release Pull Request or Publish to npm | |
| id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| publish: pnpm publish:ci | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.KHAN_ACTIONS_BOT_TOKEN }} | |
| # Note: we no longer use the NPM_TOKEN secret because we've enabled | |
| # Trusted Publishing (https://docs.npmjs.com/trusted-publishers) on | |
| # the npmjs.com side. Eg: | |
| # https://www.npmjs.com/package/@khanacademy/wonder-blocks-core/access | |
| # | |
| # We set this so that (p)npm publish will include the | |
| # provenance information in the package.json file and surface | |
| # it in the npm registry. | |
| # See: https://docs.npmjs.com/generating-provenance-statements | |
| NPM_CONFIG_PROVENANCE: true | |
| - name: Send a Slack notification if a publish fails | |
| if: failure() | |
| uses: rtCamp/action-slack-notify@v2 | |
| env: | |
| SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
| SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }} | |
| SLACK_MSG_AUTHOR: ${{ github.event.pull_request.user.login }} | |
| SLACK_USERNAME: GithubGoose | |
| SLACK_ICON_EMOJI: ":goose:" | |
| SLACK_MESSAGE: "Something went wrong with the release of ${{ github.event.repository.name }}. \nPlease check the logs → https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
| SLACK_TITLE: "Oops! I'm the Bad News Goose!" | |
| SLACK_FOOTER: Wonder Blocks Slack Notification | |
| MSG_MINIMAL: true | |
| - name: Build Slack message | |
| id: slack_message | |
| if: steps.changesets.outputs.published == 'true' | |
| # We have to do this in stages to make sure that the output into the | |
| # GITHUB_ENV retains are lines and is valid for updating the env. | |
| # This is based on: | |
| # - LIVE: https://trstringer.com/github-actions-multiline-strings/ | |
| # - ARCHIVE: https://web.archive.org/web/20211017170102/https://trstringer.com/github-actions-multiline-strings/ | |
| # - LIVE: https://renehernandez.io/snippets/multiline-strings-as-a-job-output-in-github-actions/ | |
| # - ARCHIVE: https://web.archive.org/web/20211115000540/https://renehernandez.io/snippets/multiline-strings-as-a-job-output-in-github-actions/ | |
| run: | | |
| UPDATED_PACKAGES=$(jq -r '[group_by(.name) | .[] | " - "+.[].name+"@"+.[].version] | join("\n")' <<< '${{ steps.changesets.outputs.publishedPackages }}') | |
| UPDATED_PACKAGES="${UPDATED_PACKAGES//'%'/'%25'}" | |
| UPDATED_PACKAGES="${UPDATED_PACKAGES//$'\n'/'%0A'}" | |
| UPDATED_PACKAGES="${UPDATED_PACKAGES//$'\r'/'%0D'}" | |
| echo "::set-output name=updated_packages::$UPDATED_PACKAGES" | |
| - name: Send a Slack notification if a publish happens | |
| if: steps.changesets.outputs.published == 'true' | |
| uses: rtCamp/action-slack-notify@v2 | |
| env: | |
| SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
| SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }} | |
| SLACK_MSG_AUTHOR: ${{ github.event.pull_request.user.login }} | |
| SLACK_USERNAME: GithubGoose | |
| SLACK_ICON_EMOJI: ":goose:" | |
| SLACK_MESSAGE: "A new version of ${{ github.event.repository.name }} was published! 🎉 \n${{ steps.slack_message.outputs.updated_packages }}\nRelease notes → https://github.com/${{ github.repository }}/releases/" | |
| SLACK_TITLE: "New Wonder Blocks release!" | |
| SLACK_FOOTER: Wonder Blocks Slack Notification | |
| MSG_MINIMAL: true | |
| # Publishes a PR's changes to an npm snapshot. This allows for easy testing of | |
| # PR code in a host applicaiton without doing a release. | |
| publish_snapshot: | |
| name: Publish npm snapshot | |
| # [FEI-7341] DISABLED: Snapshots temporarily disabled due to security concerns (shai-halud worm) | |
| # To re-enable, replace the condition below with the original multi-line condition | |
| if: false | |
| # Original condition (commented out): | |
| # if: | | |
| # (github.event_name == 'workflow_dispatch' && inputs.run_type == 'snapshot') || | |
| # (github.event_name == 'pull_request' && !startsWith(github.head_ref, 'changeset-release/')) | |
| runs-on: ${{ matrix.os }} | |
| permissions: | |
| id-token: write # required for publishing to npm with provenance | |
| issues: write # required because we write a comment on the PR | |
| pull-requests: write # required because we create a comment on the PR | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest] | |
| node-version: [20.x] | |
| steps: | |
| # We need to checkout all history, so that the changeset tool can diff it | |
| - name: Checkout current commit | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: "0" | |
| - name: Ensure main branch is avaialble | |
| run: | | |
| REF=$(git rev-parse HEAD) | |
| git checkout main | |
| git checkout $REF | |
| # Helper to get the URL of the current run, if we need it. | |
| - name: Get workflow run URL | |
| id: get-run-url | |
| run: echo "run_url=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> $GITHUB_OUTPUT | |
| # We need to see if any releases are in progress. | |
| # We do not want to try and publish anything if a publish is | |
| # pending. We fail here, but we make sure to update the | |
| # PR comment later. This has to come after the checkout. | |
| - name: Check for release | |
| id: check-release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| # Releases are triggered by merging "Version Packages" PRs. | |
| # So we look for instances of the release.yml workflow, with | |
| # a title containing "Version Packages", that are in progress. | |
| release_count=$(gh run list --workflow release.yml --json status,displayTitle --jq '[.[] | select(.status == "in_progress" and ((.displayTitle | contains("Version Packages")) or (.displayTitle | contains("RELEASING:"))))] | length') | |
| echo "release_count=$release_count" >> $GITHUB_OUTPUT | |
| if [ "$release_count" -ne 0 ]; then | |
| echo "Error: There are $release_count releases in progress." | |
| exit 1 | |
| else | |
| echo "No releases in progress." | |
| fi | |
| - name: Use Node.js ${{ matrix.node-version }} & Install & cache node_modules | |
| uses: ./.github/actions/shared-node-cache | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| - name: ⬆️ Upgrade npm for OIDC support | |
| shell: bash | |
| run: | | |
| # npm trusted publishing requires npm CLI v11.5.1+ | |
| # Node.js 22 ships with npm 10.x, so we need to upgrade | |
| npm install -g npm@latest | |
| echo "✅ npm upgraded to $(npm --version)" | |
| - name: Publish snapshot release to npm | |
| id: publish-snapshot | |
| run: ./utils/publish/publish-snapshot.sh # All config is via Github env vars | |
| - name: Calculate short SHA for this commit | |
| id: short-sha | |
| run: echo "short_sha=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_OUTPUT | |
| # Note: these two actions are locked to the latest version that were | |
| # published when @jeremy (Jeremy Wiebe) created the original job in Perseus. | |
| - name: Find existing comment | |
| # Even if we're failing, we want to update the comments. | |
| if: always() | |
| uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e | |
| id: find-comment | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| comment-author: "github-actions[bot]" | |
| body-includes: "npm Snapshot:" | |
| - name: Create or update npm snapshot comment - Success | |
| if: steps.publish-snapshot.outputs.npm_snapshot_tag != '' | |
| uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| comment-id: ${{ steps.find-comment.outputs.comment-id }} | |
| edit-mode: replace | |
| body: | | |
| ## npm Snapshot: Published | |
| 🎉 Good news!! We've packaged up the latest commit from this PR (${{ | |
| steps.short-sha.outputs.short_sha }}) and published all packages with changesets to npm. | |
| You can install the packages in `frontend` by running: | |
| ```sh | |
| ./dev/tools/deploy_wonder_blocks.js --tag="${{ | |
| steps.publish-snapshot.outputs.npm_snapshot_tag }}" | |
| ``` | |
| Packages can also be installed manually by running: | |
| ```sh | |
| pnpm add @khanacademy/wonder-blocks-<package-name>@${{ | |
| steps.publish-snapshot.outputs.npm_snapshot_tag }} | |
| ``` | |
| - name: Create or update npm snapshot comment - Failure | |
| if: steps.publish-snapshot.outputs.npm_snapshot_tag == '' | |
| uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| comment-id: ${{ steps.find-comment.outputs.comment-id }} | |
| edit-mode: replace | |
| body: | | |
| ## npm Snapshot: **NOT** Published | |
| 🤕 Oh noes!! We couldn't find any changesets in this PR (${{ | |
| steps.short-sha.outputs.short_sha }}). As a result, we did **not** publish an npm snapshot for you. | |
| - name: Create or update npm snapshot comment - failure, concurrent with release | |
| if: failure() && steps.check-release.outputs.release_count != '0' | |
| uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| comment-id: ${{ steps.find-comment.outputs.comment-id }} | |
| edit-mode: replace | |
| body: | | |
| # npm Snapshot: **NOT** Published | |
| 🤕 Oh noes!! We couldn't publish an npm snapshot for you because | |
| there is a release in progress. Please wait for the release to | |
| finish, then retry this workflow. | |
| [View the workflow run](${{ steps.get-run-url.outputs.run_url }}) |