ci: add github release

ci:  add github release
This commit is contained in:
Leifer Mendez
2023-01-11 13:30:38 +01:00
committed by GitHub
6 changed files with 52 additions and 5 deletions

View File

@@ -3,7 +3,7 @@ name: 🚀 (DEV) Liberando versiones
on: on:
push: push:
branches: branches:
- next-release - release/next
jobs: jobs:
############ RELEASE ############ ############ RELEASE ############

View File

@@ -3,7 +3,7 @@ name: 🚀⚡ Liberando versiones
on: on:
push: push:
branches: branches:
- production-release - release/production
jobs: jobs:
############ RELEASE ############ ############ RELEASE ############
release: release:

View File

@@ -97,5 +97,8 @@
"npm": "please-use-yarn", "npm": "please-use-yarn",
"yarn": ">=3" "yarn": ">=3"
}, },
"author": "Leifer Mendez <leifer33@gmail.com>" "author": "Leifer Mendez <leifer33@gmail.com>",
"dependencies": {
"@octokit/core": "^4.1.0"
}
} }

View File

@@ -47,13 +47,20 @@ export default component$(() => {
npm create bot-whatsapp@latest npm create bot-whatsapp@latest
</code> </code>
</div> </div>
<div class="flex w-full sm:w-auto"> <div class="flex w-full sm:w-auto gap-3">
<a <a
href="/docs" href="/docs"
class="btn bg-gray-50 dark:bg-transparent" class="btn bg-gray-50 dark:bg-transparent"
> >
Ver documentación Ver documentación
</a> </a>
<a
target={'_blank'}
href="https://youtu.be/DEIyGyJNGa8"
class="btn bg-gray-50 dark:bg-transparent"
>
Ver video
</a>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -3,16 +3,50 @@ const { join } = require('path')
const { execFile } = require('node:child_process') const { execFile } = require('node:child_process')
const process = require('node:process') const process = require('node:process')
const util = require('node:util') const util = require('node:util')
const { Octokit } = require('@octokit/core')
const OS_ENVIROMENT_WIN = process.platform.includes('win32') const OS_ENVIROMENT_WIN = process.platform.includes('win32')
const semver = require('semver') const semver = require('semver')
const NPM_COMMAND = OS_ENVIROMENT_WIN ? 'npm.cmd' : 'npm' 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 PATH_PACKAGES = join(__dirname, '..', `packages`)
const cmd = util.promisify(execFile) 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 * Create Token
*/ */
@@ -147,6 +181,7 @@ const publishRelease = async (packageName, latest = null) => {
const main = async () => { const main = async () => {
if (PKG_ARG) { if (PKG_ARG) {
let EXIST_VERSION = true 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 tokenNpm = NPM_TOKEN ? NPM_TOKEN.split('=').at(1) : null
const pkgName = PKG_ARG ? PKG_ARG.split('=').at(1) : null const pkgName = PKG_ARG ? PKG_ARG.split('=').at(1) : null
const pkgNumber = PKG_ARG_VERSION const pkgNumber = PKG_ARG_VERSION
@@ -161,6 +196,7 @@ const main = async () => {
} }
await packRelease(pkgName) await packRelease(pkgName)
await publishRelease(pkgName, pkgNumber) await publishRelease(pkgName, pkgNumber)
await githubGithubRelease(`v${pkgNumber}`, pkgNumber, githubToken)
} }
} }

View File

@@ -1100,6 +1100,7 @@ __metadata:
dependencies: dependencies:
"@commitlint/cli": ^17.3.0 "@commitlint/cli": ^17.3.0
"@commitlint/config-conventional": ^17.3.0 "@commitlint/config-conventional": ^17.3.0
"@octokit/core": ^4.1.0
"@rollup/plugin-commonjs": ^23.0.2 "@rollup/plugin-commonjs": ^23.0.2
"@rollup/plugin-json": ^5.0.1 "@rollup/plugin-json": ^5.0.1
"@rollup/plugin-node-resolve": ^15.0.1 "@rollup/plugin-node-resolve": ^15.0.1