From 0f7084f63a1d7c17947d74bb61dbd2c97334cd34 Mon Sep 17 00:00:00 2001 From: Michael Livshits Date: Mon, 23 Nov 2026 23:06:32 +0200 Subject: [PATCH 1/3] feat: each package beside codemode is released by a tag of its own (SHFT-2964) --- .github/workflows/release-package.yml | 84 +++++++++++++++++++++++++++ README.md | 9 +++ 2 files changed, 93 insertions(+) create mode 100644 .github/workflows/release-package.yml diff --git a/.github/workflows/release-package.yml b/.github/workflows/release-package.yml new file mode 100644 index 00000000..c31ac5e0 --- /dev/null +++ b/.github/workflows/release-package.yml @@ -0,0 +1,84 @@ +name: Release package + +# A package published beside codemode has a version of its own and is +# released by a tag of its own: `codemode-bash@1.2.0` publishes +# packages/codemode-bash at version 1.2.0. Codemode itself is released by a +# `v*` tag, in release.yml. +on: + push: + tags: + - "codemode-*@*" + +permissions: + contents: write + +concurrency: + # Serialize package releases so two tags can't race on the same npm package. + group: release-package + cancel-in-progress: false + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + - uses: actions/setup-node@v6 + with: + node-version: 22 + registry-url: https://registry.npmjs.org + - name: Tag matches a package that can be installed + id: package + env: + TAG: ${{ github.ref_name }} + run: | + PACKAGE="${TAG%@*}" + VERSION="${TAG##*@}" + MANIFEST="packages/$PACKAGE/package.json" + if ! echo "$PACKAGE" | grep -qE '^codemode-[a-z0-9-]+$' || [ ! -f "$MANIFEST" ]; then + echo "::error::tag $TAG names no package under packages/" + exit 1 + fi + field() { node -p "require('./$MANIFEST')$1 ?? ''"; } + if [ "$(field .private)" = "true" ]; then + echo "::error::$PACKAGE is private and is not published" + exit 1 + fi + if [ "$(field .name)" != "@shiftlabs/$PACKAGE" ]; then + echo "::error::$MANIFEST is named $(field .name), not @shiftlabs/$PACKAGE" + exit 1 + fi + if [ "$(field .version)" != "$VERSION" ]; then + echo "::error::$MANIFEST is at version $(field .version), not the tag's $VERSION" + exit 1 + fi + # A package is installable only beside a published codemode its peer range takes. + RANGE="$(field ".peerDependencies?.['@shiftlabs/codemode']")" + if [ -z "$RANGE" ] || ! npm view "@shiftlabs/codemode@$RANGE" version > /dev/null 2>&1; then + echo "::error::no published @shiftlabs/codemode satisfies the peer range '$RANGE' of $PACKAGE; release codemode first" + exit 1 + fi + echo "name=@shiftlabs/$PACKAGE" >> "$GITHUB_OUTPUT" + echo "dir=packages/$PACKAGE" >> "$GITHUB_OUTPUT" + - run: bun install --frozen-lockfile + # A package is tested against the codemode built from the same commit. + - run: bun --filter @shiftlabs/codemode build + - run: bun run --filter '${{ steps.package.outputs.name }}' typecheck + - run: bun run --filter '${{ steps.package.outputs.name }}' test + - name: Publish to npm + working-directory: ${{ steps.package.outputs.dir }} + run: | + if echo "${{ github.ref_name }}" | grep -qE '(rc|alpha|beta)'; then + npm publish --tag next --access public + else + npm publish --access public + fi + env: + NODE_AUTH_TOKEN: ${{ secrets.SHIFTLABS_NPM_TOKEN }} + # Codemode's own release stays the repository's latest. + - uses: softprops/action-gh-release@v3 + with: + generate_release_notes: true + make_latest: false diff --git a/README.md b/README.md index e51ce13d..86fe1f5f 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,15 @@ bun run --filter '@shiftlabs/codemode-*' test bun run check ``` +A release is cut by pushing a tag. Each package published beside codemode has a version of its own and is released on its own: + +| Tag | Publishes | +|---|---| +| `v0.47.0` | `@shiftlabs/codemode` and `runline`, both at that version | +| `codemode-bash@0.2.0` | `@shiftlabs/codemode-bash` at that version, from `packages/codemode-bash` | + +Set the version in the package's `package.json` first; the release stops when it differs from the tag. A package release also stops when no published codemode satisfies the package's peer range, so release codemode before a package that needs it. A version with `rc`, `alpha` or `beta` in it is published under the `next` tag. + ## License MIT From a96e4faafe0219a36ebeaf5be06baaccfd65be93 Mon Sep 17 00:00:00 2001 From: Michael Livshits Date: Mon, 23 Nov 2026 23:09:48 +0200 Subject: [PATCH 2/3] fix: a release is a prerelease by its version, not by letters in the tag (SHFT-2964) --- .github/workflows/release-package.yml | 30 ++++++++++++++------------- .github/workflows/release.yml | 10 ++++----- README.md | 2 +- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/.github/workflows/release-package.yml b/.github/workflows/release-package.yml index c31ac5e0..0cb5ec9b 100644 --- a/.github/workflows/release-package.yml +++ b/.github/workflows/release-package.yml @@ -22,13 +22,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - - uses: oven-sh/setup-bun@v2 - with: - bun-version: latest - - uses: actions/setup-node@v6 - with: - node-version: 22 - registry-url: https://registry.npmjs.org + # Runs before setup-node, whose registry settings send a token with every npm call. - name: Tag matches a package that can be installed id: package env: @@ -56,12 +50,24 @@ jobs: fi # A package is installable only beside a published codemode its peer range takes. RANGE="$(field ".peerDependencies?.['@shiftlabs/codemode']")" - if [ -z "$RANGE" ] || ! npm view "@shiftlabs/codemode@$RANGE" version > /dev/null 2>&1; then + if [ -z "$RANGE" ] || [ -z "$(npm view "@shiftlabs/codemode@$RANGE" version 2> /dev/null || true)" ]; then echo "::error::no published @shiftlabs/codemode satisfies the peer range '$RANGE' of $PACKAGE; release codemode first" exit 1 fi + # A prerelease version stays off the tag npm installs by default. + case "$VERSION" in + *-*) echo "dist-tag=next" >> "$GITHUB_OUTPUT" ;; + *) echo "dist-tag=latest" >> "$GITHUB_OUTPUT" ;; + esac echo "name=@shiftlabs/$PACKAGE" >> "$GITHUB_OUTPUT" echo "dir=packages/$PACKAGE" >> "$GITHUB_OUTPUT" + - uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + - uses: actions/setup-node@v6 + with: + node-version: 22 + registry-url: https://registry.npmjs.org - run: bun install --frozen-lockfile # A package is tested against the codemode built from the same commit. - run: bun --filter @shiftlabs/codemode build @@ -69,13 +75,9 @@ jobs: - run: bun run --filter '${{ steps.package.outputs.name }}' test - name: Publish to npm working-directory: ${{ steps.package.outputs.dir }} - run: | - if echo "${{ github.ref_name }}" | grep -qE '(rc|alpha|beta)'; then - npm publish --tag next --access public - else - npm publish --access public - fi + run: npm publish --tag "$DIST_TAG" --access public env: + DIST_TAG: ${{ steps.package.outputs.dist-tag }} NODE_AUTH_TOKEN: ${{ secrets.SHIFTLABS_NPM_TOKEN }} # Codemode's own release stays the repository's latest. - uses: softprops/action-gh-release@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 251c22e1..d969bb78 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -89,12 +89,12 @@ jobs: exit 1 - name: Publish to npm working-directory: packages/${{ matrix.package }} + # A prerelease version stays off the tag npm installs by default. run: | - if echo "${{ github.ref_name }}" | grep -qE '(rc|alpha|beta)'; then - npm publish --tag next --access public - else - npm publish --access public - fi + case "$GITHUB_REF_NAME" in + *-*) npm publish --tag next --access public ;; + *) npm publish --tag latest --access public ;; + esac env: NODE_AUTH_TOKEN: ${{ secrets[matrix.token] }} diff --git a/README.md b/README.md index 86fe1f5f..83b8ca36 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ A release is cut by pushing a tag. Each package published beside codemode has a | `v0.47.0` | `@shiftlabs/codemode` and `runline`, both at that version | | `codemode-bash@0.2.0` | `@shiftlabs/codemode-bash` at that version, from `packages/codemode-bash` | -Set the version in the package's `package.json` first; the release stops when it differs from the tag. A package release also stops when no published codemode satisfies the package's peer range, so release codemode before a package that needs it. A version with `rc`, `alpha` or `beta` in it is published under the `next` tag. +Set the version in the package's `package.json` first; the release stops when it differs from the tag. A package release also stops when no published codemode satisfies the package's peer range, so release codemode before a package that needs it. A prerelease version, such as `0.47.0-rc.1`, is published under the `next` tag. ## License From afcfa39871a651fb2ac7a8efc68a104d493b3efd Mon Sep 17 00:00:00 2001 From: Michael Livshits Date: Mon, 23 Nov 2026 23:59:47 +0200 Subject: [PATCH 3/3] fix: a release is a tag and a matching version, nothing more (SHFT-2964) --- .github/workflows/release-package.yml | 41 ++++++--------------------- .github/workflows/release.yml | 7 +---- README.md | 2 +- 3 files changed, 11 insertions(+), 39 deletions(-) diff --git a/.github/workflows/release-package.yml b/.github/workflows/release-package.yml index 0cb5ec9b..f8394b24 100644 --- a/.github/workflows/release-package.yml +++ b/.github/workflows/release-package.yml @@ -22,45 +22,23 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - # Runs before setup-node, whose registry settings send a token with every npm call. - - name: Tag matches a package that can be installed + - name: Tag matches the package version id: package env: TAG: ${{ github.ref_name }} run: | PACKAGE="${TAG%@*}" - VERSION="${TAG##*@}" MANIFEST="packages/$PACKAGE/package.json" if ! echo "$PACKAGE" | grep -qE '^codemode-[a-z0-9-]+$' || [ ! -f "$MANIFEST" ]; then echo "::error::tag $TAG names no package under packages/" exit 1 fi - field() { node -p "require('./$MANIFEST')$1 ?? ''"; } - if [ "$(field .private)" = "true" ]; then - echo "::error::$PACKAGE is private and is not published" + VERSION=$(node -p "require('./$MANIFEST').version") + if [ "$VERSION" != "${TAG##*@}" ]; then + echo "::error::$MANIFEST is at version $VERSION, which does not match tag $TAG" exit 1 fi - if [ "$(field .name)" != "@shiftlabs/$PACKAGE" ]; then - echo "::error::$MANIFEST is named $(field .name), not @shiftlabs/$PACKAGE" - exit 1 - fi - if [ "$(field .version)" != "$VERSION" ]; then - echo "::error::$MANIFEST is at version $(field .version), not the tag's $VERSION" - exit 1 - fi - # A package is installable only beside a published codemode its peer range takes. - RANGE="$(field ".peerDependencies?.['@shiftlabs/codemode']")" - if [ -z "$RANGE" ] || [ -z "$(npm view "@shiftlabs/codemode@$RANGE" version 2> /dev/null || true)" ]; then - echo "::error::no published @shiftlabs/codemode satisfies the peer range '$RANGE' of $PACKAGE; release codemode first" - exit 1 - fi - # A prerelease version stays off the tag npm installs by default. - case "$VERSION" in - *-*) echo "dist-tag=next" >> "$GITHUB_OUTPUT" ;; - *) echo "dist-tag=latest" >> "$GITHUB_OUTPUT" ;; - esac - echo "name=@shiftlabs/$PACKAGE" >> "$GITHUB_OUTPUT" - echo "dir=packages/$PACKAGE" >> "$GITHUB_OUTPUT" + echo "name=$PACKAGE" >> "$GITHUB_OUTPUT" - uses: oven-sh/setup-bun@v2 with: bun-version: latest @@ -71,13 +49,12 @@ jobs: - run: bun install --frozen-lockfile # A package is tested against the codemode built from the same commit. - run: bun --filter @shiftlabs/codemode build - - run: bun run --filter '${{ steps.package.outputs.name }}' typecheck - - run: bun run --filter '${{ steps.package.outputs.name }}' test + - run: bun run --filter '@shiftlabs/${{ steps.package.outputs.name }}' typecheck + - run: bun run --filter '@shiftlabs/${{ steps.package.outputs.name }}' test - name: Publish to npm - working-directory: ${{ steps.package.outputs.dir }} - run: npm publish --tag "$DIST_TAG" --access public + working-directory: packages/${{ steps.package.outputs.name }} + run: npm publish --access public env: - DIST_TAG: ${{ steps.package.outputs.dist-tag }} NODE_AUTH_TOKEN: ${{ secrets.SHIFTLABS_NPM_TOKEN }} # Codemode's own release stays the repository's latest. - uses: softprops/action-gh-release@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d969bb78..2d8a4440 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -89,12 +89,7 @@ jobs: exit 1 - name: Publish to npm working-directory: packages/${{ matrix.package }} - # A prerelease version stays off the tag npm installs by default. - run: | - case "$GITHUB_REF_NAME" in - *-*) npm publish --tag next --access public ;; - *) npm publish --tag latest --access public ;; - esac + run: npm publish --access public env: NODE_AUTH_TOKEN: ${{ secrets[matrix.token] }} diff --git a/README.md b/README.md index 83b8ca36..5ce6dc44 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ A release is cut by pushing a tag. Each package published beside codemode has a | `v0.47.0` | `@shiftlabs/codemode` and `runline`, both at that version | | `codemode-bash@0.2.0` | `@shiftlabs/codemode-bash` at that version, from `packages/codemode-bash` | -Set the version in the package's `package.json` first; the release stops when it differs from the tag. A package release also stops when no published codemode satisfies the package's peer range, so release codemode before a package that needs it. A prerelease version, such as `0.47.0-rc.1`, is published under the `next` tag. +Set the version in `package.json` first; the release stops when it differs from the tag. ## License