From b465de55a0e511213d1a7760a74efa102172c85e Mon Sep 17 00:00:00 2001 From: Leifer Mendez Date: Mon, 12 Dec 2022 11:02:50 +0100 Subject: [PATCH 1/6] fix(ci): :zap: github action --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6d2725..6701047 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,7 +81,7 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} message: 'ci(version): :zap: automatic - ${date} updated versions every packages' - branch: 'dev' + branch: 'next-release' ############ UNIT TEST ############ test-unit: From 9ddf144244cd6877e7d26f576387814459f2befb Mon Sep 17 00:00:00 2001 From: Leifer Mendez Date: Mon, 12 Dec 2022 11:06:25 +0100 Subject: [PATCH 2/6] fix(ci): :zap: github action --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6701047..afd808d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,6 +4,7 @@ on: pull_request: branches: - dev + - next-release jobs: ############ BUILD PACKAGE ############ @@ -38,6 +39,7 @@ jobs: release: name: Release runs-on: ubuntu-latest + if: github.head_ref == 'next-release' needs: - build-package steps: From dfced8c594e9175c81e837af359631ba055b7e1a Mon Sep 17 00:00:00 2001 From: Leifer Mendez Date: Mon, 12 Dec 2022 11:59:09 +0100 Subject: [PATCH 3/6] fix(ci): :zap: github action --- .github/workflows/ci.yml | 51 ------------------------------- .github/workflows/releases.yml | 56 ++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 51 deletions(-) create mode 100644 .github/workflows/releases.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index afd808d..5309ac9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,6 @@ on: pull_request: branches: - dev - - next-release jobs: ############ BUILD PACKAGE ############ @@ -35,56 +34,6 @@ jobs: - name: Build Eslint rules run: yarn lint:fix - ############ RELEASE ############ - release: - name: Release - runs-on: ubuntu-latest - if: github.head_ref == 'next-release' - needs: - - build-package - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - ref: ${{ github.head_ref }} - - - 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: Build Package - run: yarn build - - - name: Release @bot-whatsapp/bot - run: yarn node ./scripts/release.js --name=bot --version= --token="${{ secrets.NPM_TOKEN }}" - - - name: Release @bot-whatsapp/cli - run: yarn node ./scripts/release.js --name=cli --version= --token="${{ secrets.NPM_TOKEN }}" - - - name: Release @bot-whatsapp/create-bot-whatsapp - run: yarn node ./scripts/release.js --name=create-bot-whatsapp --version= --token="${{ secrets.NPM_TOKEN }}" - - - name: Release @bot-whatsapp/database - run: yarn node ./scripts/release.js --name=database --version= --token="${{ secrets.NPM_TOKEN }}" - - - name: Release @bot-whatsapp/provider - run: yarn node ./scripts/release.js --name=provider --version= --token="${{ secrets.NPM_TOKEN }}" - - - name: Commit Versioning & Push changes - uses: actions-js/push@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - message: 'ci(version): :zap: automatic - ${date} updated versions every packages' - branch: 'next-release' - ############ UNIT TEST ############ test-unit: name: Unit Tests diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml new file mode 100644 index 0000000..f56b98b --- /dev/null +++ b/.github/workflows/releases.yml @@ -0,0 +1,56 @@ +name: BotWhatsapp CI + +on: + pull_request: + branches: + - next-release + +jobs: + ############ RELEASE ############ + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + persist-credentials: false + fetch-depth: 0 + + - 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: Build Package + run: yarn build + + - name: Release @bot-whatsapp/bot + run: yarn node ./scripts/release.js --name=bot --version= --token="${{ secrets.NPM_TOKEN }}" + + - name: Release @bot-whatsapp/cli + run: yarn node ./scripts/release.js --name=cli --version= --token="${{ secrets.NPM_TOKEN }}" + + - name: Release @bot-whatsapp/create-bot-whatsapp + run: yarn node ./scripts/release.js --name=create-bot-whatsapp --version= --token="${{ secrets.NPM_TOKEN }}" + + - name: Release @bot-whatsapp/database + run: yarn node ./scripts/release.js --name=database --version= --token="${{ secrets.NPM_TOKEN }}" + + - name: Release @bot-whatsapp/provider + run: yarn node ./scripts/release.js --name=provider --version= --token="${{ secrets.NPM_TOKEN }}" + + - name: Commit Versioning & Push changes + uses: actions-js/push@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + message: 'ci(version): :zap: automatic - ${date} updated versions every packages' + branch: 'next-release' From 2ce342a0cb15019d5084ca06dc30e342b030ea10 Mon Sep 17 00:00:00 2001 From: Leifer Mendez Date: Mon, 12 Dec 2022 12:10:15 +0100 Subject: [PATCH 4/6] fix(ci): :zap: github action --- packages/bot/package.json | 2 +- packages/cli/package.json | 2 +- packages/create-bot-whatsapp/package.json | 2 +- packages/database/package.json | 2 +- packages/provider/package.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/bot/package.json b/packages/bot/package.json index c3c1819..5e48152 100644 --- a/packages/bot/package.json +++ b/packages/bot/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/bot", - "version": "0.0.13-alpha.0", + "version": "0.0.15-alpha.0", "description": "", "main": "./lib/bundle.bot.cjs", "scripts": { diff --git a/packages/cli/package.json b/packages/cli/package.json index 274df2d..c01f647 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/cli", - "version": "0.0.20-alpha.0", + "version": "0.0.22-alpha.0", "description": "", "main": "index.js", "devDependencies": { diff --git a/packages/create-bot-whatsapp/package.json b/packages/create-bot-whatsapp/package.json index 4b54827..8c16fb0 100644 --- a/packages/create-bot-whatsapp/package.json +++ b/packages/create-bot-whatsapp/package.json @@ -1,6 +1,6 @@ { "name": "create-bot-whatsapp", - "version": "0.0.26-alpha.0", + "version": "0.0.28-alpha.0", "description": "", "main": "./lib/bundle.create-bot-whatsapp.cjs", "files": [ diff --git a/packages/database/package.json b/packages/database/package.json index 98786ba..fc31820 100644 --- a/packages/database/package.json +++ b/packages/database/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/database", - "version": "0.0.12-alpha.0", + "version": "0.0.14-alpha.0", "description": "Esto es el conector a mysql, pg, mongo", "main": "./lib/mock/index.cjs", "keywords": [], diff --git a/packages/provider/package.json b/packages/provider/package.json index 7c99889..4874821 100644 --- a/packages/provider/package.json +++ b/packages/provider/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/provider", - "version": "0.0.18-alpha.0", + "version": "0.0.20-alpha.0", "description": "Esto es el conector a Twilio, Meta, etc...", "main": "./lib/mock/index.cjs", "keywords": [], From 4142ca4fd552e7005f3b1397a76b90a2e574d19d Mon Sep 17 00:00:00 2001 From: Leifer Mendez Date: Mon, 12 Dec 2022 14:36:32 +0100 Subject: [PATCH 5/6] fix(ci): :zap: github action --- packages/provider/package.json | 2 +- scripts/release.js | 27 +++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/packages/provider/package.json b/packages/provider/package.json index 4874821..bb1f21d 100644 --- a/packages/provider/package.json +++ b/packages/provider/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/provider", - "version": "0.0.20-alpha.0", + "version": "0.0.19-alpha.0", "description": "Esto es el conector a Twilio, Meta, etc...", "main": "./lib/mock/index.cjs", "keywords": [], diff --git a/scripts/release.js b/scripts/release.js index d72522e..9fbc820 100644 --- a/scripts/release.js +++ b/scripts/release.js @@ -82,6 +82,24 @@ const updateVersion = async (packageName = null, number = null) => { return { version: newVersion } } +const checkExistVersion = async (packageName = null, version = null) => { + try { + const pkgJson = join(PATH_PACKAGES, packageName) + const pkgJsonObject = readPackage(packageName) + const { stdout } = await cmd( + NPM_COMMAND, + ['view', `${pkgJsonObject.name}@${version}`], + { + stdio: 'inherit', + cwd: pkgJson, + } + ) + return true + } catch (e) { + return false + } +} + const packRelease = async (packageName) => { const pkgJson = join(PATH_PACKAGES, packageName) const { stdout } = await cmd(NPM_COMMAND, ['pack'], { @@ -108,14 +126,19 @@ const publishRelease = async (packageName, latest = null) => { const main = async () => { if (PKG_ARG) { + let EXIST_VERSION = true const tokenNpm = NPM_TOKEN ? NPM_TOKEN.split('=').at(1) : null const pkgName = PKG_ARG ? PKG_ARG.split('=').at(1) : null const pkgNumber = PKG_ARG_VERSION ? PKG_ARG_VERSION.split('=').at(1) : null if (tokenNpm) await npmToken(tokenNpm) - await updateVersion(pkgName, pkgNumber) - await packRelease(pkgName) + + while (EXIST_VERSION) { + const { version } = await updateVersion(pkgName, pkgNumber) + EXIST_VERSION = await checkExistVersion(pkgName, version) + console.log(`[${pkgName} - Version]: `, version, EXIST_VERSION) + } await publishRelease(pkgName, pkgNumber) } } From 7790391b5022b578d9ed4833a554d3d4c595b28b Mon Sep 17 00:00:00 2001 From: Leifer Mendez Date: Mon, 12 Dec 2022 14:43:38 +0100 Subject: [PATCH 6/6] ci(ci): :sparkles: releases action --- .github/workflows/ci.yml | 2 +- .github/workflows/releases.yml | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5309ac9..aa05560 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: BotWhatsapp CI +name: BotWhatsapp Build-Test on: pull_request: diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index f56b98b..f1f74dd 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -1,7 +1,8 @@ -name: BotWhatsapp CI +name: BotWhatsapp Releases on: pull_request: + types: [closed] branches: - next-release @@ -10,6 +11,7 @@ jobs: release: name: Release runs-on: ubuntu-latest + if: github.event.pull_request.merged == 'true' steps: - name: Checkout uses: actions/checkout@v3