From 92a2e07bd22921b38b16647433322b6851ad624a Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Thu, 28 Nov 2024 12:21:01 -0800 Subject: [PATCH 1/3] ci: add release pipeline --- .github/workflows/release.yml | 52 +++++++++++++++++++++++++++++++++++ package.json | 8 +++++- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7d9589a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,52 @@ +name: Release + +on: + workflow_dispatch: + inputs: + releaseType: + description: "Release type - major, minor or patch" + required: true + default: "" + preReleaseFlavor: + description: "Pre-Release flavor - rc, alpha, beta etc." + required: false + default: "" + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + fetch-depth: 0 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + cache: "npm" + + - name: Install Dependencies + run: npm ci + + - name: Setup Git + run: | + git config --global user.name "devx-sauce-bot" + git config --global user.email "devx.bot@saucelabs.com" + + - name: Login to NPM + run: npm set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" + + - name: Release + if: ${{ github.event.inputs.releaseType != '' }} + run: | + if [ -n "${{ github.event.inputs.preReleaseFlavor }}" ];then + PRE_RELEASE_ARGS="--preRelease=${{ github.event.inputs.preReleaseFlavor }} --github.preRelease" + fi + + npm run release:ci -- ${{ github.event.inputs.releaseType }} ${PRE_RELEASE_ARGS} + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index f51d862..0923667 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,12 @@ "lint": "prettier --check '**/*.{js,ts,mjs,cjs}' && eslint .", "fmt": "prettier --write '**/*.{js,ts,mjs,cjs}'", "prepare": "husky", - "test": "mocha tests/unit/" + "test": "mocha tests/unit/", + "release": "release-it --github.release", + "release:ci": "npm run release -- --ci --no-git.requireCleanWorkingDir", + "release:patch": "npm run release -- patch", + "release:minor": "npm run release -- minor", + "release:major": "npm run release -- major" }, "keywords": [ "testcafe", @@ -42,3 +47,4 @@ "sinon": "^19.0.2" } } + From 61d38ebfc47bda25337bf896fac7ed6bedb6b71f Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Thu, 28 Nov 2024 13:36:11 -0800 Subject: [PATCH 2/3] fmt --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 0923667..6809250 100644 --- a/package.json +++ b/package.json @@ -47,4 +47,3 @@ "sinon": "^19.0.2" } } - From 6013a546a8ee7498e06941e96f6cb2ee81ff8de5 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Thu, 28 Nov 2024 14:06:25 -0800 Subject: [PATCH 3/3] remove outdated release-it config --- .release-it.json | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .release-it.json diff --git a/.release-it.json b/.release-it.json deleted file mode 100644 index fb63364..0000000 --- a/.release-it.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "hooks": { - "before:init": ["npm test"], - "after:bump": "npm run build" - } -}