name: Release
on:
workflow_dispatch:
inputs:
version:
description: >-
Release spec, bumped from the version every package.json shares.
`beta` (the default) publishes the next beta, e.g. `2.0.0-beta.81`
to `2.0.0-beta.82`; `beta.N` publishes that candidate. `rc[.N]` and
`alpha[.N]` select those prerelease channels. `patch|minor|major`
bump per semver, and `x.y.z[-beta.N]` publishes exactly that
version. Anything else publishes `0.0.0-<name>` without committing
it.
required: false
type: string
default: "beta"
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: write
id-token: write
env:
ALCHEMY_REPO: alchemy-run/alchemy
jobs:
build:
name: Build and pack
runs-on: blacksmith-8vcpu-ubuntu-2404
outputs:
sha: ${{ steps.commit.outputs.sha }}
version: ${{ steps.release.outputs.version }}
channel: ${{ steps.release.outputs.channel }}
steps:
- name: Generate bot token
id: bot-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
app-id: ${{ secrets.ALCHEMY_VERSION_BOT_ID }}
private-key: ${{ secrets.ALCHEMY_VERSION_BOT_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
token: ${{ steps.bot-token.outputs.token }}
- name: Checkout distilled
run: git submodule update --init --depth=1 --checkout -- submodules/distilled
- name: Setup pnpm, Node.js, Bun and install dependencies
uses: pnpm/setup@703c52620218391530e48b9e8870d5c0082e1b9b # v2.1.0
with:
cache: true
install: true
require-lockfile: true
- id: release
name: Prepare release
run: |
set -euo pipefail
node scripts/release/prepare.ts '${{ inputs.version }}' | tee -a "$GITHUB_OUTPUT"
- name: Build release packages
run: pnpm build:pkg
- name: Pack release artifacts
run: |
set -euo pipefail
mkdir release-packages
while IFS= read -r dir; do
pnpm --dir "$dir" pack --pack-destination "$GITHUB_WORKSPACE/release-packages"
done < <(jq -r '.[].dir' release-packages.json)
- id: commit
name: Commit and tag
env:
VERSION: ${{ steps.release.outputs.version }}
CHANNEL: ${{ steps.release.outputs.channel }}
GITHUB_TOKEN: ${{ github.token }}
run: bash scripts/release/commit.sh
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: release-packages
path: release-packages/*.tgz
if-no-files-found: error
retention-days: 7
publish:
name: Publish
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.build.outputs.sha }}
fetch-depth: 0
- name: Checkout distilled
run: git submodule update --init --depth=1 --checkout -- submodules/distilled
- name: Setup pnpm, Node.js, Bun
uses: pnpm/setup@703c52620218391530e48b9e8870d5c0082e1b9b # v2.1.0
with:
cache: true
install: false
# Release scripts import changelogen, but publishing does not need
# package lifecycle scripts.
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Remove token-based npm authentication
run: sed -i '/always-auth/d' ~/.npmrc 2>/dev/null || true
- name: Download release artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: release-packages
path: release-packages
- name: Publish tarballs with OIDC
run: node scripts/release/publish.ts
- name: Create GitHub release
if: needs.build.outputs.channel != 'tag'
env:
GITHUB_TOKEN: ${{ github.token }}
VERSION: ${{ needs.build.outputs.version }}
CHANNEL: ${{ needs.build.outputs.channel }}
run: node scripts/release/github-release.ts "v${VERSION}" "$CHANNEL"
- name: Notify Discord
if: needs.build.outputs.channel != 'tag'
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
VERSION: ${{ needs.build.outputs.version }}
CHANNEL: ${{ needs.build.outputs.channel }}
run: node scripts/release/discord-notify.ts "v${VERSION}" "$CHANNEL"