Skip to content

Commit 334c7fa

Browse files
authored
Merge pull request #108 from livesession/feat/canary-release
feat(canary-release): build scripts for xyd-js@canary
2 parents 23166ce + 43618b9 commit 334c7fa

2 files changed

Lines changed: 173 additions & 0 deletions

File tree

.github/workflows/cli-canary.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: 🐤 CLI Canary Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
branch:
7+
description: 'Branch to build canary from (default: current branch)'
8+
required: false
9+
type: string
10+
default: ''
11+
12+
jobs:
13+
canary-release:
14+
name: 🐤 Canary Release
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
node-version: [ 22.12.0 ]
19+
permissions:
20+
contents: read
21+
id-token: write
22+
steps:
23+
- name: 📥 Checkout code
24+
uses: actions/checkout@v4
25+
with:
26+
ref: ${{ github.event.inputs.branch || github.ref }}
27+
fetch-depth: 0
28+
29+
- name: 🟢 Setup Node.js ${{ matrix.node-version }}
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: ${{ matrix.node-version }}
33+
34+
- name: Setup pnpm
35+
uses: pnpm/action-setup@v4
36+
with:
37+
version: 9.10.0
38+
39+
- name: Setup Bun
40+
uses: oven-sh/setup-bun@v2
41+
with:
42+
bun-version: 'latest'
43+
44+
- name: Get pnpm store directory
45+
shell: bash
46+
run: |
47+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
48+
49+
- name: Setup pnpm cache
50+
uses: actions/cache@v4
51+
with:
52+
path: ${{ env.STORE_PATH }}
53+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
54+
restore-keys: |
55+
${{ runner.os }}-pnpm-store-
56+
57+
- name: Install the packages
58+
run: pnpm i
59+
60+
- name: 🏗 Build packages
61+
run: pnpm run build
62+
63+
- name: 🔐 Setup npm auth
64+
run: |
65+
echo "registry=https://registry.npmjs.org" >> ~/.npmrc
66+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
67+
env:
68+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
69+
70+
- name: 🕵️ Determine canary version
71+
id: version
72+
run: |
73+
SHA=$(git rev-parse HEAD)
74+
SHORT_SHA=${SHA::7}
75+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
76+
TIMESTAMP=$(date +%Y%m%d%H%M%S)
77+
CANARY_VERSION="canary-${SHORT_SHA}"
78+
echo "CANARY_VERSION=${CANARY_VERSION}" >> $GITHUB_OUTPUT
79+
echo "📦 Canary version: ${CANARY_VERSION}"
80+
echo "🌿 Branch: ${BRANCH}"
81+
echo "🔑 Commit: ${SHORT_SHA}"
82+
83+
- name: 🐤 Publish canary packages
84+
run: node ./release.js --prod --snapshot ${{ steps.version.outputs.CANARY_VERSION }}
85+
86+
- name: 📦 Publish xyd-js canary
87+
run: |
88+
cd packages/xyd-js
89+
90+
# Find the canary version of @xyd-js/cli that was just published
91+
CANARY_CLI_VERSION=$(npm view @xyd-js/cli versions --json | node -e "
92+
const versions = JSON.parse(require('fs').readFileSync('/dev/stdin', 'utf8'));
93+
const canary = versions.filter(v => v.includes('${{ steps.version.outputs.CANARY_VERSION }}'));
94+
console.log(canary[canary.length - 1]);
95+
")
96+
97+
echo "📦 Installing @xyd-js/cli@${CANARY_CLI_VERSION}"
98+
npm install @xyd-js/cli@${CANARY_CLI_VERSION} --save-exact
99+
100+
# Set canary version on xyd-js package
101+
npm version 0.0.0-${{ steps.version.outputs.CANARY_VERSION }} --no-git-tag-version
102+
103+
echo "📦 Publishing xyd-js@0.0.0-${{ steps.version.outputs.CANARY_VERSION }} with canary tag"
104+
npm publish --tag canary
105+
106+
- name: ✅ Success
107+
run: |
108+
echo "✅ Canary release published!"
109+
echo ""
110+
echo "Install with:"
111+
echo " bun add -g xyd-js@canary"
112+
echo " npm i -g xyd-js@canary"
113+
echo ""
114+
echo "Version: 0.0.0-${{ steps.version.outputs.CANARY_VERSION }}"

scripts/canary.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Publish a canary release of xyd-js from local machine
5+
# Usage: ./scripts/canary.sh
6+
#
7+
# Prerequisites:
8+
# - npm auth configured (npm login or NPM_TOKEN env var)
9+
# - packages built (pnpm run build)
10+
#
11+
# Install the canary release with:
12+
# bun add -g xyd-js@canary
13+
14+
SHA=$(git rev-parse HEAD)
15+
SHORT_SHA=${SHA::7}
16+
CANARY_VERSION="canary-${SHORT_SHA}"
17+
18+
echo "🐤 Publishing canary release..."
19+
echo " Commit: ${SHORT_SHA}"
20+
echo " Version: 0.0.0-${CANARY_VERSION}"
21+
echo ""
22+
23+
# Step 1: Build packages
24+
echo "🏗 Building packages..."
25+
pnpm run build
26+
27+
# Step 2: Publish all @xyd-js/* packages with canary snapshot
28+
echo "📦 Publishing @xyd-js/* packages..."
29+
node ./release.js --prod --snapshot "${CANARY_VERSION}"
30+
31+
# Step 3: Find the published canary version of @xyd-js/cli
32+
echo "🔍 Finding published @xyd-js/cli canary version..."
33+
CANARY_CLI_VERSION=$(npm view @xyd-js/cli versions --json | node -e "
34+
const versions = JSON.parse(require('fs').readFileSync('/dev/stdin', 'utf8'));
35+
const canary = versions.filter(v => v.includes('${CANARY_VERSION}'));
36+
console.log(canary[canary.length - 1]);
37+
")
38+
39+
echo " Found: @xyd-js/cli@${CANARY_CLI_VERSION}"
40+
41+
# Step 4: Update xyd-js package and publish with canary tag
42+
echo "📦 Publishing xyd-js canary..."
43+
cd packages/xyd-js
44+
npm install "@xyd-js/cli@${CANARY_CLI_VERSION}" --save-exact
45+
npm version "0.0.0-${CANARY_VERSION}" --no-git-tag-version
46+
npm publish --tag canary
47+
cd ../..
48+
49+
# Step 5: Restore xyd-js package.json
50+
echo "🔄 Restoring packages/xyd-js/package.json..."
51+
git checkout packages/xyd-js/package.json packages/xyd-js/package-lock.json 2>/dev/null || true
52+
53+
echo ""
54+
echo "✅ Canary release published!"
55+
echo ""
56+
echo "Install with:"
57+
echo " bun add -g xyd-js@canary"
58+
echo " npm i -g xyd-js@canary"
59+
echo " pnpm add -g xyd-js@canary"

0 commit comments

Comments
 (0)