diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5716c8e..d5a2a6b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,11 +11,6 @@ jobs: lint-and-test: runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - node: [20, 22] - steps: - name: Checkout uses: actions/checkout@v4 @@ -23,7 +18,7 @@ jobs: - name: Setup Node uses: actions/setup-node@v4 with: - node-version: ${{ matrix.node }} + node-version: 22 cache: npm - name: Install diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f61acf8..3cbfc4d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -23,13 +23,36 @@ jobs: with: node-version: 22 cache: npm + registry-url: https://npm.pkg.github.com + scope: '@hanlogy' - run: npm ci - run: npm run lint - run: npm test - run: npm run build + - name: Read local version + id: local + run: + echo "version=$(node -p \"require('./package.json').version\")" >> + "$GITHUB_OUTPUT" + + - name: Check published version + id: check + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + PKG="@hanlogy/ts-lib" + REG="https://npm.pkg.github.com" + PUBLISHED="$(npm view "$PKG" version --registry="$REG" 2>/dev/null || echo "")" + if [ "$PUBLISHED" = "${{ steps.local.outputs.version }}" ]; then + echo "should_publish=false" >> "$GITHUB_OUTPUT" + else + echo "should_publish=true" >> "$GITHUB_OUTPUT" + fi + - name: Publish + if: steps.check.outputs.should_publish == 'true' run: npm publish env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index e293df2..cd97378 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,6 @@ "type": "module", "author": "hanlogy.com", "license": "AGPL-3.0 license", - "publishConfig": { - "registry": "https://npm.pkg.github.com/" - }, "main": "dist/cjs/index.js", "module": "dist/index.js", "types": "dist/index.d.ts", @@ -26,7 +23,6 @@ "build:cjs": "tsc --project tsconfig.cjs.json && tsc-alias -p tsconfig.cjs.json", "build:esm": "tsc --project tsconfig.esm.json && tsc-alias -p tsconfig.esm.json", "build": "rm -rf dist && npm run build:cjs && npm run build:esm", - "prepublishOnly": "npm run build", "prepack": "npm run build", "test": "TZ=UTC jest" },