Merge pull request #16 from Xeze-org/renovate/node-vault-0.x #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 📦 Publish @xeze/dbr-core to NPM | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'core/node/**' | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Version to publish (leave blank to auto-bump patch)" | |
| required: false | |
| type: string | |
| jobs: | |
| publish: | |
| name: 🚀 Build & Publish | |
| runs-on: ubuntu-latest | |
| environment: release | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - name: 📥 Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: 🟢 Set up Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '24.x' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: 🤖 Auto-bump version | |
| id: auto_bump | |
| working-directory: core/node | |
| run: | | |
| if [ -n "${{ github.event.inputs.version }}" ]; then | |
| npm version ${{ github.event.inputs.version }} --no-git-tag-version | |
| else | |
| npm version patch --no-git-tag-version | |
| fi | |
| NEW_VERSION=$(node -p "require('./package.json').version") | |
| echo "VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| - name: 📋 Show NPM version plan | |
| run: | | |
| echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | |
| echo "📦 Package: @xeze/dbr-core" | |
| echo "" | |
| CURRENT=$(npm view @xeze/dbr-core version 2>/dev/null || echo "not found") | |
| echo "📌 Latest NPM version: $CURRENT" | |
| echo "🆕 New version to publish: ${{ steps.auto_bump.outputs.VERSION }}" | |
| echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | |
| - name: 💾 Commit & Push Version Bump | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add core/node/package.json | |
| if git diff --staged --quiet; then | |
| echo "No version changes to commit." | |
| else | |
| git commit -m "chore(node-core): bump version to ${{ steps.auto_bump.outputs.VERSION }} [skip ci]" | |
| SUCCESS=0 | |
| for i in 1 2 3 4 5; do | |
| if git pull --rebase origin ${{ github.ref_name }} && git push origin HEAD:${{ github.ref_name }}; then | |
| SUCCESS=1 | |
| break | |
| fi | |
| sleep 5 | |
| done | |
| if [ $SUCCESS -eq 0 ]; then | |
| echo "Failed to push version bump to GitHub!" | |
| exit 1 | |
| fi | |
| fi | |
| - name: 📦 Install dependencies | |
| working-directory: core/node | |
| run: npm ci || npm install | |
| - name: 🚀 Publish to NPM | |
| working-directory: core/node | |
| run: | | |
| VERSION="${{ steps.auto_bump.outputs.VERSION }}" | |
| if npm view @xeze/dbr-core@$VERSION > /dev/null 2>&1; then | |
| echo "Version $VERSION already exists on NPM, skipping publish." | |
| else | |
| npm publish --access public | |
| fi | |
| - name: 🏷️ Create Git tag | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git tag -a "core-npm-v${{ steps.auto_bump.outputs.VERSION }}" -m "@xeze/dbr-core v${{ steps.auto_bump.outputs.VERSION }}" | |
| git push origin "core-npm-v${{ steps.auto_bump.outputs.VERSION }}" |