Release #48
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: | |
| release_type: | |
| description: "Release type" | |
| required: true | |
| type: choice | |
| default: "snapshot" | |
| options: | |
| - "stable" | |
| - "snapshot" | |
| packages: | |
| description: "Packages to publish (snapshots only)" | |
| required: false | |
| type: choice | |
| default: "@nylas/react" | |
| options: | |
| - "@nylas/connect" | |
| - "@nylas/react" | |
| snapshot_tag: | |
| description: "Snapshot tag (snapshots only)" | |
| required: false | |
| default: "canary" | |
| type: choice | |
| options: | |
| - "canary" | |
| - "alpha" | |
| - "beta" | |
| - "snapshot" | |
| - "dev" | |
| run-name: >- | |
| ${{ inputs.release_type == 'snapshot' | |
| && format('Snapshot: {0}@{1} by @{2}', inputs.packages, inputs.snapshot_tag, github.actor) | |
| || 'Release' }} | |
| # Prevent multiple releases from running at the same time | |
| concurrency: ${{ github.workflow }}-${{ github.ref }} | |
| env: | |
| NODE_VERSION: ${{ vars.NODE_VERSION }} | |
| jobs: | |
| release: | |
| name: Release | |
| if: inputs.release_type != 'snapshot' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # to create release commits and tags | |
| pull-requests: write # to create release PRs | |
| id-token: write # for NPM provenance | |
| timeout-minutes: 15 | |
| outputs: | |
| published: ${{ steps.changesets.outputs.published }} | |
| publishedPackages: ${{ steps.changesets.outputs.publishedPackages }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.SDK_RELEASE_PAT }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Update npm | |
| run: npm install -g npm@latest | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| run_install: false | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Type check | |
| run: pnpm typecheck | |
| - name: Check formatting | |
| run: pnpm format:check | |
| - name: Build packages | |
| run: pnpm build | |
| - name: Run tests | |
| run: pnpm test | |
| - name: Run tests with coverage | |
| run: pnpm --filter @nylas/connect coverage | |
| - name: Create Release Pull Request or Publish to NPM | |
| id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| version: pnpm run version | |
| publish: pnpm run publish | |
| title: "chore: version packages" | |
| commit: "chore: version packages" | |
| createGithubReleases: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.SDK_RELEASE_PAT }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # do not remove this line (https://github.com/changesets/action/issues/98) | |
| NPM_CONFIG_PROVENANCE: true | |
| snapshot: | |
| name: Publish Snapshot | |
| if: inputs.release_type == 'snapshot' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write # for NPM provenance | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| run_install: false | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: pnpm | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Create snapshot version | |
| run: pnpm changeset version --snapshot ${{ inputs.snapshot_tag }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build packages | |
| run: pnpm nx run-many -t build --parallel=3 --projects=${{ inputs.packages }} | |
| - name: Publish snapshot | |
| run: | | |
| pnpm changeset publish --no-git-tag --snapshot --tag ${{ inputs.snapshot_tag }} | tee /tmp/changeset_publish.log | |
| echo '### Published Snapshot Packages' >> $GITHUB_STEP_SUMMARY | |
| echo '' >> $GITHUB_STEP_SUMMARY | |
| grep -oP '@nylas/\S+' /tmp/changeset_publish.log | grep '@[0-9]' | sort -u | \ | |
| sed 's/^/- /' >> $GITHUB_STEP_SUMMARY || echo '- No packages published' >> $GITHUB_STEP_SUMMARY | |
| echo '' >> $GITHUB_STEP_SUMMARY | |
| echo '<details><summary>Full publish log</summary>' >> $GITHUB_STEP_SUMMARY | |
| echo '' >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| cat /tmp/changeset_publish.log >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| echo '</details>' >> $GITHUB_STEP_SUMMARY | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| NPM_CONFIG_PROVENANCE: true | |