From fc8d9c2c0ecf0605e8f09b4b8c00dab12908038d Mon Sep 17 00:00:00 2001 From: Michael Walter Van Der Velden Date: Sat, 11 Nov 2023 17:28:16 +0000 Subject: [PATCH] ci(github): Switch to Google's Release Please Action (#22) * ci(github): Switch to Google's Release Please Action * ci(github): Don't run release if tests fail --- .github/workflows/ci.yml | 52 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 32 --------------------- .github/workflows/test.yml | 21 -------------- 3 files changed, 52 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1ea131a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,52 @@ +name: CI Pipeline + +on: ['push'] + +jobs: + test: + name: Test Suite + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [16.x, 18.x, 20.x] + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + - run: npm ci + name: Install Dependancies + - run: npm test + name: Run tests + release-please: + runs-on: ubuntu-latest + name: Release + needs: test + if: github.ref == 'refs/heads/main' + steps: + - uses: google-github-actions/release-please-action@v3 + name: Release Please + id: release + with: + release-type: node + package-name: webmention-handler + # The logic below handles the npm publication: + - uses: actions/checkout@v3 + # these if statements ensure that a publication only occurs when + # a new release is created: + if: ${{ steps.release.outputs.release_created }} + - uses: actions/setup-node@v1 + with: + node-version: 18 + registry-url: 'https://registry.npmjs.org' + if: ${{ steps.release.outputs.release_created }} + - run: npm ci + name: Install Dependancies + if: ${{ steps.release.outputs.release_created }} + - run: npm run build + name: Build Release + - run: npm publish --access=public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} + if: ${{ steps.release.outputs.release_created }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 4b70fac..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Release Module - -on: - release: - types: [created] -jobs: - npm: - runs-on: ubuntu-latest - if: contains(github.ref, 'tags') - steps: - - uses: actions/checkout@v3 - - - name: Use Node.js 16 - uses: actions/setup-node@v3 - with: - node-version: '16.x' - - - name: Install npm dependencies - run: npm ci - - - name: Test and build package - run: | - npm test - npm run build - - name: Publish tag to npm - run: npm publish --access=public - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} - - - uses: actions/setup-node@v1 - with: - registry-url: 'https://npm.pkg.github.com' \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index a05e09d..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Test Suite - -on: ['push'] - -jobs: - test: - - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [14.x, 16.x, 18.x] - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - - run: npm ci - - run: npm test \ No newline at end of file