diff --git a/.github/actions/init-npm/action.yaml b/.github/actions/init-npm/action.yaml new file mode 100644 index 0000000..76e1c89 --- /dev/null +++ b/.github/actions/init-npm/action.yaml @@ -0,0 +1,21 @@ +name: init-npm +description: 'Initialize the repo with npm and install all the dependencies' +inputs: + node-version: + description: 'Node.js version' + required: true + default: '20.x' +runs: + using: composite + steps: + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + cache: npm + - name: Install TS Project dependencies + shell: bash + run: npm ci + - name: build + shell: bash + run: npm run build diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a7efa4b..f2fd3b5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,8 +1,10 @@ +name: publish + on: workflow_dispatch: release: types: [published] - + jobs: publish: runs-on: ubuntu-latest @@ -11,11 +13,8 @@ jobs: packages: write # allow GITHUB_TOKEN to publish packages steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: "20" - - run: npm ci - - run: npm run build + - name: Init nodejs + uses: ./.github/actions/init-npm - uses: JS-DevTools/npm-publish@v3 with: token: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index d9a659c..ebfac91 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -11,18 +11,18 @@ jobs: name: Run TS Project eslint runs-on: ubuntu-latest + strategy: + matrix: + node: [20.x, 22.x] + steps: - name: Check out TS Project Git repository uses: actions/checkout@v4 - - name: Set up Node.js - uses: actions/setup-node@v1 + - name: Init nodejs + uses: ./.github/actions/init-npm with: - node-version: 20.x - cache: npm - - - name: Install TS Project dependencies - run: npm ci + node-version: ${{ matrix.node }} - name: Run TS Project linters uses: wearerequired/lint-action@v2 @@ -39,13 +39,9 @@ jobs: steps: - name: Check out TS Project Git repository uses: actions/checkout@v4 - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: 20.x - cache: npm - - name: Install TS Project dependencies - run: npm ci + - name: Init nodejs + uses: ./.github/actions/init-npm + - name: Pack the package run: npm pack - name: get properties diff --git a/.github/workflows/typedoc.yml b/.github/workflows/typedoc.yml index 6bf2233..9458823 100644 --- a/.github/workflows/typedoc.yml +++ b/.github/workflows/typedoc.yml @@ -32,13 +32,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: npm - - name: Install TS Project dependencies - run: npm ci + - name: Init nodejs + uses: ./.github/actions/init-npm - name: build docs run: npm run typedoc - name: build the package