diff --git a/.github/workflows/releases-dev.yml b/.github/workflows/releases-dev.yml index 6f380a2..7848669 100644 --- a/.github/workflows/releases-dev.yml +++ b/.github/workflows/releases-dev.yml @@ -3,7 +3,7 @@ name: 🚀 (DEV) Liberando versiones on: push: branches: - - next-release + - release/next jobs: ############ RELEASE ############ diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index df211d4..2fd43fe 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -3,7 +3,7 @@ name: 🚀⚡ Liberando versiones on: push: branches: - - production-release + - release/production jobs: ############ RELEASE ############ release: diff --git a/package.json b/package.json index b15b835..7387dfc 100644 --- a/package.json +++ b/package.json @@ -97,5 +97,8 @@ "npm": "please-use-yarn", "yarn": ">=3" }, - "author": "Leifer Mendez " + "author": "Leifer Mendez ", + "dependencies": { + "@octokit/core": "^4.1.0" + } } diff --git a/packages/docs/src/components/widgets/Hero.tsx b/packages/docs/src/components/widgets/Hero.tsx index 4700421..0e7cc5e 100644 --- a/packages/docs/src/components/widgets/Hero.tsx +++ b/packages/docs/src/components/widgets/Hero.tsx @@ -47,13 +47,20 @@ export default component$(() => { npm create bot-whatsapp@latest - diff --git a/scripts/release.js b/scripts/release.js index 9dfcc62..e88e740 100644 --- a/scripts/release.js +++ b/scripts/release.js @@ -3,16 +3,50 @@ const { join } = require('path') const { execFile } = require('node:child_process') const process = require('node:process') const util = require('node:util') +const { Octokit } = require('@octokit/core') 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, NPM_TOKEN] = process.argv.slice(2) || [null] +const [PKG_ARG, PKG_ARG_VERSION, NPM_TOKEN, GITHUB_TOKEN] = process.argv.slice( + 2 +) || [null] const PATH_PACKAGES = join(__dirname, '..', `packages`) const cmd = util.promisify(execFile) +/** + * Publicar Release en Github + * @param {*} name + * @param {*} tag_name + * @param {*} auth + * @param {*} owner + * @param {*} repo + */ +const githubGithubRelease = async ( + name = '', + tag_name = '', + auth = '', + owner = 'codigoencasa', + repo = 'bot-whatsapp' +) => { + const octokit = new Octokit({ + auth, + }) + + await octokit.request(`POST /repos/${owner}/${repo}/releases`, { + owner, + repo, + tag_name, + name, + body: 'Description of the release', + draft: false, + prerelease: false, + generate_release_notes: true, + }) +} + /** * Create Token */ @@ -147,6 +181,7 @@ const publishRelease = async (packageName, latest = null) => { const main = async () => { if (PKG_ARG) { let EXIST_VERSION = true + const githubToken = GITHUB_TOKEN ? GITHUB_TOKEN.split('=').at(1) : null 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 @@ -161,6 +196,7 @@ const main = async () => { } await packRelease(pkgName) await publishRelease(pkgName, pkgNumber) + await githubGithubRelease(`v${pkgNumber}`, pkgNumber, githubToken) } } diff --git a/yarn.lock b/yarn.lock index 05e6737..cf802d5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1100,6 +1100,7 @@ __metadata: dependencies: "@commitlint/cli": ^17.3.0 "@commitlint/config-conventional": ^17.3.0 + "@octokit/core": ^4.1.0 "@rollup/plugin-commonjs": ^23.0.2 "@rollup/plugin-json": ^5.0.1 "@rollup/plugin-node-resolve": ^15.0.1