From 2eda85ac6972a95003cb6f7a3d59012017fea82a Mon Sep 17 00:00:00 2001 From: Apteryx Date: Mon, 1 Jul 2024 03:59:26 +1200 Subject: [PATCH] Update github workflows --- .github/workflows/continuous-delivery.yml | 85 -------------------- .github/workflows/continuous-integration.yml | 64 ++++++++++----- 2 files changed, 44 insertions(+), 105 deletions(-) delete mode 100644 .github/workflows/continuous-delivery.yml diff --git a/.github/workflows/continuous-delivery.yml b/.github/workflows/continuous-delivery.yml deleted file mode 100644 index 39f1fe4..0000000 --- a/.github/workflows/continuous-delivery.yml +++ /dev/null @@ -1,85 +0,0 @@ -name: Continuous Delivery - -on: - workflow_dispatch: - inputs: - pull_request: - description: The number of the PR that is being deployed. - required: false - branch: - description: The branch that is being deployed. - required: false - -jobs: - integration: - uses: ./.github/workflows/continuous-integration.yml - - publish: - name: Publish - needs: integration - runs-on: ubuntu-latest - steps: - - name: Checkout project - uses: actions/checkout@v3 - with: - fetch-depth: 0 - repository: ${{ github.event.inputs.repository || github.repository }} - ref: ${{ github.event.inputs.branch || 'main' }} - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: 18 - registry-url: 'https://registry.npmjs.org' - cache: 'yarn' - - - name: Cache dependencies - uses: actions/cache@v3 - with: - path: ~/.yarn - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - - - name: Install dependencies - run: yarn install - - - name: Determine tag - id: determine_tag - run: | - # Dispatch a pull request - if [[ ${{ github.event.inputs.pull_request != '' }} == true ]] - then - NUMBER=${{ github.event.inputs.pull_request }} - echo "TAG=pr-${NUMBER}" >> $GITHUB_OUTPUT - - # Push or regular dispatch - else - echo "TAG=next" >> $GITHUB_OUTPUT - fi - - - name: Publish to NPM - if: steps.determine_tag.outputs.TAG != '' - run: | - TAG=${{ steps.determine_tag.outputs.TAG }} - HEAD="$(git rev-parse --short HEAD)" - - for PACKAGE in packages/* - do - if [[ $(git diff HEAD~1 --name-only $PACKAGE/) ]] - then - pushd $PACKAGE - - yarn lint - yarn build - - yarn version patch - VERSION=$(node -p "require('./package.json').version") - IDENTIFIER="${VERSION}-${TAG}.${HEAD}" - node -e "const fs=require('fs');const package=require('./package.json');package.version='${IDENTIFIER}';fs.writeFileSync('./package.json',JSON.stringify(package, null, 4));" - - npm publish --tag $TAG - - popd - fi - done - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index c6f4200..7c2beda 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -11,49 +11,73 @@ jobs: name: Linting runs-on: ubuntu-latest steps: - - name: Checkout project + - name: Checkout uses: actions/checkout@v3 - - name: Setup Node.js + - name: Install Node.js uses: actions/setup-node@v3 with: node-version: 18 - cache: 'yarn' - - name: Cache dependencies - uses: actions/cache@v3 + - uses: pnpm/action-setup@v3 + name: Install pnpm with: - path: ~/.yarn - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + version: 8 + run_install: false + + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install dependencies - run: yarn install + run: pnpm install - - name: Run ESLint - run: yarn lint + - name: Run Linter + run: pnpm lint build: name: Building needs: lint runs-on: ubuntu-latest steps: - - name: Checkout project + - name: Checkout uses: actions/checkout@v3 - - name: Setup Node.js + - name: Install Node.js uses: actions/setup-node@v3 with: node-version: 18 - cache: 'yarn' - - name: Cache dependencies - uses: actions/cache@v3 + - uses: pnpm/action-setup@v3 + name: Install pnpm + with: + version: 8 + run_install: false + + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v3 + name: Setup pnpm cache with: - path: ~/.yarn - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install dependencies - run: yarn install + run: pnpm install - - name: Compile code - run: yarn build + - name: Build project + run: pnpm build