From ecd75b2e56aaad749da98d706654aa78959c3894 Mon Sep 17 00:00:00 2001 From: TheBoomerDev Date: Mon, 13 Jul 2026 11:12:11 +0200 Subject: [PATCH] feat: add CI/CD workflows [skip ci] --- .github/workflows/npm-publish.yml | 108 ++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 .github/workflows/npm-publish.yml diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..effe9dc --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -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 + + - 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" \ No newline at end of file