diff --git a/.github/workflows/__call-ci-node.yml b/.github/workflows/__call-ci-node.yml new file mode 100644 index 00000000..ba52e499 --- /dev/null +++ b/.github/workflows/__call-ci-node.yml @@ -0,0 +1,112 @@ +--- +# This workflow is intended to work with all our organization Node projects. + +# This workflow will run tests using node and then create a draft release on GitHub for push events to master. + +name: CI-Node (called) +permissions: + contents: read + +on: + workflow_call: + secrets: + CODECOV_TOKEN: + description: 'Codecov token to use for the workflow.' + required: false + GH_BOT_TOKEN: + description: 'GitHub bot token to use for the workflow.' + required: false + +jobs: + setup_release: + name: Setup Release + outputs: + publish_release: ${{ steps.setup_release.outputs.publish_release }} + release_body: ${{ steps.setup_release.outputs.release_body }} + release_generate_release_notes: ${{ steps.setup_release.outputs.release_generate_release_notes }} + release_tag: ${{ steps.setup_release.outputs.release_tag }} + 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@47f89e9acb64b76debcd5ea40642d25a4adced9f # v1.1.1 + with: + fail_ci_if_error: true + files: ./junit.xml,!./cache + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true + + - name: Upload test coverage to Codecov + # any except canceled or skipped + if: >- + always() && + (steps.test.outcome == 'success' || steps.test.outcome == 'failure') && + startsWith(github.repository, 'LizardByte/') + uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1 + 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 }} + draft: true + 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 }} diff --git a/.github/workflows/__call-update-npm.yml b/.github/workflows/__call-update-npm.yml new file mode 100644 index 00000000..86aa2f7f --- /dev/null +++ b/.github/workflows/__call-update-npm.yml @@ -0,0 +1,56 @@ +--- +name: Update NPM (called) +permissions: + contents: read + id-token: write # required for provenance and OIDC + packages: write + +on: + workflow_call: + inputs: + release_version: + description: 'Version to publish (v prefix will be stripped automatically).' + required: true + type: string + +jobs: + publish-npm: + 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: Strip version prefix + id: version + env: + INPUT_RELEASE_VERSION: ${{ inputs.release_version }} + run: echo "version=${INPUT_RELEASE_VERSION#v}" >> "${GITHUB_OUTPUT}" + + - name: Update package.json + env: + RELEASE_VERSION: ${{ steps.version.outputs.version }} + run: npm version "${RELEASE_VERSION}" --no-git-tag-version + + - name: Install dependencies + run: npm install + + - name: Build + run: npm run build + + - name: Publish + run: npm publish ${{ matrix.extra-args }} diff --git a/.github/workflows/__global-replicator.yml b/.github/workflows/__global-replicator.yml index 5339bd46..be244eb0 100644 --- a/.github/workflows/__global-replicator.yml +++ b/.github/workflows/__global-replicator.yml @@ -211,6 +211,27 @@ jobs: - name: Checkout repository uses: actions/checkout@v5 + - name: Replicating files (node) + uses: derberg/manage-files-in-multiple-repositories@v2.1.0 + with: + bot_branch_name: ${{ env.BOT_BRANCH_NAME }} + commit_message: ${{ env.COMMIT_MESSAGE }} + exclude_private: ${{ env.EXCLUDE_PRIVATE }} + repos_to_ignore: ${{ env.REPOS_TO_IGNORE }} + github_token: ${{ secrets.GH_BOT_TOKEN }} + committer_username: ${{ secrets.GH_BOT_NAME }} + committer_email: ${{ secrets.GH_BOT_EMAIL }} + patterns_to_ignore: '' + patterns_to_include: >- + .github/workflows/_ci_node.yml, + .github/workflows/_update-npm.yml + topics_to_include: 'npm-pkg' + exclude_forked: false + destination: '' + + - name: Checkout repository + uses: actions/checkout@v5 + - name: Replicating files (python) uses: derberg/manage-files-in-multiple-repositories@v2.1.0 with: diff --git a/.github/workflows/_ci-node.yml b/.github/workflows/_ci-node.yml new file mode 100644 index 00000000..a1c90397 --- /dev/null +++ b/.github/workflows/_ci-node.yml @@ -0,0 +1,28 @@ +--- +# 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. + +name: CI-Node +permissions: + contents: read + +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 00000000..3047c0a1 --- /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 }}