From 2f4dbf06a2c160471c95187ba5c8a4de8639b771 Mon Sep 17 00:00:00 2001 From: Dexxiez Date: Fri, 29 Dec 2023 19:39:35 +1100 Subject: [PATCH] chore: Update CI workflow and package.json minimum engines --- .github/workflows/ci.yml | 110 +++++++++++++++++++++------------------ .npmrc | 1 + package.json | 68 ++++++++++++------------ 3 files changed, 94 insertions(+), 85 deletions(-) create mode 100644 .npmrc diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 18cb24a8..39873d53 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,62 +2,70 @@ name: BetterDiscord CI on: push: - branches: [ "main" ] + branches: ["main"] pull_request: - branches: [ "main" ] + branches: ["main"] jobs: - build: - + test: runs-on: ubuntu-latest - + strategy: + matrix: + node-version: [18, 20] # Current LTS versions steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install Node.js - uses: actions/setup-node@v3 - with: - node-version: 16 - - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install - with: - version: 7 - run_install: false + - name: Checkout + uses: actions/checkout@v4 - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + - name: Install Node.js LTS + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: "pnpm" - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- + - uses: pnpm/action-setup@v2 + name: Install pnpm + with: + version: 8 + run_install: false - - name: Install dependencies - run: pnpm install --frozen-lockfile - -# - name: Lint -# run: pnpm lint - -# - name: Run tests -# run: pnpm test - - - name: Build asar - run: pnpm dist - - - uses: actions/upload-artifact@v3 - name: Upload artifact -# if: ${{ github.ref == 'refs/heads/main' }} # Only create artifacts when pushed to main - with: - name: betterdiscord.asar - path: dist/betterdiscord.asar - retention-days: 30 - if-no-files-found: error + - name: Install dependencies + run: pnpm install --frozen-lockfile --prefer-frozen-lockfile + + - name: Run tests + run: pnpm test + + - name: Ensure build compiles on Node.js ${{ matrix.node-version }} LTS + run: pnpm dist + + release: + runs-on: ubuntu-latest + if: ${{ github.ref == 'refs/heads/main' }} # Only build when pushed to main + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Node.js LTS + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "pnpm" + + - uses: pnpm/action-setup@v2 + name: Install pnpm + with: + version: 8 + run_install: false + + - name: Install dependencies + run: pnpm install --frozen-lockfile --prefer-frozen-lockfile + + - name: Build asar + run: pnpm dist + + - uses: actions/upload-artifact@v3 + name: Upload artifact + with: + name: betterdiscord.asar + path: dist/betterdiscord.asar + retention-days: 30 + if-no-files-found: error diff --git a/.npmrc b/.npmrc new file mode 100644 index 00000000..3e8493b2 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +auto-install-peers=false # Maintain PNPM v7 behavior for now diff --git a/package.json b/package.json index a4829186..2cbd7919 100644 --- a/package.json +++ b/package.json @@ -1,36 +1,36 @@ { - "name": "betterdiscord", - "version": "1.9.7", - "description": "Enhances Discord by adding functionality and themes.", - "main": "src/index.js", - "scripts": { - "build": "pnpm run build-injector && pnpm run build-preload && pnpm run build-renderer", - "build-prod": "pnpm --filter injector build-prod && pnpm --filter preload build-prod && pnpm --filter renderer build-prod", - "build-injector": "pnpm --filter injector build", - "build-renderer": "pnpm --filter renderer build", - "build-preload": "pnpm --filter preload build", - "inject": "node scripts/inject.js", - "lint": "eslint --ext .js common/ && pnpm --filter injector lint && pnpm --filter preload lint && pnpm --filter renderer lint-js", - "test": "mocha --require @babel/register --recursive \"./tests/renderer/*.js\"", - "dist": "pnpm run build-prod && node scripts/pack.js", - "api": "jsdoc -X -r renderer/src/modules/api/ > jsdoc-ast.json", - "translations": "node -r dotenv/config scripts/translations.js" - }, - "devDependencies": { - "@babel/core": "^7.16.12", - "@babel/preset-env": "^7.16.11", - "@babel/register": "^7.16.9", - "asar": "^3.2.0", - "dotenv": "^16.0.3", - "eslint": "^8.23.0", - "eslint-plugin-react": "^7.31.6", - "eslint-plugin-react-hooks": "^4.6.0", - "mocha": "^10.0.0", - "webpack": "^5.74.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=14", - "pnpm": ">=7" - } + "name": "betterdiscord", + "version": "1.9.7", + "description": "Enhances Discord by adding functionality and themes.", + "main": "src/index.js", + "scripts": { + "build": "pnpm run build-injector && pnpm run build-preload && pnpm run build-renderer", + "build-prod": "pnpm --filter injector build-prod && pnpm --filter preload build-prod && pnpm --filter renderer build-prod", + "build-injector": "pnpm --filter injector build", + "build-renderer": "pnpm --filter renderer build", + "build-preload": "pnpm --filter preload build", + "inject": "node scripts/inject.js", + "lint": "eslint --ext .js common/ && pnpm --filter injector lint && pnpm --filter preload lint && pnpm --filter renderer lint-js", + "test": "mocha --require @babel/register --recursive \"./tests/renderer/*.js\"", + "dist": "pnpm run build-prod && node scripts/pack.js", + "api": "jsdoc -X -r renderer/src/modules/api/ > jsdoc-ast.json", + "translations": "node -r dotenv/config scripts/translations.js" + }, + "devDependencies": { + "@babel/core": "^7.16.12", + "@babel/preset-env": "^7.16.11", + "@babel/register": "^7.16.9", + "asar": "^3.2.0", + "dotenv": "^16.0.3", + "eslint": "^8.23.0", + "eslint-plugin-react": "^7.31.6", + "eslint-plugin-react-hooks": "^4.6.0", + "mocha": "^10.0.0", + "webpack": "^5.74.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=18", + "pnpm": ">=8" + } }