Publish CRE SDK #40
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: Publish CRE SDK | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Git tag to checkout and publish from (leave empty for latest commit on main)" | |
| required: false | |
| type: string | |
| dry_run: | |
| description: "Run in dry-run mode (do not actually publish)" | |
| required: false | |
| default: false | |
| type: boolean | |
| env: | |
| BUN_VERSION: "1.2.21" | |
| jobs: | |
| build-and-publish-cre-sdk: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write # for npm provenance | |
| environment: Publish | |
| defaults: | |
| run: | |
| shell: /usr/bin/zsh {0} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.inputs.tag || 'main' }} | |
| fetch-depth: 0 | |
| submodules: recursive | |
| # Install zsh with bash explicitly, so this step never fails | |
| - name: Ensure zsh is installed | |
| shell: bash | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y zsh | |
| - name: Verify zsh | |
| run: | | |
| echo "zsh path: $(which zsh)" | |
| echo "zsh version: $(zsh --version)" | |
| - name: Display checkout info | |
| run: | | |
| echo "Checked out ref: ${{ github.event.inputs.tag || 'main' }}" | |
| echo "Current commit: $(git rev-parse HEAD)" | |
| echo "Current commit short: $(git rev-parse --short HEAD)" | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2 | |
| with: | |
| bun-version: ${{ env.BUN_VERSION }} | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Setup Node.js for npm publish | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "24" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Update npm | |
| run: npm install -g npm@latest | |
| - name: Get package version | |
| working-directory: packages/cre-sdk | |
| run: | | |
| CURRENT_VERSION=$(node -p "require('./package.json').version") | |
| echo "CRE_SDK_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV | |
| echo "Using CRE SDK version from package.json: $CURRENT_VERSION" | |
| # Detect pre-release tag from version (e.g. 1.1.3-alpha.1 → alpha) | |
| if [[ "$CURRENT_VERSION" =~ -([a-zA-Z]+) ]]; then | |
| NPM_TAG="${match[1]}" | |
| else | |
| NPM_TAG="latest" | |
| fi | |
| echo "NPM_DIST_TAG=$NPM_TAG" >> $GITHUB_ENV | |
| echo "npm dist-tag: $NPM_TAG" | |
| - name: Build cre-sdk | |
| working-directory: packages/cre-sdk | |
| run: bun run build | |
| - name: Setup CRE environment | |
| working-directory: packages/cre-sdk | |
| run: | | |
| echo "Setting up CRE environment with javy plugin..." | |
| bun --bun ../cre-sdk-javy-plugin/bin/setup.ts | |
| - name: Publish cre-sdk package | |
| working-directory: packages/cre-sdk | |
| run: | | |
| echo "Publishing @chainlink/cre-sdk with dist-tag: $NPM_DIST_TAG..." | |
| if [ "${{ github.event.inputs.dry_run }}" = "true" ]; then | |
| echo "DRY RUN: Would publish @chainlink/cre-sdk" | |
| npm publish --dry-run --access public --tag "$NPM_DIST_TAG" --verbose | |
| else | |
| npm publish --access public --tag "$NPM_DIST_TAG" --verbose | |
| fi | |
| - name: Create release summary | |
| if: ${{ github.event.inputs.dry_run != 'true' }} | |
| run: | | |
| echo "## 📦 Published CRE SDK Package" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "- 📋 \`@chainlink/cre-sdk@$CRE_SDK_VERSION\`" >> $GITHUB_STEP_SUMMARY | |
| echo "- 🏷️ npm dist-tag: \`$NPM_DIST_TAG\`" >> $GITHUB_STEP_SUMMARY | |
| echo "- 📋 Published from: \`${{ github.event.inputs.tag || 'main' }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "- 🔗 Commit: \`$(git rev-parse --short HEAD)\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Installation" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY | |
| if [ "$NPM_DIST_TAG" = "latest" ]; then | |
| echo "bun add @chainlink/cre-sdk" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "bun add @chainlink/cre-sdk@$NPM_DIST_TAG" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### CLI Commands" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY | |
| echo "# Compile workflow" >> $GITHUB_STEP_SUMMARY | |
| echo "bun x cre-compile" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
| verify-cre-sdk: | |
| needs: build-and-publish-cre-sdk | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event.inputs.dry_run != 'true' }} | |
| steps: | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2 | |
| with: | |
| bun-version: ${{ env.BUN_VERSION }} | |
| - name: Wait for package propagation | |
| run: sleep 60 | |
| - name: Verify cre-sdk package installation | |
| run: | | |
| echo "Verifying @chainlink/cre-sdk@$CRE_SDK_VERSION can be installed..." | |
| bun add @chainlink/cre-sdk@$CRE_SDK_VERSION --dry-run | |
| echo "✅ CRE SDK package verification successful" | |
| - name: Verify CLI binary is available | |
| run: | | |
| echo "Installing package to test CLI binary..." | |
| bun add @chainlink/cre-sdk@$CRE_SDK_VERSION | |
| echo "Checking cre-compile command via bunx..." | |
| if bun x cre-compile --help >/dev/null 2>&1; then | |
| echo "✅ cre-compile command is available via bunx" | |
| else | |
| echo "❌ cre-compile command not found via bunx" | |
| exit 1 | |
| fi |