Skip to content

Commit

Permalink
ci: ⚡ add github release
Browse files Browse the repository at this point in the history
ci: ⚡ add github release
  • Loading branch information
leifermendez committed Jan 11, 2023
2 parents 2a416bf + af44ed1 commit ca97886
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/releases-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: 🚀 (DEV) Liberando versiones
on:
push:
branches:
- next-release
- release/next

jobs:
############ RELEASE ############
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: 🚀⚡ Liberando versiones
on:
push:
branches:
- production-release
- release/production
jobs:
############ RELEASE ############
release:
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,8 @@
"npm": "please-use-yarn",
"yarn": ">=3"
},
"author": "Leifer Mendez <leifer33@gmail.com>"
"author": "Leifer Mendez <leifer33@gmail.com>",
"dependencies": {
"@octokit/core": "^4.1.0"
}
}
9 changes: 8 additions & 1 deletion packages/docs/src/components/widgets/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,20 @@ export default component$(() => {
npm create bot-whatsapp@latest
</code>
</div>
<div class="flex w-full sm:w-auto">
<div class="flex w-full sm:w-auto gap-3">
<a
href="/docs"
class="btn bg-gray-50 dark:bg-transparent"
>
Ver documentación
</a>
<a
target={'_blank'}
href="https://youtu.be/DEIyGyJNGa8"
class="btn bg-gray-50 dark:bg-transparent"
>
Ver video
</a>
</div>
</div>
</div>
Expand Down
38 changes: 37 additions & 1 deletion scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
Expand All @@ -161,6 +196,7 @@ const main = async () => {
}
await packRelease(pkgName)
await publishRelease(pkgName, pkgNumber)
await githubGithubRelease(`v${pkgNumber}`, pkgNumber, githubToken)
}
}

Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ca97886

Please sign in to comment.