The best way to control Claude Code, Codex and more from any computer or phone
| 1 | name: Release |
| 2 | |
| 3 | on: |
| 4 | workflow_dispatch: |
| 5 | inputs: |
| 6 | version: |
| 7 | description: >- |
| 8 | Release spec, bumped from the version every package.json shares. |
| 9 | `beta` (the default) publishes the next beta, e.g. `2.0.0-beta.81` |
| 10 | to `2.0.0-beta.82`; `beta.N` publishes that candidate. `rc[.N]` and |
| 11 | `alpha[.N]` select those prerelease channels. `patch|minor|major` |
| 12 | bump per semver, and `x.y.z[-beta.N]` publishes exactly that |
| 13 | version. Anything else publishes `0.0.0-<name>` without committing |
| 14 | it. |
| 15 | required: false |
| 16 | type: string |
| 17 | default: "beta" |
| 18 | |
| 19 | concurrency: |
| 20 | group: release-${{ github.ref }} |
| 21 | cancel-in-progress: false |
| 22 | |
| 23 | permissions: |
| 24 | contents: write |
| 25 | id-token: write |
| 26 | |
| 27 | env: |
| 28 | ALCHEMY_REPO: alchemy-run/alchemy |
| 29 | |
| 30 | jobs: |
| 31 | build: |
| 32 | name: Build and pack |
| 33 | runs-on: blacksmith-8vcpu-ubuntu-2404 |
| 34 | outputs: |
| 35 | sha: ${{ steps.commit.outputs.sha }} |
| 36 | version: ${{ steps.release.outputs.version }} |
| 37 | channel: ${{ steps.release.outputs.channel }} |
| 38 | steps: |
| 39 | - name: Generate bot token |
| 40 | id: bot-token |
| 41 | uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 |
| 42 | with: |
| 43 | app-id: ${{ secrets.ALCHEMY_VERSION_BOT_ID }} |
| 44 | private-key: ${{ secrets.ALCHEMY_VERSION_BOT_PRIVATE_KEY }} |
| 45 | |
| 46 | - name: Checkout repository |
| 47 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 48 | with: |
| 49 | fetch-depth: 0 |
| 50 | token: ${{ steps.bot-token.outputs.token }} |
| 51 | |
| 52 | - name: Checkout distilled |
| 53 | run: git submodule update --init --depth=1 --checkout -- submodules/distilled |
| 54 | |
| 55 | - name: Setup pnpm, Node.js, Bun and install dependencies |
| 56 | uses: pnpm/setup@703c52620218391530e48b9e8870d5c0082e1b9b # v2.1.0 |
| 57 | with: |
| 58 | cache: true |
| 59 | install: true |
| 60 | require-lockfile: true |
| 61 | |
| 62 | - id: release |
| 63 | name: Prepare release |
| 64 | run: | |
| 65 | set -euo pipefail |
| 66 | node scripts/release/prepare.ts '${{ inputs.version }}' | tee -a "$GITHUB_OUTPUT" |
| 67 | |
| 68 | - name: Build release packages |
| 69 | run: pnpm build:pkg |
| 70 | |
| 71 | - name: Pack release artifacts |
| 72 | run: | |
| 73 | set -euo pipefail |
| 74 | mkdir release-packages |
| 75 | while IFS= read -r dir; do |
| 76 | pnpm --dir "$dir" pack --pack-destination "$GITHUB_WORKSPACE/release-packages" |
| 77 | done < <(jq -r '.[].dir' release-packages.json) |
| 78 | |
| 79 | - id: commit |
| 80 | name: Commit and tag |
| 81 | env: |
| 82 | VERSION: ${{ steps.release.outputs.version }} |
| 83 | CHANNEL: ${{ steps.release.outputs.channel }} |
| 84 | GITHUB_TOKEN: ${{ github.token }} |
| 85 | run: bash scripts/release/commit.sh |
| 86 | |
| 87 | - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 88 | with: |
| 89 | name: release-packages |
| 90 | path: release-packages/*.tgz |
| 91 | if-no-files-found: error |
| 92 | retention-days: 7 |
| 93 | |
| 94 | publish: |
| 95 | name: Publish |
| 96 | needs: build |
| 97 | runs-on: ubuntu-latest |
| 98 | steps: |
| 99 | - name: Checkout repository |
| 100 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 101 | with: |
| 102 | ref: ${{ needs.build.outputs.sha }} |
| 103 | fetch-depth: 0 |
| 104 | |
| 105 | - name: Checkout distilled |
| 106 | run: git submodule update --init --depth=1 --checkout -- submodules/distilled |
| 107 | |
| 108 | - name: Setup pnpm, Node.js, Bun |
| 109 | uses: pnpm/setup@703c52620218391530e48b9e8870d5c0082e1b9b # v2.1.0 |
| 110 | with: |
| 111 | cache: true |
| 112 | install: false |
| 113 | |
| 114 | # Release scripts import changelogen, but publishing does not need |
| 115 | # package lifecycle scripts. |
| 116 | - name: Install dependencies |
| 117 | run: pnpm install --frozen-lockfile --ignore-scripts |
| 118 | |
| 119 | - name: Remove token-based npm authentication |
| 120 | run: sed -i '/always-auth/d' ~/.npmrc 2>/dev/null || true |
| 121 | |
| 122 | - name: Download release artifacts |
| 123 | uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 124 | with: |
| 125 | name: release-packages |
| 126 | path: release-packages |
| 127 | |
| 128 | - name: Publish tarballs with OIDC |
| 129 | run: node scripts/release/publish.ts |
| 130 | |
| 131 | - name: Create GitHub release |
| 132 | if: needs.build.outputs.channel != 'tag' |
| 133 | env: |
| 134 | GITHUB_TOKEN: ${{ github.token }} |
| 135 | VERSION: ${{ needs.build.outputs.version }} |
| 136 | CHANNEL: ${{ needs.build.outputs.channel }} |
| 137 | run: node scripts/release/github-release.ts "v${VERSION}" "$CHANNEL" |
| 138 | |
| 139 | - name: Notify Discord |
| 140 | if: needs.build.outputs.channel != 'tag' |
| 141 | env: |
| 142 | DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }} |
| 143 | VERSION: ${{ needs.build.outputs.version }} |
| 144 | CHANNEL: ${{ needs.build.outputs.channel }} |
| 145 | run: node scripts/release/discord-notify.ts "v${VERSION}" "$CHANNEL" |