diff --git a/.github/workflows/_ci-node.yml b/.github/workflows/_ci-node.yml new file mode 100644 index 0000000..f0882d2 --- /dev/null +++ b/.github/workflows/_ci-node.yml @@ -0,0 +1,32 @@ +--- +# This workflow is centrally managed in https://github.com/LizardByte/.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in +# the above-mentioned repo. + +# To use, add the `npm-pkg` repository label to identify repositories that should trigger this workflow. + +# This will run standard CI for Node.js/npm/TypeScript projects. + +name: CI-Node +permissions: + contents: write # required for release_setup action + +on: + push: + branches: + - master + pull_request: + branches: + - master + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + call-ci-node: + name: CI-Node + uses: LizardByte/.github/.github/workflows/__call-ci-node.yml@master + if: ${{ github.repository != 'LizardByte/.github' }} + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/_update-npm.yml b/.github/workflows/_update-npm.yml new file mode 100644 index 0000000..3047c0a --- /dev/null +++ b/.github/workflows/_update-npm.yml @@ -0,0 +1,31 @@ +--- +# This workflow is centrally managed in https://github.com/LizardByte/.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in +# the above-mentioned repo. + +# To use, add the `npm-pkg` repository label to identify repositories that should trigger this workflow. + +# Update NPM packages on release events. + +name: Update NPM +permissions: + contents: read + id-token: write # required for provenance and OIDC + packages: write + +on: + release: + types: + - released + +concurrency: + group: "${{ github.workflow }}-${{ github.event.release.tag_name }}" + cancel-in-progress: true + +jobs: + update-npm: + name: Update NPM + uses: LizardByte/.github/.github/workflows/__call-update-npm.yml@master + if: github.repository_owner == 'LizardByte' + with: + release_version: ${{ github.event.release.tag_name }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 9620a16..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,171 +0,0 @@ ---- -# This workflow will run tests using node and then publish a package to GitHub Packages on push events to master. -# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages - -name: CI -permissions: - contents: read - -on: - pull_request: - branches: - - master - types: - - opened - - synchronize - - reopened - push: - branches: - - master - -concurrency: - group: "${{ github.workflow }}-${{ github.ref }}" - cancel-in-progress: true - -jobs: - setup_release: - name: Setup Release - outputs: - publish_release: ${{ steps.setup_release.outputs.publish_release }} - release_body: ${{ steps.setup_release.outputs.release_body }} - release_commit: ${{ steps.setup_release.outputs.release_commit }} - release_generate_release_notes: ${{ steps.setup_release.outputs.release_generate_release_notes }} - release_tag: ${{ steps.setup_release.outputs.release_tag }} - release_version: ${{ steps.setup_release.outputs.release_version }} - permissions: - contents: write - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v5 - - - name: Setup Release - id: setup_release - uses: LizardByte/actions/actions/release_setup@v2025.1011.184228 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v5 - - - name: Setup node - uses: actions/setup-node@v6 - with: - node-version: latest - - - name: Install dependencies - run: npm install - - - name: Test - id: test - env: - FORCE_COLOR: true - run: npm test - - - name: Build - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - run: npm run build - - - name: Upload test results to Codecov - # any except canceled or skipped - if: >- - always() && - (steps.test.outcome == 'success' || steps.test.outcome == 'failure') && - startsWith(github.repository, 'LizardByte/') - uses: codecov/test-results-action@v1 - with: - fail_ci_if_error: true - files: ./junit.xml,!./cache - token: ${{ secrets.CODECOV_TOKEN }} - verbose: true - - - name: Upload coverage - # any except canceled or skipped - if: >- - always() && - (steps.test.outcome == 'success' || steps.test.outcome == 'failure') && - startsWith(github.repository, 'LizardByte/') - uses: codecov/codecov-action@v5 - with: - disable_search: true - fail_ci_if_error: true - files: ./coverage/coverage-final.json - token: ${{ secrets.CODECOV_TOKEN }} - verbose: true - - release: - if: needs.setup_release.outputs.publish_release == 'true' - needs: - - setup_release - - build - runs-on: ubuntu-latest - steps: - - name: Create Release - id: action - uses: LizardByte/actions/actions/release_create@v2025.1011.184228 - with: - allowUpdates: false - artifacts: '' - body: ${{ needs.setup_release.outputs.release_body }} - generateReleaseNotes: ${{ needs.setup_release.outputs.release_generate_release_notes }} - name: ${{ needs.setup_release.outputs.release_tag }} - prerelease: true - tag: ${{ needs.setup_release.outputs.release_tag }} - token: ${{ secrets.GH_BOT_TOKEN }} - - publish-gpr: - if: needs.setup_release.outputs.publish_release == 'true' - needs: - - setup_release - - build - permissions: - contents: read - id-token: write # required for provenance - packages: write - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - - registry-url: "https://npm.pkg.github.com" - extra-args: "" - - registry-url: "https://registry.npmjs.org" - extra-args: "--provenance --access public" - steps: - - name: Checkout - uses: actions/checkout@v5 - - - name: Setup node - uses: actions/setup-node@v6 - with: - node-version: latest - registry-url: ${{ matrix.registry-url }} - scope: '@lizardbyte' - - - name: Update package.json - run: npm version ${{ needs.setup_release.outputs.release_version }} --no-git-tag-version - - - name: Install dependencies - run: npm install - - - name: Build - run: npm run build - - - name: Set token - id: token - run: | - # if github registry, use GITHUB_TOKEN - if [ "${{ matrix.registry-url }}" == "https://npm.pkg.github.com" ]; then - echo "NODE_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> "${GITHUB_OUTPUT}" - else - echo "NODE_AUTH_TOKEN=${{ secrets.NPM_TOKEN }}" >> "${GITHUB_OUTPUT}" - fi - - - name: Publish - run: npm publish ${{ matrix.extra-args }} - env: - NODE_AUTH_TOKEN: ${{ steps.token.outputs.NODE_AUTH_TOKEN }}