refactor: add return url to createSubscription (#80) #13
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 | |
| environment: | |
| name: production | |
| url: https://www.npmjs.com/package/@layr-labs/ecloud-cli | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Ensure tag is on default branch | |
| run: | | |
| TAG="${{ github.ref_name }}" | |
| DEFAULT_BRANCH="${{ github.event.repository.default_branch }}" | |
| git fetch origin "$DEFAULT_BRANCH" | |
| TAG_COMMIT=$(git rev-parse "$TAG") | |
| if ! git merge-base --is-ancestor "$TAG_COMMIT" "origin/$DEFAULT_BRANCH"; then | |
| echo "ERROR: Tag $TAG points to a commit not on $DEFAULT_BRANCH" | |
| echo "Tag commit: $TAG_COMMIT" | |
| exit 1 | |
| fi | |
| - name: Set version from tag | |
| run: | | |
| VERSION="${{ github.ref_name }}" | |
| PACKAGE_VERSION="${VERSION#v}" | |
| 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" | |
| - name: Verify dev tag and get commit | |
| run: | | |
| 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 }}" | |
| git tag -l "*-dev*" | tail -10 | |
| exit 1 | |
| fi | |
| PROD_COMMIT=$(git rev-list -n 1 "${{ github.ref_name }}") | |
| for DEV_TAG in $DEV_TAGS; do | |
| DEV_COMMIT=$(git rev-list -n 1 "$DEV_TAG") | |
| if [ "$DEV_COMMIT" = "$PROD_COMMIT" ]; then | |
| echo "DEV_COMMIT=$DEV_COMMIT" >> $GITHUB_ENV | |
| echo "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" | |
| for DEV_TAG in $DEV_TAGS; do | |
| DEV_COMMIT=$(git rev-list -n 1 "$DEV_TAG") | |
| echo " $DEV_TAG: $DEV_COMMIT" | |
| done | |
| exit 1 | |
| - name: Verify production tag exists | |
| run: | | |
| if ! git rev-parse "${{ env.VERSION }}" >/dev/null 2>&1; then | |
| echo "ERROR: Production tag '${{ env.VERSION }}' does not exist" | |
| exit 1 | |
| fi | |
| PROD_COMMIT=$(git rev-list -n 1 "${{ env.VERSION }}") | |
| if [ "$PROD_COMMIT" != "${{ env.DEV_COMMIT }}" ]; then | |
| echo "ERROR: Production tag and dev tag point to different commits" | |
| echo "Production: $PROD_COMMIT" | |
| echo "Dev: ${{ env.DEV_COMMIT }}" | |
| exit 1 | |
| fi | |
| - 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: | | |
| 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: | | |
| npm pkg set version="${{ env.PACKAGE_VERSION }}" | |
| npm pkg set "dependencies.@layr-labs/ecloud-sdk"="${{ env.PACKAGE_VERSION }}" | |
| 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 "Verified dev testing completed with matching commit from ${{ env.DEV_TAG }}" | |
| echo "Install with: npm install -g @layr-labs/ecloud-cli@latest" |