diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000..6e0a499 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,18 @@ +name: 'Setup' +description: 'Prepares a local copy of the repository for CI actions' +runs: + using: composite + steps: + - name: Enable corepack + shell: bash + run: corepack enable pnpm + + - uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: https://registry.npmjs.org/ + cache: 'pnpm' + + - name: Install dependencies + shell: bash + run: pnpm install diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 33a7931..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,27 +0,0 @@ -on: [push] - -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: oven-sh/setup-bun@v1 - with: - bun-version: latest - - run: bun install - - run: bun test:coverage - - run: bun test:report - - name: Coveralls - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - path-to-lcov: ./lcov.info - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: oven-sh/setup-bun@v1 - with: - bun-version: latest - - run: bun install - - run: bun run build diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..cbd6bc2 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,48 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + environment: ci + steps: + - uses: actions/checkout@v4 + + - name: Setup + uses: ./.github/actions/setup + + - run: pnpm test:coverage + + - name: Coveralls + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: ./coverage/lcov.info + + check: + runs-on: ubuntu-latest + environment: ci + steps: + - uses: actions/checkout@v4 + + - name: Setup + uses: ./.github/actions/setup + + - run: pnpm check + - run: pnpm type-check + + build: + runs-on: ubuntu-latest + environment: ci + steps: + - uses: actions/checkout@v4 + + - name: Setup + uses: ./.github/actions/setup + + - run: pnpm build diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..9c29407 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,26 @@ +name: Publish + +on: + release: + types: [prereleased, released] + +jobs: + publish: + name: Publish to NPM + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + filter: tree:0 + + - name: Setup + uses: ./.github/actions/setup + + - run: git config --global user.name "${{ github.actor }}" + - run: git config --global user.email "github-action-${{ github.actor }}@users.noreply.github.com" + - run: npm version from-git --no-git-tag-version + - run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} \ No newline at end of file