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..b66da8a 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: | + VERSION="$(node --input-type=module -e "import fs from 'node:fs'; console.log(JSON.parse(fs.readFileSync('package.json','utf8')).version)")" + echo "version=$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 }}