Cm/vbuild support (#57) #8
Workflow file for this run
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: Release Production | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| - "!v*-dev*" # Exclude all dev tags | |
| permissions: | |
| contents: write | |
| id-token: write | |
| env: | |
| NODE_VERSION: "20.x" | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set version from tag | |
| run: | | |
| VERSION="${{ github.ref_name }}" | |
| # Clean leading v from provided version | |
| PACKAGE_VERSION="${VERSION#v}" | |
| # Extract base semantic version (x.y.z) - strip everything after first hyphen | |
| BASE_VERSION="${VERSION%%-*}" | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV | |
| echo "BASE_VERSION=$BASE_VERSION" >> $GITHUB_ENV | |
| echo "Building production version: $PACKAGE_VERSION" | |
| echo "Will verify dev tag exists for base version: $BASE_VERSION" | |
| - name: Verify dev testing occurred | |
| run: | | |
| echo "Looking for dev tag with base version: ${{ env.BASE_VERSION }}" | |
| # Check if any dev tag exists for this semantic version (e.g., v0.1.0-dev*) | |
| DEV_TAGS=$(git tag -l "${{ env.BASE_VERSION }}-dev*" | head -10) | |
| if [ -z "$DEV_TAGS" ]; then | |
| echo "ERROR: No dev tag found for version ${{ env.BASE_VERSION }}" | |
| echo "" | |
| echo "Available dev tags:" | |
| git tag -l "*-dev*" | head -10 || echo "No dev tags found" | |
| echo "" | |
| echo "Must test in dev first: git tag ${{ env.BASE_VERSION }}-dev" | |
| exit 1 | |
| fi | |
| echo "✅ Found dev tags for ${{ env.BASE_VERSION }}:" | |
| echo "$DEV_TAGS" | |
| # Verify dev and prod tags point to same commit | |
| PROD_COMMIT=$(git rev-list -n 1 "${{ github.ref_name }}") | |
| echo "Production tag ${{ github.ref_name }} points to commit: $PROD_COMMIT" | |
| for DEV_TAG in $DEV_TAGS; do | |
| DEV_COMMIT=$(git rev-list -n 1 "$DEV_TAG") | |
| echo "Dev tag $DEV_TAG points to commit: $DEV_COMMIT" | |
| if [ "$DEV_COMMIT" = "$PROD_COMMIT" ]; then | |
| echo "✅ Dev tag $DEV_TAG verified - same commit as production tag" | |
| echo "VERIFIED_DEV_TAG=$DEV_TAG" >> $GITHUB_ENV | |
| exit 0 | |
| fi | |
| done | |
| echo "ERROR: No dev tag points to the same commit as production tag ${{ github.ref_name }}" | |
| echo "Production commit: $PROD_COMMIT" | |
| echo "Dev tags and their commits:" | |
| for DEV_TAG in $DEV_TAGS; do | |
| DEV_COMMIT=$(git rev-list -n 1 "$DEV_TAG") | |
| echo " $DEV_TAG: $DEV_COMMIT" | |
| done | |
| echo "" | |
| echo "Create a dev tag on the same commit: git tag ${{ env.BASE_VERSION }}-dev $PROD_COMMIT" | |
| exit 1 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| registry-url: "https://registry.npmjs.org" | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| working-directory: . | |
| run: pnpm install --frozen-lockfile | |
| - name: Build SDK (prod) - dependency for CLI | |
| working-directory: ./packages/sdk | |
| env: | |
| BUILD_TYPE: prod | |
| PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }} | |
| POSTHOG_API_KEY_BUILD_TIME: ${{ secrets.POSTHOG_API_KEY }} | |
| run: | | |
| pnpm run build | |
| - name: Build CLI (prod) | |
| working-directory: ./packages/cli | |
| env: | |
| BUILD_TYPE: prod | |
| PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }} | |
| POSTHOG_API_KEY_BUILD_TIME: ${{ secrets.POSTHOG_API_KEY }} | |
| run: | | |
| pnpm run build | |
| - name: Get short sha | |
| run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV | |
| env: | |
| GITHUB_SHA: ${{ github.sha }} | |
| - name: Generate SDK VERSION file | |
| working-directory: ./packages/sdk | |
| env: | |
| PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }} | |
| GITHUB_SHA: ${{ env.SHORT_SHA }} | |
| run: | | |
| node scripts/generate-version.js | |
| - name: Generate CLI VERSION file | |
| working-directory: ./packages/cli | |
| env: | |
| PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }} | |
| GITHUB_SHA: ${{ env.SHORT_SHA }} | |
| run: | | |
| node scripts/generate-version.js | |
| - name: Update SDK package.json for publishing | |
| working-directory: ./packages/sdk | |
| run: | | |
| # Update version (keep default package name) | |
| npm pkg set version="${{ env.PACKAGE_VERSION }}" | |
| - name: Publish SDK to npm (prod) | |
| working-directory: ./packages/sdk | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| npm publish --tag latest --access public | |
| - name: Update CLI package.json for publishing | |
| working-directory: ./packages/cli | |
| run: | | |
| # Update version (keep default package name) | |
| npm pkg set version="${{ env.PACKAGE_VERSION }}" | |
| # Update SDK dependency to match published version | |
| npm pkg set "dependencies.@layr-labs/ecloud-sdk"="${{ env.PACKAGE_VERSION }}" | |
| # Verify changes | |
| cat package.json | grep -A 2 '"name"' | |
| cat package.json | grep -A 1 '"@layr-labs/ecloud-sdk"' | |
| - name: Publish CLI to npm (prod) | |
| working-directory: ./packages/cli | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| npm publish --tag latest --access public | |
| - name: Summary | |
| run: | | |
| echo "🚀 Production release published successfully!" | |
| echo "📦 SDK Package: @layr-labs/ecloud-sdk@${{ env.PACKAGE_VERSION }} (tag: latest)" | |
| echo "📦 CLI Package: @layr-labs/ecloud-cli@${{ env.PACKAGE_VERSION }} (tag: latest)" | |
| echo "🏷️ Tag: latest" | |
| echo "🔒 Verified dev testing completed with matching commit from ${{ env.VERIFIED_DEV_TAG }}" | |
| echo "🔗 Install with: npm install -g @layr-labs/ecloud-cli@latest" |