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 }}"
0 commit comments