From 7fbe82324543cb2173dcbe9f0aa1e96343ee7bf5 Mon Sep 17 00:00:00 2001 From: Jose V Sebastian Date: Fri, 19 Jan 2024 01:29:23 +0530 Subject: [PATCH] ci: setup release pipeline --- .github/workflows/release.yaml | 53 ++++++++++++++++++++++++++++++++++ package.json | 7 ++--- pnpm-lock.yaml | 36 +++++++++++++++++------ release.config.cjs | 30 +++++++++++++++++++ 4 files changed, 113 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/release.yaml create mode 100644 release.config.cjs diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..a2d1176 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,53 @@ +name: Release + +on: + workflow_dispatch: + push: + branches: + - main + - beta + - alpha + +jobs: + release: + permissions: + contents: write + issues: write + pull-requests: write + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 20 + + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: latest + run_install: false + + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - name: Setup pnpm cache + uses: actions/cache@v3 + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install --frozen-lockfile --strict-peer-dependencies + + - name: Semantic Release + run: npx semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index 356103f..2d988a1 100644 --- a/package.json +++ b/package.json @@ -3,10 +3,10 @@ "author": "Jose V Sebastian", "version": "0.0.0", "license": "MIT", - "private": true, "scripts": { "start": "tsx ./src/cli", "build": "rollup -c", + "prepack": "pnpm build", "test": "jest --watch", "lint": "eslint --quiet --fix", "prepare": "husky install" @@ -30,14 +30,13 @@ "node": ">=20" }, "dependencies": { - "@optimize-lodash/rollup-plugin": "^4.0.4", "cheerio": "1.0.0-rc.12", "commander": "^11.1.0", "glob": "^10.3.10", - "lodash": "^4.17.21", - "lodash-es": "^4.17.21" + "lodash": "^4.17.21" }, "devDependencies": { + "@optimize-lodash/rollup-plugin": "^4.0.4", "@rollup/plugin-commonjs": "^25.0.7", "@rollup/plugin-eslint": "^9.0.5", "@rollup/plugin-node-resolve": "^15.2.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d3b0ca2..30a1f20 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,9 +5,6 @@ settings: excludeLinksFromLockfile: false dependencies: - "@optimize-lodash/rollup-plugin": - specifier: ^4.0.4 - version: 4.0.4(rollup@4.9.5) cheerio: specifier: 1.0.0-rc.12 version: 1.0.0-rc.12 @@ -20,11 +17,11 @@ dependencies: lodash: specifier: ^4.17.21 version: 4.17.21 - lodash-es: - specifier: ^4.17.21 - version: 4.17.21 devDependencies: + "@optimize-lodash/rollup-plugin": + specifier: ^4.0.4 + version: 4.0.4(rollup@4.9.5) "@rollup/plugin-commonjs": specifier: ^25.0.7 version: 25.0.7(rollup@4.9.5) @@ -296,6 +293,7 @@ packages: { integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==, } + dev: true /@jridgewell/trace-mapping@0.3.21: resolution: @@ -479,7 +477,7 @@ packages: "@optimize-lodash/transform": 3.0.3 "@rollup/pluginutils": 5.0.5(rollup@4.9.5) rollup: 4.9.5 - dev: false + dev: true /@optimize-lodash/transform@3.0.3: resolution: @@ -490,7 +488,7 @@ packages: dependencies: estree-walker: 2.0.2 magic-string: 0.30.5 - dev: false + dev: true /@pkgjs/parseargs@0.11.0: resolution: @@ -658,7 +656,7 @@ packages: estree-walker: 2.0.2 picomatch: 2.3.1 rollup: 4.9.5 - dev: false + dev: true /@rollup/pluginutils@5.1.0(rollup@4.9.5): resolution: @@ -686,6 +684,7 @@ packages: cpu: [arm] os: [android] requiresBuild: true + dev: true optional: true /@rollup/rollup-android-arm64@4.9.5: @@ -696,6 +695,7 @@ packages: cpu: [arm64] os: [android] requiresBuild: true + dev: true optional: true /@rollup/rollup-darwin-arm64@4.9.5: @@ -706,6 +706,7 @@ packages: cpu: [arm64] os: [darwin] requiresBuild: true + dev: true optional: true /@rollup/rollup-darwin-x64@4.9.5: @@ -716,6 +717,7 @@ packages: cpu: [x64] os: [darwin] requiresBuild: true + dev: true optional: true /@rollup/rollup-linux-arm-gnueabihf@4.9.5: @@ -726,6 +728,7 @@ packages: cpu: [arm] os: [linux] requiresBuild: true + dev: true optional: true /@rollup/rollup-linux-arm64-gnu@4.9.5: @@ -736,6 +739,7 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true + dev: true optional: true /@rollup/rollup-linux-arm64-musl@4.9.5: @@ -746,6 +750,7 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true + dev: true optional: true /@rollup/rollup-linux-riscv64-gnu@4.9.5: @@ -756,6 +761,7 @@ packages: cpu: [riscv64] os: [linux] requiresBuild: true + dev: true optional: true /@rollup/rollup-linux-x64-gnu@4.9.5: @@ -766,6 +772,7 @@ packages: cpu: [x64] os: [linux] requiresBuild: true + dev: true optional: true /@rollup/rollup-linux-x64-musl@4.9.5: @@ -776,6 +783,7 @@ packages: cpu: [x64] os: [linux] requiresBuild: true + dev: true optional: true /@rollup/rollup-win32-arm64-msvc@4.9.5: @@ -786,6 +794,7 @@ packages: cpu: [arm64] os: [win32] requiresBuild: true + dev: true optional: true /@rollup/rollup-win32-ia32-msvc@4.9.5: @@ -796,6 +805,7 @@ packages: cpu: [ia32] os: [win32] requiresBuild: true + dev: true optional: true /@rollup/rollup-win32-x64-msvc@4.9.5: @@ -806,6 +816,7 @@ packages: cpu: [x64] os: [win32] requiresBuild: true + dev: true optional: true /@semantic-release/changelog@6.0.3(semantic-release@23.0.0): @@ -983,6 +994,7 @@ packages: { integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==, } + dev: true /@types/glob@7.2.0: resolution: @@ -2220,6 +2232,7 @@ packages: { integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==, } + dev: true /esutils@2.0.3: resolution: @@ -2469,6 +2482,7 @@ packages: engines: { node: ^8.16.0 || ^10.6.0 || >=11.0.0 } os: [darwin] requiresBuild: true + dev: true optional: true /function-bind@1.1.2: @@ -3308,6 +3322,7 @@ packages: { integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==, } + dev: true /lodash.capitalize@4.2.1: resolution: @@ -3396,6 +3411,7 @@ packages: engines: { node: ">=12" } dependencies: "@jridgewell/sourcemap-codec": 1.4.15 + dev: true /marked-terminal@6.2.0(marked@11.1.1): resolution: @@ -4006,6 +4022,7 @@ packages: integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==, } engines: { node: ">=8.6" } + dev: true /pidtree@0.6.0: resolution: @@ -4330,6 +4347,7 @@ packages: "@rollup/rollup-win32-ia32-msvc": 4.9.5 "@rollup/rollup-win32-x64-msvc": 4.9.5 fsevents: 2.3.3 + dev: true /run-parallel@1.2.0: resolution: diff --git a/release.config.cjs b/release.config.cjs new file mode 100644 index 0000000..b4a2d4b --- /dev/null +++ b/release.config.cjs @@ -0,0 +1,30 @@ +/** @type {import('semantic-release').GlobalConfig} */ +const config = { + branches: [ + "+([0-9])?(.{+([0-9]),x}).x", + "main", + "next", + "next-major", + { name: "beta", prerelease: true }, + { name: "alpha", prerelease: true }, + ], + plugins: [ + ["@semantic-release/commit-analyzer", { preset: "conventionalcommits" }], + [ + "@semantic-release/release-notes-generator", + { preset: "conventionalcommits" }, + ], + [ + "@semantic-release/changelog", + { + changelogTitle: + "# Changelog\n\nAll notable changes to this project will be documented in this file. See\n[Conventional Commits](https://conventionalcommits.org) for commit guidelines.", + }, + ], + ["@semantic-release/npm", { tarballDir: "pack" }], + "@semantic-release/git", + ["@semantic-release/github", { assets: "pack/*.tgz" }], + ], +}; + +module.exports = config;