diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..5a68945 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,74 @@ +name: Publish Package +on: + release: + types: [published] + +jobs: + prepare: + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + ref: ${{ github.event.repository.default_branch }} + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 24 + registry-url: https://registry.npmjs.org + - name: Install dependencies + run: npm ci + - name: Build + run: npm run build + - name: Run tests + run: npm test + - name: Update package.json with release tag + run: | + TAG="${{ github.event.release.tag_name }}" + echo "Updating package.json version to $TAG" + npm version "$TAG" --no-git-tag-version + - name: Commit and push version update + run: | + TAG="${{ github.event.release.tag_name }}" + git config user.name "github-actions" + git config user.email "github-actions@github.com" + git add package.json package-lock.json + git commit -m "Update package.json to version $TAG" + git push origin ${{ github.event.repository.default_branch }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish-npm: + needs: prepare + permissions: + id-token: write + contents: read + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 24 + registry-url: https://registry.npmjs.org + + - run: npm ci + - run: npm run release + + publish-github: + needs: prepare + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 24 + registry-url: 'https://npm.pkg.github.com' + - run: npm ci + - run: npm run release + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index d3ea880..a9deca8 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # simple-async-pool -[![ci:build](https://flat.badgen.net/github/checks/notanengineercom/simple-async-pool/main/build?label=build&icon=github)](https://github.com/notanengineercom/simple-async-pool/actions) -[![ci:test](https://flat.badgen.net/github/checks/notanengineercom/simple-async-pool/main/test?label=test&icon=github)](https://github.com/notanengineercom/simple-async-pool/actions) +[![npm:version](https://flat.badgen.net/npm/license/simple-async-pool?icon=npm)](https://www.npmjs.com/package/simple-async-pool) +[![npm:version](https://flat.badgen.net/npm/v/simple-async-pool?icon=npm)](https://www.npmjs.com/package/simple-async-pool) [![packagephobia](https://flat.badgen.net/packagephobia/install/simple-async-pool)](https://packagephobia.com/result?p=simple-async-pool) -[![lgtm](https://flat.badgen.net/lgtm/grade/g/notanengineercom/simple-async-pool)](https://lgtm.com/projects/g/notanengineercom/simple-async-pool) +[![ci](https://flat.badgen.net/github/checks/notanengineercom/simple-async-pool/main?icon=github)](https://github.com/notanengineercom/simple-async-pool/actions) Easy to use, dependency free and typesafe concurrent pool of async and promise returning functions. diff --git a/package.json b/package.json index 1c2ebe8..1e86fd8 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,8 @@ }, "scripts": { "test": "mocha --require tsx 'tests/**/*.ts'", - "lint": "oxlint 'src/**/*.ts' 'tests/**/*.ts'", - "build": "tsl -p tsconfig.build.json", + "lint": "oxlint 'src/**/*.ts' 'tests/**/*.ts' && tsl -p tsconfig.json", + "build": "tsc -p tsconfig.build.json", "release": "npm run build && cp package.json dist && cp README.md dist && npm publish ./dist", "prepare": "husky" },