mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-17 19:26:23 +00:00
ci(ci): ⚡ update ci
ci(ci): ⚡ update ci
This commit is contained in:
107
.github/workflows/ci.yml
vendored
107
.github/workflows/ci.yml
vendored
@@ -14,6 +14,8 @@ jobs:
|
||||
build-package:
|
||||
name: Build Package
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- test-unit
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
@@ -33,44 +35,6 @@ jobs:
|
||||
- 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
|
||||
|
||||
@@ -78,76 +42,49 @@ jobs:
|
||||
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'
|
||||
cache: 'yarn'
|
||||
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
|
||||
run: yarn install --immutable --network-timeout 300000
|
||||
|
||||
- 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: Build Package
|
||||
run: yarn build
|
||||
|
||||
- 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: Release @bot-whatsapp/bot
|
||||
run: yarn node ./scripts/release.js --name=bot --version= --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
|
||||
- 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/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 }}"
|
||||
|
||||
############ UNIT TEST ############
|
||||
test-unit:
|
||||
name: Unit Tests
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- build-package
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -30,4 +30,5 @@ tmp/
|
||||
example-app*/
|
||||
qr.svg
|
||||
package-lock.json
|
||||
yarn-error.log
|
||||
yarn-error.log
|
||||
.npmrc
|
||||
@@ -11,12 +11,13 @@
|
||||
"bot:rollup": "rollup --config ./packages/bot/rollup-bot.config.js",
|
||||
"provider:rollup": "rollup --config ./packages/provider/rollup-provider.config.js ",
|
||||
"database:rollup": "rollup --config ./packages/database/rollup-database.config.js",
|
||||
"create-bot-whatsapp:rollup": "rollup --config ./packages/create-bot-whatsapp/rollup-create.config.js",
|
||||
"format:check": "prettier --check ./packages",
|
||||
"format:write": "prettier --write ./packages",
|
||||
"fmt.staged": "pretty-quick --staged",
|
||||
"lint:check": "eslint ./packages",
|
||||
"lint:fix": "eslint --fix ./packages",
|
||||
"build": "yarn run cli:rollup && yarn run bot:rollup && yarn run provider:rollup && yarn run database:rollup",
|
||||
"build": "yarn run cli:rollup && yarn run bot:rollup && yarn run provider:rollup && yarn run database:rollup && yarn run create-bot-whatsapp:rollup",
|
||||
"copy.lib": "node ./scripts/move.js",
|
||||
"test.unit": "node ./node_modules/uvu/bin.js packages test",
|
||||
"test.coverage": "node ./node_modules/c8/bin/c8.js npm run test.unit",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@bot-whatsapp/provider",
|
||||
"version": "0.0.2-alpha.0",
|
||||
"version": "0.0.7-alpha.0",
|
||||
"description": "Esto es el conector a Twilio, Meta, etc...",
|
||||
"main": "./lib/mock/index.cjs",
|
||||
"keywords": [],
|
||||
|
||||
@@ -8,11 +8,26 @@ const OS_ENVIROMENT_WIN = process.platform.includes('win32')
|
||||
const semver = require('semver')
|
||||
|
||||
const NPM_COMMAND = OS_ENVIROMENT_WIN ? 'npm.cmd' : 'npm'
|
||||
const [PKG_ARG, PKG_ARG_VERSION] = process.argv.slice(2) || [null]
|
||||
const [PKG_ARG, PKG_ARG_VERSION, NPM_TOKEN] = process.argv.slice(2) || [null]
|
||||
const PATH_PACKAGES = join(__dirname, '..', `packages`)
|
||||
|
||||
const cmd = util.promisify(execFile)
|
||||
|
||||
/**
|
||||
* Create Token
|
||||
*/
|
||||
const npmToken = (token = null) =>
|
||||
new Promise((resolve, reject) => {
|
||||
writeFile(
|
||||
`${process.cwd()}/.npmrc`,
|
||||
`//registry.npmjs.org/:_authToken=${token}`,
|
||||
(error) => {
|
||||
if (error) reject(error)
|
||||
resolve()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
/**
|
||||
* Leer package json
|
||||
* @param {*} packageName
|
||||
@@ -76,7 +91,7 @@ const packRelease = async (packageName) => {
|
||||
return stdout
|
||||
}
|
||||
|
||||
const publishRelease = async (packageName, latest = false) => {
|
||||
const publishRelease = async (packageName, latest = null) => {
|
||||
const args = !latest ? ['--tag', 'dev'] : ['--access', 'public']
|
||||
const pkgJson = join(PATH_PACKAGES, packageName)
|
||||
const { stdout } = await cmd(NPM_COMMAND, ['publish'].concat(args), {
|
||||
@@ -93,13 +108,15 @@ const publishRelease = async (packageName, latest = false) => {
|
||||
|
||||
const main = async () => {
|
||||
if (PKG_ARG) {
|
||||
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)
|
||||
await publishRelease(pkgName)
|
||||
await publishRelease(pkgName, pkgNumber)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user