Skip to content

Commit

Permalink
fix(ci): ⚡ github action
Browse files Browse the repository at this point in the history
fix(ci): ⚡ github action
  • Loading branch information
leifermendez authored Dec 12, 2022
2 parents 091544a + 4142ca4 commit b827a0a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/provider/package.json
Original file line number Diff line number Diff line change
@@ -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": [],
Expand Down
27 changes: 25 additions & 2 deletions scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'], {
Expand All @@ -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)
}
}
Expand Down

0 comments on commit b827a0a

Please sign in to comment.