|
20 | 20 | - '.github/workflows/release.yml' |
21 | 21 | # Allows you to run this workflow manually from the Actions tab |
22 | 22 | workflow_dispatch: |
| 23 | + inputs: |
| 24 | + snapshot_tag: |
| 25 | + description: 'NPM dist-tag for the beta release' |
| 26 | + required: true |
| 27 | + default: 'beta' |
| 28 | + type: choice |
| 29 | + options: |
| 30 | + - beta |
| 31 | + - alpha |
| 32 | + - rc |
| 33 | + - preview |
23 | 34 |
|
24 | 35 | concurrency: ${{ github.workflow }}-${{ github.ref }} |
25 | 36 |
|
|
34 | 45 | # This job prepares the release by creating or updating a release PR. |
35 | 46 | # Notice the omission of the `publish` flag in the changesets action. |
36 | 47 | prepare-release: |
| 48 | + if: github.event_name == 'push' |
37 | 49 | permissions: |
38 | 50 | id-token: write |
39 | 51 | contents: write |
|
90 | 102 | env: |
91 | 103 | NPM_CONFIG_PROVENANCE: true |
92 | 104 | GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} |
93 | | - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
94 | 105 |
|
95 | 106 | check-latest-published: |
| 107 | + if: github.event_name == 'push' |
96 | 108 | runs-on: ubuntu-latest |
97 | 109 | outputs: |
98 | 110 | all_latest: ${{ steps.check.outputs.all_latest }} |
@@ -129,15 +141,15 @@ jobs: |
129 | 141 | # Windows is excluded here for speed but tested nightly via cli-install-test.yml. |
130 | 142 | cli-install-cross-platform-release-test: |
131 | 143 | needs: [check-latest-published] |
132 | | - if: needs.check-latest-published.outputs.all_latest == 'false' |
| 144 | + if: github.event_name == 'push' && needs.check-latest-published.outputs.all_latest == 'false' |
133 | 145 | uses: ./.github/workflows/cli-install-test.yml |
134 | 146 | with: |
135 | 147 | include-windows: false |
136 | 148 |
|
137 | 149 | # This job publishes the release to NPM. |
138 | 150 | publish-release: |
139 | 151 | needs: cli-install-cross-platform-release-test |
140 | | - if: github.ref == 'refs/heads/main' |
| 152 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
141 | 153 | permissions: |
142 | 154 | id-token: write |
143 | 155 | contents: write |
@@ -166,6 +178,7 @@ jobs: |
166 | 178 | uses: actions/setup-node@v6 |
167 | 179 | with: |
168 | 180 | node-version-file: .nvmrc |
| 181 | + registry-url: 'https://registry.npmjs.org' |
169 | 182 |
|
170 | 183 | - name: Setup Foundry |
171 | 184 | uses: ./.github/actions/setup-foundry |
@@ -198,4 +211,81 @@ jobs: |
198 | 211 | env: |
199 | 212 | NPM_CONFIG_PROVENANCE: true |
200 | 213 | GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} |
201 | | - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 214 | + |
| 215 | + publish-beta: |
| 216 | + if: github.event_name == 'workflow_dispatch' |
| 217 | + concurrency: |
| 218 | + group: npm-beta-release |
| 219 | + cancel-in-progress: false |
| 220 | + permissions: |
| 221 | + contents: read |
| 222 | + id-token: write |
| 223 | + runs-on: ubuntu-latest |
| 224 | + steps: |
| 225 | + - name: Checkout |
| 226 | + uses: actions/checkout@v6 |
| 227 | + with: |
| 228 | + fetch-depth: 0 |
| 229 | + submodules: recursive |
| 230 | + persist-credentials: false |
| 231 | + |
| 232 | + - name: Setup Node.js |
| 233 | + uses: actions/setup-node@v6 |
| 234 | + with: |
| 235 | + node-version-file: .nvmrc |
| 236 | + registry-url: 'https://registry.npmjs.org' |
| 237 | + |
| 238 | + - name: Check for changesets |
| 239 | + run: | |
| 240 | + CHANGESET_COUNT=$(find .changeset -name "*.md" ! -name "README.md" ! -name "config.json" 2>/dev/null | wc -l | tr -d ' ') |
| 241 | + if [ "$CHANGESET_COUNT" -eq 0 ]; then |
| 242 | + echo "::error::No pending changesets found. Beta releases require pending changeset files." |
| 243 | + echo "" |
| 244 | + echo "To create a beta release:" |
| 245 | + echo "1. Add a changeset: pnpm exec changeset" |
| 246 | + echo "2. Commit the changeset file" |
| 247 | + echo "3. Run this workflow again" |
| 248 | + exit 1 |
| 249 | + fi |
| 250 | + echo "Found $CHANGESET_COUNT changeset(s)" |
| 251 | +
|
| 252 | + - name: Setup pnpm |
| 253 | + uses: pnpm/action-setup@v4 |
| 254 | + |
| 255 | + - name: Install dependencies |
| 256 | + run: pnpm install --frozen-lockfile |
| 257 | + |
| 258 | + - name: Create snapshot versions |
| 259 | + run: pnpm exec changeset version --snapshot ${{ inputs.snapshot_tag }} |
| 260 | + |
| 261 | + - name: Get snapshot version |
| 262 | + id: version |
| 263 | + run: | |
| 264 | + SNAPSHOT_VERSION=$(node -p "require('./typescript/sdk/package.json').version") |
| 265 | + echo "snapshot=$SNAPSHOT_VERSION" >> $GITHUB_OUTPUT |
| 266 | +
|
| 267 | + # Need to install foundry for the build step. `hardhat-foundry` expects foundry to be installed. |
| 268 | + - name: Setup Foundry |
| 269 | + uses: ./.github/actions/setup-foundry |
| 270 | + |
| 271 | + - name: Build packages |
| 272 | + run: pnpm run build && pnpm run build:zk |
| 273 | + |
| 274 | + - name: Publish beta packages |
| 275 | + run: pnpm exec changeset publish --tag ${{ inputs.snapshot_tag }} --no-git-tag |
| 276 | + env: |
| 277 | + NPM_CONFIG_PROVENANCE: true |
| 278 | + |
| 279 | + - name: Summary |
| 280 | + run: | |
| 281 | + echo "### Beta Release Published" >> $GITHUB_STEP_SUMMARY |
| 282 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 283 | + echo "**Version:** \`${{ steps.version.outputs.snapshot }}\`" >> $GITHUB_STEP_SUMMARY |
| 284 | + echo "**NPM Tag:** \`${{ inputs.snapshot_tag }}\`" >> $GITHUB_STEP_SUMMARY |
| 285 | + echo "**Branch:** \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY |
| 286 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 287 | + echo "Install with:" >> $GITHUB_STEP_SUMMARY |
| 288 | + echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY |
| 289 | + echo "npm install @hyperlane-xyz/sdk@${{ inputs.snapshot_tag }}" >> $GITHUB_STEP_SUMMARY |
| 290 | + echo "npm install @hyperlane-xyz/cli@${{ inputs.snapshot_tag }}" >> $GITHUB_STEP_SUMMARY |
| 291 | + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY |
0 commit comments