snapshot of https://github.com/yjs/yjs.git @ 96c96e1fcb1ef6ce866d5264b3f97f7f77b11f64 (2026-09-15)
This commit is contained in:
70
.github/workflows/publish.yml
vendored
Normal file
70
.github/workflows/publish.yml
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
name: Publish to npm
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["Node.js CI"]
|
||||
types: [completed]
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
check:
|
||||
if: github.event.workflow_run.conclusion == 'success'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
outputs:
|
||||
should_publish: ${{ steps.version-check.outputs.should_publish }}
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: 26.x
|
||||
- name: Check if version is already published
|
||||
id: version-check
|
||||
run: |
|
||||
NAME=$(node -p "require('./package.json').name")
|
||||
LOCAL=$(node -p "require('./package.json').version")
|
||||
if npm view "${NAME}@${LOCAL}" version 2>/dev/null; then
|
||||
echo "should_publish=false" >> "$GITHUB_OUTPUT"
|
||||
echo "Version $LOCAL already published, skipping."
|
||||
else
|
||||
echo "should_publish=true" >> "$GITHUB_OUTPUT"
|
||||
echo "New version detected: $LOCAL"
|
||||
fi
|
||||
|
||||
publish:
|
||||
needs: check
|
||||
if: needs.check.outputs.should_publish == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
id-token: write
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: 26.x
|
||||
- run: npm ci
|
||||
- name: Build
|
||||
run: npm run dist
|
||||
- name: Determine npm tag
|
||||
id: npm-tag
|
||||
run: |
|
||||
VERSION=$(node -p "require('./package.json').version")
|
||||
if [[ "$VERSION" == *-* ]]; then
|
||||
echo "tag=beta" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "tag=latest" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
- name: Publish
|
||||
run: npm publish --provenance --access public --tag ${{ steps.npm-tag.outputs.tag }}
|
||||
- name: Create GitHub Release
|
||||
run: |
|
||||
VERSION=$(node -p "require('./package.json').version")
|
||||
PRERELEASE=""
|
||||
if [[ "$VERSION" == *-* ]]; then
|
||||
PRERELEASE="--prerelease"
|
||||
fi
|
||||
gh release create "v${VERSION}" --generate-notes $PRERELEASE
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
Reference in New Issue
Block a user