Skip to content

fix lint errors and failing tests to pass CI #12

fix lint errors and failing tests to pass CI

fix lint errors and failing tests to pass CI #12

Workflow file for this run

name: Release
# main: npm publish @latest + fixed tag v<ver> + mobile tag 'latest' + GitHub Release
# dev: no npm publish, no fixed tag, no GitHub Release, just mobile tag 'alpha'
# (users can install dev via `npm i github:enixCode/light-process#alpha`)
on:
push:
branches: [main, dev]
jobs:
release:
name: Build + Release
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip release]')"
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
registry-url: https://registry.npmjs.org
- name: Compute version
id: v
run: |
BASE=$(node -p "require('./package.json').version.split('-')[0]")
if [ "${{ github.ref_name }}" = "main" ]; then
VERSION="$BASE"
else
COUNT=$(git rev-list --count HEAD)
VERSION="${BASE}-alpha.${COUNT}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Guard - main must be stable version
if: github.ref_name == 'main' && contains(steps.v.outputs.version, '-')
run: |
echo "main branch must publish a stable version (no pre-release suffix)"
exit 1
- name: Install, lint, build, test
run: |
npm ci
npx biome check src/ test/
npm run build
npm test
- name: Set version in-memory
run: npm version ${{ steps.v.outputs.version }} --no-git-tag-version --allow-same-version
# --- main branch: publish to npm + fixed tag + mobile 'latest' + GitHub Release ---
- name: Check if version already on npm
if: github.ref_name == 'main'
id: npm_check
run: |
if npm view light-process@${{ steps.v.outputs.version }} version >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "Version ${{ steps.v.outputs.version }} already on npm, skipping publish"
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Publish to npm
if: github.ref_name == 'main' && steps.npm_check.outputs.exists == 'false'
run: npm publish --tag latest --provenance --access public
- name: Create fixed git tag (main)
if: github.ref_name == 'main' && steps.npm_check.outputs.exists == 'false'
run: |
git tag ${{ steps.v.outputs.tag }}
git push origin ${{ steps.v.outputs.tag }}
- name: Move mobile 'latest' git tag (main)
if: github.ref_name == 'main' && steps.npm_check.outputs.exists == 'false'
run: |
git tag -f latest
git push origin latest --force
- name: Create GitHub Release (main)
if: github.ref_name == 'main' && steps.npm_check.outputs.exists == 'false'
run: gh release create ${{ steps.v.outputs.tag }} --generate-notes
env:
GH_TOKEN: ${{ github.token }}
# --- dev branch: just move mobile 'alpha' git tag ---
- name: Move mobile 'alpha' git tag (dev)
if: github.ref_name == 'dev'
run: |
git tag -f alpha
git push origin alpha --force