Skip to content
Open
Changes from all commits
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
108 changes: 108 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Publish to NPM

on:
push:
branches:
- "release"

permissions:
contents: write

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: release
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Configure Git
run: |
git config user.name "CargoBot"
git config user.email "dev@cargoffer.com"

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
registry-url: "https://registry.npmjs.org"

- name: Install Dependencies
run: yarn install || npm install

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test comment


- name: Build
run: yarn run build --if-present || npm run build --if-present || echo "No build script"

- name: Run Tests
run: |
yarn test --if-present || echo "Tests non-blocking"
continue-on-error: true

- name: Get Current Version
id: get-version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"

- name: Update Version
run: |
VERSION=$(node -p "require('./package.json').version")
npm version $VERSION --no-git-tag-version || true

- name: Commit version
run: |
VERSION=$(node -p "require('./package.json').version")
git add --all
git commit -m "chore(release): $VERSION [skip ci]" || echo "No changes"
git push origin release
continue-on-error: true

- name: Create Tag
run: |
VERSION=$(node -p "require('./package.json').version")
TAG_NAME="v_${VERSION}"
git tag -f "$TAG_NAME"
git push origin "$TAG_NAME" --force
echo "Tag: $TAG_NAME"

- name: Publish to NPM
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm publish --access public || echo "Publish attempted"
echo "Published version: ${{ steps.get-version.outputs.version }}"

deploy-to-demo:
needs: publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: release

- name: Merge to Demo
run: |
git fetch origin demo
git checkout demo
git merge origin/release --no-ff -m "chore(release): merge release to demo [skip ci]"
git push origin demo
echo "✅ Merged to demo"

- name: Merge to Edu
run: |
git fetch origin edu
git checkout edu
git merge origin/demo --no-ff -m "chore(release): merge demo to edu [skip ci]"
git push origin edu
echo "✅ Merged to edu"

- name: Merge to Main
run: |
git fetch origin main
git checkout main
git merge origin/release --no-ff -m "chore(release): merge release to main [skip ci]"
git push origin main
echo "✅ Merged to main"