Skip to content

🚀 Publish to NPM Dev Channel #1

🚀 Publish to NPM Dev Channel

🚀 Publish to NPM Dev Channel #1

Workflow file for this run

name: Publish to NPM Dev Channel
on:
workflow_dispatch
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check branch
run: |
if [ "$GITHUB_REF" != "refs/heads/develop" ]; then
echo "This workflow can only be run on the 'develop' branch."
exit 1
fi
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: npm install
- name: Build project
run: npm run build
- name: Update package version
id: update-version
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
TIMESTAMP=$(date -u +"%Y%m%d%H%M%S")
NEW_VERSION="${CURRENT_VERSION}-dev${TIMESTAMP}"
npm version --no-git-tag-version $NEW_VERSION
echo "New version: $NEW_VERSION"
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
- name: Update package-lock.json
run: npm install
- name: Commit version update
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
git add package.json package-lock.json
git commit -m "Update version to $NEW_VERSION [skip ci]"
git push origin develop
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
- name: Publish to NPM Dev Channel
run: npm publish --tag dev
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}