diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 976bd10..4255179 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,23 +21,16 @@ permissions: contents: read jobs: - # ─── Job 1: Run all unit tests (+ bump version on push events) ──────────────── + # ─── Job 1: Run all unit tests ──────────────────────────────────────────────── test: name: Unit Tests runs-on: ubuntu-22.04 - # Version bump needs write access on push events; PRs only need read permissions: - contents: write - - outputs: - new-version: ${{ steps.bump.outputs.new-version }} + contents: read steps: - name: Checkout uses: actions/checkout@v6 - with: - # Use GITHUB_TOKEN so the bot can push the version bump commit back - token: ${{ secrets.GITHUB_TOKEN }} - name: Setup Node.js uses: actions/setup-node@v6 @@ -45,84 +38,12 @@ jobs: node-version: '24' cache: 'npm' - # ── Version bump (push events only, not PRs, not uat) ───────────────────── - # Display version format: RELEASE.BETA.ALPHA.BUILD (stored in build.extraMetadata.version) - # Semver format: RELEASE.BETA.ALPHA (stored in version — required by electron-builder) - # - # develop → increment BUILD (4th digit only) - # alpha → increment ALPHA (3rd digit), reset BUILD to 0 - # beta → increment BETA (2nd digit), reset ALPHA and BUILD to 0 - # main → increment RELEASE (1st digit), reset BETA/ALPHA/BUILD to 0, tag release/X.0.0.0 - - name: Bump version - id: bump - if: github.event_name == 'push' && github.ref_name != 'uat' && github.actor != 'dependabot[bot]' - run: | - # Read the 4-part display version from extraMetadata - EXT_VERSION=$(node -p "require('./package.json').build.extraMetadata.version") - IFS='.' read -r RELEASE BETA ALPHA BUILD <<< "$EXT_VERSION" - - case "${{ github.ref_name }}" in - develop) - BUILD=$((BUILD + 1)) - ;; - alpha) - ALPHA=$((ALPHA + 1)) - BUILD=0 - ;; - beta) - BETA=$((BETA + 1)) - ALPHA=0 - BUILD=0 - ;; - main) - RELEASE=$((RELEASE + 1)) - BETA=0 - ALPHA=0 - BUILD=0 - ;; - esac - - NEW_EXT_VERSION="${RELEASE}.${BETA}.${ALPHA}.${BUILD}" - # 3-part semver for electron-builder (strips the BUILD digit) - NEW_VERSION="${RELEASE}.${BETA}.${ALPHA}" - - node -e " - const fs = require('fs'); - const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); - pkg.version = '${NEW_VERSION}'; - pkg.build.extraMetadata.version = '${NEW_EXT_VERSION}'; - fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n'); - " - echo "new-version=${NEW_EXT_VERSION}" >> "$GITHUB_OUTPUT" - echo "Bumped to: ${NEW_EXT_VERSION} (semver: ${NEW_VERSION})" - - name: Install dependencies run: npm ci - name: Run unit tests run: npm run test:run - # Push the version bump commit AFTER tests pass so a failed test doesn't - # advance the version counter. - - name: Commit and push version bump - if: github.event_name == 'push' && github.ref_name != 'uat' && github.actor != 'dependabot[bot]' && steps.bump.outputs.new-version != '' - run: | - NEW_VERSION="${{ steps.bump.outputs.new-version }}" - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git add package.json - # Only commit if package.json actually changed (idempotent guard) - git diff --cached --quiet || git commit -m "chore: bump version to ${NEW_VERSION} [skip ci]" - git push - - # On main: create a release tag after the version bump commit is pushed. - - name: Tag release - if: github.event_name == 'push' && github.ref_name == 'main' && github.actor != 'dependabot[bot]' && steps.bump.outputs.new-version != '' - run: | - TAG="release/${{ steps.bump.outputs.new-version }}" - git tag "$TAG" - git push origin "$TAG" - # ─── Job 2: Build the .deb installer (only runs when all tests pass) ────────── build: name: Build Linux DEB @@ -135,7 +56,6 @@ jobs: actions: write # required to list and delete artifacts steps: - # Checkout the branch tip (picks up the version bump commit from the test job) - name: Checkout uses: actions/checkout@v6 with: