From 9d5aa7db5d58ce14cf5be5dcb120c8c47f9010e9 Mon Sep 17 00:00:00 2001 From: Leifer Mendez Date: Fri, 9 Dec 2022 14:12:38 +0100 Subject: [PATCH] ci(ci): :zap: update ci --- .github/workflows/ci.yml | 167 +++++++++++++++++++++++++++++++--- .github/workflows/relases.yml | 26 ------ scripts/release.js | 4 +- 3 files changed, 156 insertions(+), 41 deletions(-) delete mode 100644 .github/workflows/relases.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d6690f..af31d88 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,27 +1,168 @@ -name: Bot CI Test +name: BotWhatsapp CI on: push: - branches: [dev] + branches: + - main pull_request: - branches: [main] + branches: + - main + - dev jobs: - build: + ############ BUILD PACKAGE ############ + build-package: + name: Build Package runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [16.x] - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node-version }} + node-version: 16.x + cache: 'yarn' + registry-url: https://registry.npmjs.org/ + - run: corepack enable + - name: Install NPM Dependencies run: yarn install --immutable --network-timeout 300000 - - name: Test + + - name: Build Package + run: yarn build + + - name: Test Package + run: yarn test + + - name: Upload @bot-whatsapp/bot + uses: actions/upload-artifact@master + with: + name: dist-dev-bot + path: packages/bot/lib/ + if-no-files-found: error + + - name: Upload @bot-whatsapp/cli + uses: actions/upload-artifact@master + with: + name: dist-dev-cli + path: packages/cli/lib/ + if-no-files-found: error + + - name: Upload @bot-whatsapp/create-bot-whatsapp + uses: actions/upload-artifact@master + with: + name: dist-dev-create-bot-whatsapp + path: packages/create-bot-whatsapp/lib/ + if-no-files-found: error + + - name: Upload @bot-whatsapp/database + uses: actions/upload-artifact@master + with: + name: dist-dev-database + path: packages/database/lib/ + if-no-files-found: error + + - name: Upload @bot-whatsapp/database + uses: actions/upload-artifact@master + with: + name: dist-dev-provider + path: packages/provider/lib/ + if-no-files-found: error + + - name: Build Eslint rules + run: yarn lint:fix + + ############ RELEASE ############ + release: + name: Release + runs-on: ubuntu-latest + + needs: + - build-package + - test-unit + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - uses: pnpm/action-setup@v2.2.4 + with: + version: 7 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 16.x + cache: 'pnpm' + registry-url: https://registry.npmjs.org/ + + - run: corepack enable + + - name: Download Build Artifacts + uses: actions/download-artifact@v2 + + - name: Print Distribution Artifacts + run: tree builderio-qwik-distribution/ + + - name: Print Create Qwik CLI Artifacts + run: tree dist-dev-create-qwik/ + + - name: Move Distribution Artifacts + run: | + mkdir -p packages/qwik/dist/ + mv builderio-qwik-distribution/* packages/qwik/dist/ + mkdir -p packages/create-qwik/dist/ + mv dist-dev-create-qwik/* packages/create-qwik/dist/ + mkdir -p packages/eslint-plugin-qwik/dist/ + mv dist-dev-eslint-plugin-qwik/* packages/eslint-plugin-qwik/dist/ + + - name: Install NPM Dependencies + run: pnpm install --frozen-lockfile + + - name: Dry-Run Publish @builder.io/qwik + if: ${{ github.event_name != 'workflow_dispatch' }} + run: pnpm tsm scripts/index.ts --set-dist-tag="${{ github.event.inputs.disttag }}" --release --dry-run + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Publish @builder.io/qwik + if: ${{ github.event_name == 'workflow_dispatch' }} + run: pnpm tsm scripts/index.ts --set-dist-tag="${{ github.event.inputs.disttag }}" --release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Save artifacts + if: ${{ needs.changes.outputs.fullbuild == 'true' && github.event_name == 'push' }} + env: + API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} + run: pnpm run qwik-save-artifacts + + ############ UNIT TEST ############ + test-unit: + name: Unit Tests + runs-on: ubuntu-latest + needs: + - build-package + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 16.x + cache: 'yarn' + registry-url: https://registry.npmjs.org/ + + - run: corepack enable + + - name: Install NPM Dependencies + run: yarn install --immutable --network-timeout 300000 + + - name: Unit Tests run: yarn test diff --git a/.github/workflows/relases.yml b/.github/workflows/relases.yml deleted file mode 100644 index b21e385..0000000 --- a/.github/workflows/relases.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Bot Relases - -on: - release: - types: [released, published] -jobs: - build: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [16.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: corepack enable - - name: Install NPM Dependencies - run: yarn install --immutable --network-timeout 300000 - - name: Test - run: yarn test - - name: Build - run: yarn build diff --git a/scripts/release.js b/scripts/release.js index d0a9932..82059a7 100644 --- a/scripts/release.js +++ b/scripts/release.js @@ -1,6 +1,6 @@ const { writeFile, readFileSync } = require('fs') const { join } = require('path') -const { spawn, execFile } = require('node:child_process') +const { execFile } = require('node:child_process') const process = require('node:process') const util = require('node:util') @@ -77,7 +77,7 @@ const packRelease = async (packageName) => { } const publishRelease = async (packageName, latest = false) => { - const args = !latest ? ['--tag', 'next'] : ['--access', 'public'] + const args = !latest ? ['--tag', 'dev'] : ['--access', 'public'] const pkgJson = join(PATH_PACKAGES, packageName) const { stdout } = await cmd(NPM_COMMAND, ['publish'].concat(args), { stdio: 'inherit',