π€ CLI Canary Release #16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: π€ CLI Canary Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| branch: | |
| description: 'Branch to build canary from (default: current branch)' | |
| required: false | |
| type: string | |
| default: '' | |
| jobs: | |
| canary-release: | |
| name: π€ Canary Release | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [ 22.12.0 ] | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: π₯ Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.inputs.branch || github.ref }} | |
| fetch-depth: 0 | |
| - name: π’ Setup Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9.10.0 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: 'latest' | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install the packages | |
| run: pnpm i | |
| - name: π Build packages | |
| run: pnpm run build | |
| - name: π Setup npm auth | |
| run: | | |
| echo "registry=https://registry.npmjs.org" >> ~/.npmrc | |
| echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc | |
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: π΅οΈ Determine canary version | |
| id: version | |
| run: | | |
| SHA=$(git rev-parse HEAD) | |
| SHORT_SHA=${SHA::7} | |
| BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
| TIMESTAMP=$(date +%Y%m%d%H%M%S) | |
| CANARY_VERSION="canary-${SHORT_SHA}" | |
| echo "CANARY_VERSION=${CANARY_VERSION}" >> $GITHUB_OUTPUT | |
| echo "π¦ Canary version: ${CANARY_VERSION}" | |
| echo "πΏ Branch: ${BRANCH}" | |
| echo "π Commit: ${SHORT_SHA}" | |
| - name: π€ Publish canary packages | |
| run: node ./release.js --prod --tag canary --snapshot ${{ steps.version.outputs.CANARY_VERSION }} | |
| - name: π¦ Publish xyd-js canary | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| # Read the canary version of @xyd-js/cli from its local package.json | |
| # (already versioned by changeset in the previous step) | |
| CANARY_CLI_VERSION=$(node -p "require('./packages/xyd-cli/package.json').version") | |
| echo "π¦ @xyd-js/cli version: ${CANARY_CLI_VERSION}" | |
| cd packages/xyd-js | |
| # Write dependency directly into package.json (avoids npm install resolving full dep tree) | |
| node -e " | |
| const fs = require('fs'); | |
| const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); | |
| pkg.dependencies['@xyd-js/cli'] = '${CANARY_CLI_VERSION}'; | |
| fs.writeFileSync('package.json', JSON.stringify(pkg, null, 4) + '\n'); | |
| " | |
| # Set canary version on xyd-js package | |
| npm version 0.0.0-${{ steps.version.outputs.CANARY_VERSION }} --no-git-tag-version | |
| echo "π¦ Publishing xyd-js@0.0.0-${{ steps.version.outputs.CANARY_VERSION }} with canary tag" | |
| npm publish --tag canary | |
| - name: β Success | |
| run: | | |
| echo "β Canary release published!" | |
| echo "" | |
| echo "Install with:" | |
| echo " bun add -g xyd-js@canary" | |
| echo " npm i -g xyd-js@canary" | |
| echo "" | |
| echo "Version: 0.0.0-${{ steps.version.outputs.CANARY_VERSION }}" |