|
5 | 5 | branches: |
6 | 6 | - main |
7 | 7 | workflow_dispatch: |
| 8 | + inputs: |
| 9 | + release_type: |
| 10 | + description: "Release type" |
| 11 | + required: true |
| 12 | + type: choice |
| 13 | + default: "snapshot" |
| 14 | + options: |
| 15 | + - "stable" |
| 16 | + - "snapshot" |
| 17 | + packages: |
| 18 | + description: "Packages to publish (snapshots only)" |
| 19 | + required: false |
| 20 | + type: choice |
| 21 | + default: "@nylas/react" |
| 22 | + options: |
| 23 | + - "@nylas/connect" |
| 24 | + - "@nylas/react" |
| 25 | + snapshot_tag: |
| 26 | + description: "Snapshot tag (snapshots only)" |
| 27 | + required: false |
| 28 | + default: "canary" |
| 29 | + type: choice |
| 30 | + options: |
| 31 | + - "canary" |
| 32 | + - "alpha" |
| 33 | + - "beta" |
| 34 | + - "snapshot" |
| 35 | + - "dev" |
| 36 | + |
| 37 | +run-name: >- |
| 38 | + ${{ inputs.release_type == 'snapshot' |
| 39 | + && format('Snapshot: {0}@{1} by @{2}', inputs.packages, inputs.snapshot_tag, github.actor) |
| 40 | + || 'Release' }} |
8 | 41 |
|
9 | 42 | # Prevent multiple releases from running at the same time |
10 | 43 | concurrency: ${{ github.workflow }}-${{ github.ref }} |
|
15 | 48 | jobs: |
16 | 49 | release: |
17 | 50 | name: Release |
| 51 | + if: inputs.release_type != 'snapshot' |
18 | 52 | runs-on: ubuntu-latest |
19 | 53 | permissions: |
20 | 54 | contents: write # to create release commits and tags |
|
29 | 63 | - name: Checkout code |
30 | 64 | uses: actions/checkout@v4 |
31 | 65 | with: |
32 | | - # Need full history for changesets |
33 | 66 | fetch-depth: 0 |
34 | | - # Use a token that can trigger workflows (for release PR creation) |
35 | 67 | token: ${{ secrets.SDK_RELEASE_PAT }} |
36 | 68 |
|
37 | 69 | - name: Setup Node.js |
@@ -92,31 +124,66 @@ jobs: |
92 | 124 | GITHUB_TOKEN: ${{ secrets.SDK_RELEASE_PAT }} |
93 | 125 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
94 | 126 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # do not remove this line (https://github.com/changesets/action/issues/98) |
95 | | - PM_CONFIG_PROVENANCE: true |
| 127 | + NPM_CONFIG_PROVENANCE: true |
96 | 128 |
|
97 | | - # Slack notification job (only when packages are published) |
98 | | - notify: |
99 | | - name: Notify Slack |
| 129 | + snapshot: |
| 130 | + name: Publish Snapshot |
| 131 | + if: inputs.release_type == 'snapshot' |
100 | 132 | runs-on: ubuntu-latest |
101 | | - needs: release |
102 | | - if: needs.release.outputs.published == 'true' |
| 133 | + permissions: |
| 134 | + contents: read |
| 135 | + id-token: write # for NPM provenance |
| 136 | + timeout-minutes: 15 |
103 | 137 |
|
104 | 138 | steps: |
105 | 139 | - name: Checkout code |
106 | 140 | uses: actions/checkout@v4 |
107 | | - |
108 | | - - name: Setup Node.js |
109 | | - uses: actions/setup-node@v4 |
110 | 141 | with: |
111 | | - node-version: ${{ env.NODE_VERSION }} |
| 142 | + fetch-depth: 0 |
112 | 143 |
|
113 | 144 | - name: Setup pnpm |
114 | 145 | uses: pnpm/action-setup@v4 |
115 | 146 | with: |
116 | 147 | run_install: false |
117 | 148 |
|
| 149 | + - name: Setup Node.js |
| 150 | + uses: actions/setup-node@v4 |
| 151 | + with: |
| 152 | + node-version: ${{ env.NODE_VERSION }} |
| 153 | + cache: pnpm |
| 154 | + registry-url: "https://registry.npmjs.org" |
| 155 | + |
118 | 156 | - name: Install dependencies |
119 | 157 | run: pnpm install --frozen-lockfile |
120 | 158 |
|
121 | | - - name: Send Slack notification |
122 | | - run: pnpm slack:notify '${{ needs.release.outputs.publishedPackages }}' ${{ secrets.SLACK_WEBHOOK_URL }} |
| 159 | + - name: Create snapshot version |
| 160 | + run: pnpm changeset version --snapshot ${{ inputs.snapshot_tag }} |
| 161 | + env: |
| 162 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 163 | + |
| 164 | + - name: Build packages |
| 165 | + run: pnpm nx run-many -t build --parallel=3 --projects=${{ inputs.packages }} |
| 166 | + |
| 167 | + - name: Publish snapshot |
| 168 | + run: | |
| 169 | + pnpm changeset publish --no-git-tag --snapshot --tag ${{ inputs.snapshot_tag }} | tee /tmp/changeset_publish.log |
| 170 | +
|
| 171 | + echo '### Published Snapshot Packages' >> $GITHUB_STEP_SUMMARY |
| 172 | + echo '' >> $GITHUB_STEP_SUMMARY |
| 173 | +
|
| 174 | + grep -oP '@nylas/\S+' /tmp/changeset_publish.log | grep '@[0-9]' | sort -u | \ |
| 175 | + sed 's/^/- /' >> $GITHUB_STEP_SUMMARY || echo '- No packages published' >> $GITHUB_STEP_SUMMARY |
| 176 | +
|
| 177 | + echo '' >> $GITHUB_STEP_SUMMARY |
| 178 | + echo '<details><summary>Full publish log</summary>' >> $GITHUB_STEP_SUMMARY |
| 179 | + echo '' >> $GITHUB_STEP_SUMMARY |
| 180 | + echo '```' >> $GITHUB_STEP_SUMMARY |
| 181 | + cat /tmp/changeset_publish.log >> $GITHUB_STEP_SUMMARY |
| 182 | + echo '```' >> $GITHUB_STEP_SUMMARY |
| 183 | + echo '</details>' >> $GITHUB_STEP_SUMMARY |
| 184 | + env: |
| 185 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 186 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 187 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 188 | + NPM_CONFIG_PROVENANCE: true |
| 189 | + |
0 commit comments