Skip to content
Merged
Changes from 1 commit
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
69 changes: 69 additions & 0 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ 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@v4
Expand Down Expand Up @@ -45,3 +48,69 @@ 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@v4
with:
ref: ${{ needs.release.outputs.tag }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
registry-url: https://registry.npmjs.org
Comment thread
coderabbitai[bot] marked this conversation as resolved.
package-manager-cache: false
Comment thread
coderabbitai[bot] marked this conversation as resolved.

- 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")
if npm view "${name}@${version}" version >/dev/null 2>&1; then
echo "${name}@${version} is already published."
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "Publishing ${name}@${version}."
echo "skip=false" >> "$GITHUB_OUTPUT"
Comment thread
coderabbitai[bot] marked this conversation as resolved.
fi

- name: Publish to npm
if: steps.published.outputs.skip != 'true'
run: npm publish --access public