|
|
@@ -3,10 +3,17 @@ name: Publish to npm
|
|
|
on:
|
|
|
release:
|
|
|
types: [created]
|
|
|
+ workflow_run:
|
|
|
+ workflows: [CI]
|
|
|
+ types: [completed]
|
|
|
+ branches: [main]
|
|
|
|
|
|
jobs:
|
|
|
publish:
|
|
|
runs-on: macos-latest
|
|
|
+ if: >
|
|
|
+ (github.event_name == 'release') ||
|
|
|
+ (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push')
|
|
|
|
|
|
steps:
|
|
|
- name: Checkout repository
|
|
|
@@ -19,19 +26,41 @@ jobs:
|
|
|
registry-url: "https://registry.npmjs.org"
|
|
|
cache: "npm"
|
|
|
|
|
|
+ - name: Check if version is already published
|
|
|
+ id: check
|
|
|
+ run: |
|
|
|
+ LOCAL_VERSION=$(node -p "require('./package.json').version")
|
|
|
+ PUBLISHED_VERSION=$(npm view apple-mail-mcp version 2>/dev/null || echo "0.0.0")
|
|
|
+ echo "local=$LOCAL_VERSION" >> "$GITHUB_OUTPUT"
|
|
|
+ echo "published=$PUBLISHED_VERSION" >> "$GITHUB_OUTPUT"
|
|
|
+ if [ "$LOCAL_VERSION" = "$PUBLISHED_VERSION" ]; then
|
|
|
+ echo "skip=true" >> "$GITHUB_OUTPUT"
|
|
|
+ else
|
|
|
+ echo "skip=false" >> "$GITHUB_OUTPUT"
|
|
|
+ fi
|
|
|
+
|
|
|
- name: Install dependencies
|
|
|
+ if: steps.check.outputs.skip == 'false'
|
|
|
run: npm ci
|
|
|
|
|
|
- name: Run linter
|
|
|
+ if: steps.check.outputs.skip == 'false'
|
|
|
run: npm run lint
|
|
|
|
|
|
- name: Run tests
|
|
|
+ if: steps.check.outputs.skip == 'false'
|
|
|
run: npm test
|
|
|
|
|
|
- name: Build
|
|
|
+ if: steps.check.outputs.skip == 'false'
|
|
|
run: npm run build
|
|
|
|
|
|
- name: Publish to npm
|
|
|
+ if: steps.check.outputs.skip == 'false'
|
|
|
run: npm publish
|
|
|
env:
|
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
|
+
|
|
|
+ - name: Skip publish (version already published)
|
|
|
+ if: steps.check.outputs.skip == 'true'
|
|
|
+ run: echo "Version ${{ steps.check.outputs.local }} is already published. Skipping."
|