Release #67
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 | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version (e.g., 2.23.0 or 2.23.0-beta.1)' | |
| required: true | |
| type: string | |
| prerelease: | |
| description: 'Is this a prerelease?' | |
| required: true | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: write | |
| id-token: write # Required for npm trusted publishing with OIDC | |
| jobs: | |
| build-binaries: | |
| name: Build ${{ matrix.platform }} binary | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: linux | |
| os: ubuntu-latest | |
| target: linux-x64-gnu | |
| - platform: alpine | |
| os: ubuntu-latest | |
| target: linux-x64-musl | |
| - platform: macos | |
| os: ubuntu-latest | |
| target: darwin-x64 | |
| - platform: macos-arm | |
| os: ubuntu-latest | |
| target: darwin-arm64 | |
| - platform: win | |
| os: windows-latest | |
| target: win32-x64 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Cache dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.bun/install/cache | |
| node_modules | |
| key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }} | |
| restore-keys: | | |
| ${{ runner.os }}-bun- | |
| - name: Clean node_modules on Windows (workaround for nested path issues) | |
| if: matrix.platform == 'win' | |
| run: | | |
| if (Test-Path node_modules) { Remove-Item -Recurse -Force node_modules } | |
| shell: pwsh | |
| - name: Install dependencies | |
| run: bun install | |
| - name: Generate schemas | |
| if: ${{ inputs.prerelease == false }} | |
| run: bun run gen:schema | |
| - name: Build binary for ${{ matrix.platform }} | |
| if: matrix.platform != 'alpine' | |
| run: bun run scripts/build-dist-package.ts --platform ${{ matrix.platform }} --version ${{ inputs.version }} | |
| - name: Build Alpine binary (in Docker) | |
| if: matrix.platform == 'alpine' | |
| run: | | |
| docker run --rm -v $(pwd):/workspace -w /workspace node:22-alpine sh -c " | |
| apk add --no-cache curl bash git | |
| curl -fsSL https://bun.sh/install | bash | |
| export PATH=\$HOME/.bun/bin:\$PATH | |
| bun install | |
| bun run scripts/build-dist-package.ts --platform alpine --version ${{ inputs.version }} | |
| " | |
| - name: Upload binary artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: binary-${{ matrix.platform }} | |
| path: | | |
| __dist/*.tar.gz | |
| __dist/*.zip | |
| retention-days: 1 | |
| release: | |
| name: Create Release and Publish | |
| needs: build-binaries | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # Required for creating releases and pushing commits | |
| id-token: write # Required for npm OIDC authentication | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Cache dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.bun/install/cache | |
| node_modules | |
| key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }} | |
| restore-keys: | | |
| ${{ runner.os }}-bun- | |
| - name: Install dependencies | |
| run: bun install | |
| - name: Download all binary artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: __dist-package-platform | |
| - name: Organize artifacts | |
| run: | | |
| mkdir -p __dist | |
| find __dist-package-platform -type f -exec mv {} __dist/ \; | |
| - name: Install Stacktape CLI | |
| run: | | |
| curl -L https://installs.stacktape.com/linux.sh | sh | |
| echo "$HOME/.stacktape/bin" >> $GITHUB_PATH | |
| - name: Generate starter projects metadata | |
| if: ${{ inputs.prerelease == false }} | |
| run: bun run gen:sp:metadata | |
| - name: Generate schemas | |
| if: ${{ inputs.prerelease == false }} | |
| run: bun run gen:schema | |
| - name: Build npm package | |
| run: bun run build:npm --version ${{ inputs.version }} | |
| - name: Setup Node.js for npm publish | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Update npm to latest | |
| run: npm install -g npm@latest | |
| - name: Create GitHub Release | |
| id: create_release | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| run: | | |
| bun run scripts/github-actions/create-github-release.ts \ | |
| --version ${{ inputs.version }} \ | |
| --prerelease ${{ inputs.prerelease }} | |
| - name: Publish to npm using OIDC | |
| run: | | |
| TAG_ARG="" | |
| if [ "${{ inputs.prerelease }}" = "true" ]; then | |
| PRERELEASE_TAG=$(echo "${{ inputs.version }}" | grep -oP '(alpha|beta|rc)' || echo "") | |
| if [ -n "$PRERELEASE_TAG" ]; then | |
| TAG_ARG="--tag $PRERELEASE_TAG" | |
| fi | |
| fi | |
| cd __release-npm | |
| npm publish --provenance --access public $TAG_ARG | |
| - name: Publish install scripts | |
| env: | |
| STACKTAPE_API_KEY: ${{ secrets.STACKTAPE_API_KEY }} | |
| run: | | |
| BUCKET_TYPE="production" | |
| if [ "${{ inputs.prerelease }}" = "true" ]; then | |
| BUCKET_TYPE="preview" | |
| fi | |
| bun run scripts/publish-install-scripts.ts --version ${{ inputs.version }} --bucket-type $BUCKET_TYPE | |
| - name: Publish schemas | |
| if: ${{ inputs.prerelease == false }} | |
| env: | |
| STACKTAPE_API_KEY: ${{ secrets.STACKTAPE_API_KEY }} | |
| run: bun run publish:schemas | |
| - name: Publish AI docs | |
| env: | |
| STACKTAPE_API_KEY: ${{ secrets.STACKTAPE_API_KEY }} | |
| run: bun run publish:ai:docs | |
| - name: Update package.json versions | |
| run: | | |
| bun run scripts/github-actions/update-versions.ts --version ${{ inputs.version }} | |
| - name: Commit version bump | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add package.json src/api/npm/package.json | |
| git commit -m "release: v${{ inputs.version }}" | |
| git push |