Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/release-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
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
- name: Tag matches the package version
id: package
env:
TAG: ${{ github.ref_name }}
run: |
PACKAGE="${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
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
echo "name=$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
- 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: packages/${{ steps.package.outputs.name }}
run: npm publish --access public
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
7 changes: 1 addition & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,7 @@ jobs:
exit 1
- name: Publish to npm
working-directory: packages/${{ matrix.package }}
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 --access public
env:
NODE_AUTH_TOKEN: ${{ secrets[matrix.token] }}

Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `package.json` first; the release stops when it differs from the tag.

## License

MIT