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
77 changes: 0 additions & 77 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ jobs:
release:
name: Create release for new version
runs-on: ubuntu-latest
outputs:
released: ${{ steps.check.outputs.released }}
tag: ${{ steps.check.outputs.tag }}
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
Expand Down Expand Up @@ -48,77 +45,3 @@ jobs:
gh release create "$TAG" --title "$TAG" --notes "$NOTES"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish:
name: Publish package
runs-on: ubuntu-latest
needs: release
if: needs.release.outputs.released == 'true'
concurrency:
group: npm-publish-${{ needs.release.outputs.tag }}
cancel-in-progress: false
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
with:
ref: ${{ needs.release.outputs.tag }}
persist-credentials: false

- name: Setup Node.js
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
with:
node-version: 24
registry-url: https://registry.npmjs.org
package-manager-cache: false

- name: Install dependencies
shell: bash
run: |
if [ -f package-lock.json ]; then
npm ci
elif node -e "const p=require('./package.json'); process.exit(p.dependencies || p.devDependencies ? 0 : 1)"; then
npm install
else
echo "No dependencies to install."
fi

- name: Validate package
shell: bash
run: |
if node -e "process.exit(require('./package.json').scripts?.check ? 0 : 1)"; then
npm run check
elif node -e "process.exit(require('./package.json').scripts?.test ? 0 : 1)"; then
npm test
elif node -e "process.exit(require('./package.json').scripts?.typecheck ? 0 : 1)"; then
npm run typecheck
else
echo "No validation script configured."
fi

- name: Skip already published version
id: published
shell: bash
run: |
name=$(node -p "require('./package.json').name")
version=$(node -p "require('./package.json').version")
set +e
output=$(npm view "${name}@${version}" version 2>&1)
status=$?
set -e
if [ "$status" -eq 0 ]; then
echo "${name}@${version} is already published."
echo "skip=true" >> "$GITHUB_OUTPUT"
elif printf '%s' "$output" | grep -Eq 'E404|404 Not Found'; then
echo "Publishing ${name}@${version}."
echo "skip=false" >> "$GITHUB_OUTPUT"
else
printf '%s\n' "$output" >&2
exit "$status"
fi

- name: Publish to npm
if: steps.published.outputs.skip != 'true'
run: npm publish --access public
16 changes: 12 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
with:
ref: ${{ github.event.inputs.ref || github.ref }}
persist-credentials: false

- name: Setup Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e
with:
node-version: 24
registry-url: https://registry.npmjs.org
Expand Down Expand Up @@ -69,12 +70,19 @@ jobs:
run: |
name=$(node -p "require('./package.json').name")
version=$(node -p "require('./package.json').version")
if npm view "${name}@${version}" version >/dev/null 2>&1; then
set +e
output=$(npm view "${name}@${version}" version 2>&1)
status=$?
set -e
if [ "$status" -eq 0 ]; then
echo "${name}@${version} is already published."
echo "skip=true" >> "$GITHUB_OUTPUT"
else
elif printf '%s' "$output" | grep -Eq 'E404|404 Not Found'; then
echo "Publishing ${name}@${version}."
echo "skip=false" >> "$GITHUB_OUTPUT"
else
printf '%s\n' "$output" >&2
exit "$status"
fi

- name: Publish to npm
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pi install -l npm:pi-weighted-model-router
To pin a specific version:

```bash
pi install npm:pi-weighted-model-router@0.2.1
pi install npm:pi-weighted-model-router@0.2.2
```

From a local checkout:
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pi-weighted-model-router",
"version": "0.2.1",
"version": "0.2.2",
"description": "Pi extension that balances model/provider usage across weighted model pools.",
"type": "module",
"license": "MIT",
Expand Down