diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 36ccce5bd4..21c8b19bb2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,11 @@ name: CI on: + push: + branches: [main] pull_request: branches: [main] + workflow_call: jobs: typecheck: @@ -18,3 +21,49 @@ jobs: working-directory: gitnexus - run: npx tsc --noEmit working-directory: gitnexus + + unit-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + cache-dependency-path: gitnexus/package-lock.json + - run: npm ci + working-directory: gitnexus + - run: npx vitest run test/unit --coverage --coverage.thresholdAutoUpdate=false + working-directory: gitnexus + + integration-tests: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + cache-dependency-path: gitnexus/package-lock.json + - run: npm ci + working-directory: gitnexus + - run: npx vitest run test/integration + working-directory: gitnexus + + cross-platform: + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + cache-dependency-path: gitnexus/package-lock.json + - run: npm ci + working-directory: gitnexus + - run: npx vitest run test/unit + working-directory: gitnexus diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 66d6c1bb9c..5bade43475 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,10 +6,15 @@ on: - 'v*' jobs: + ci: + uses: ./.github/workflows/ci.yml + publish: + needs: ci runs-on: ubuntu-latest permissions: - contents: read + contents: write + id-token: write steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -20,9 +25,33 @@ jobs: cache-dependency-path: gitnexus/package-lock.json - run: npm ci working-directory: gitnexus - - run: npx tsc --noEmit + + - name: Verify version consistency + run: | + TAG_VERSION="${GITHUB_REF#refs/tags/v}" + PKG_VERSION=$(node -p "require('./package.json').version") + if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then + echo "::error::Tag version (v$TAG_VERSION) does not match package.json version ($PKG_VERSION)" + exit 1 + fi + echo "Version verified: $PKG_VERSION" working-directory: gitnexus - - run: npm publish + + - name: Build + run: npm run build + working-directory: gitnexus + + - name: Dry-run publish + run: npm publish --dry-run + working-directory: gitnexus + + - name: Publish to npm + run: npm publish --provenance --access public working-directory: gitnexus env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + generate_release_notes: true