name: Release on: push: tags: # Glob pattern for semantic versions (matches git-cliff's own workflow) - "v*.*.*" permissions: id-token: write # Required for npm OIDC publishing contents: write # Required for GitHub releases pull-requests: read # Required for git-cliff PR metadata/avatars jobs: build-artifacts: runs-on: ubuntu-latest # OCX 3 publishes previews without changing the frozen V1 latest channel. if: github.repository == 'kdcokenny/ocx' steps: - uses: actions/checkout@v6 - uses: oven-sh/setup-bun@v2 with: bun-version-file: package.json - name: Validate release tag version shell: bash run: | set -euo pipefail package_version="$(node -p "require('./packages/cli/package.json').version")" case "$package_version" in 3.*-*) ;; *) echo "::error::This branch only publishes OCX 3 prereleases; latest remains frozen for V1 users."; exit 1 ;; esac if [ "$GITHUB_REF_NAME" != "v${package_version}" ]; then echo "::error::Tag ${GITHUB_REF_NAME} does not match packages/cli/package.json version ${package_version}." exit 1 fi - name: Install dependencies run: bun install --frozen-lockfile - name: Validate run: bun run check && bun run test - name: Build CLI run: bun run build working-directory: packages/cli - name: Build binaries run: bun run build:binary:all working-directory: packages/cli - name: Upload binary artifacts uses: actions/upload-artifact@v6 with: name: ocx-binaries path: packages/cli/dist/bin/ocx-* if-no-files-found: error smoke-windows-artifacts: runs-on: windows-latest needs: build-artifacts permissions: contents: read actions: read steps: - uses: actions/checkout@v6 - uses: oven-sh/setup-bun@v2 with: bun-version-file: package.json - name: Install dependencies run: bun install --frozen-lockfile - name: Download binary artifacts uses: actions/download-artifact@v6 with: name: ocx-binaries path: packages/cli/dist/bin - name: Run release Windows binary smoke tests run: bun run test:binary-smoke working-directory: packages/cli env: OCX_BINARY_SMOKE_TARGETS: ${{ github.workspace }}\packages\cli\dist\bin\ocx-windows-x64.exe;${{ github.workspace }}\packages\cli\dist\bin\ocx-windows-x64-baseline.exe release: runs-on: ubuntu-latest needs: smoke-windows-artifacts permissions: id-token: write # Required for npm OIDC publishing contents: write # Required for GitHub releases pull-requests: read # Required for git-cliff PR metadata/avatars actions: read # Required to download smoke-tested artifacts steps: - uses: actions/checkout@v6 with: fetch-depth: 0 # Required for git-cliff to access full history - name: Generate changelog id: changelog uses: orhun/git-cliff-action@v4 with: config: cliff.toml args: --latest --strip all env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Node 24+ ships with npm 11.5.1+ which supports tokenless OIDC publishing - uses: actions/setup-node@v6 with: node-version: "24" registry-url: "https://registry.npmjs.org" - uses: oven-sh/setup-bun@v2 with: bun-version-file: package.json - name: Install dependencies run: bun install --frozen-lockfile - name: Validate run: bun run check && bun run test - name: Build CLI run: bun run build working-directory: packages/cli - name: Download smoke-tested binary artifacts uses: actions/download-artifact@v6 with: name: ocx-binaries path: packages/cli/dist/bin - name: Generate checksums run: | cd packages/cli/dist/bin # Generate individual .sha256 files for file in ocx-*; do if [ -f "$file" ]; then sha256sum "$file" > "$file.sha256" fi done # Generate consolidated SHA256SUMS.txt sha256sum ocx-* | grep -v '\.sha256' > SHA256SUMS.txt - name: Revalidate release source shell: bash env: DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} run: | set -euo pipefail package_version="$(node -p "require('./packages/cli/package.json').version")" lock_version="$( cd packages/cli bun -e 'import { parse } from "jsonc-parser"; const lock = parse(await Bun.file("../../bun.lock").text()); process.stdout.write(lock.workspaces["packages/cli"].version)' )" if [ "$GITHUB_REF_NAME" != "v${package_version}" ]; then echo "::error::Tag ${GITHUB_REF_NAME} does not match packages/cli/package.json version ${package_version}." exit 1 fi if [ "$lock_version" != "$package_version" ]; then echo "::error::bun.lock CLI version ${lock_version} does not match packages/cli/package.json version ${package_version}." exit 1 fi git fetch --no-tags origin "+refs/heads/${DEFAULT_BRANCH}:refs/remotes/origin/${DEFAULT_BRANCH}" if ! git merge-base --is-ancestor "$GITHUB_SHA" "refs/remotes/origin/${DEFAULT_BRANCH}"; then echo "::error::Tag commit ${GITHUB_SHA} is not on origin/${DEFAULT_BRANCH}." exit 1 fi remote_version="$( git show "refs/remotes/origin/${DEFAULT_BRANCH}:packages/cli/package.json" | node -p 'JSON.parse(require("fs").readFileSync(0, "utf8")).version' )" if [ "$remote_version" != "$package_version" ]; then echo "::error::origin/${DEFAULT_BRANCH} package version ${remote_version} does not match release version ${package_version}." exit 1 fi - name: Release uses: softprops/action-gh-release@v2 with: prerelease: true make_latest: false files: | packages/cli/dist/bin/ocx-* packages/cli/dist/bin/SHA256SUMS.txt body: | ## Installation **Via curl (macOS/Linux):** ```bash curl -fsSL https://ocx.kdco.dev/install.sh | OCX_VERSION=${{ github.ref_name }} bash ``` **Via npm (all platforms including Windows):** ```bash npm install -g ocx@next ``` **Manual download:** Download the appropriate binary for your platform from the assets below. ## Checksums SHA256 checksums are provided for each binary. Verify with: ```bash sha256sum -c SHA256SUMS.txt ``` --- ${{ steps.changelog.outputs.content }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Tokenless npm publish using OIDC # Requires trusted publisher configured at npmjs.com/package/ocx/access - name: Publish ocx to npm run: npm publish --provenance --access public --tag next working-directory: packages/cli