Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,9 @@ jobs:
npx lerna publish from-package --no-verify-access --yes
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Upload artifacts to Github release
run: |
node scripts/upload-to-release.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 0 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"typecheck": "tsc -b tsconfig.project.json -verbose"
},
"devDependencies": {
"@octokit/rest": "^17.8.0",
"@typescript-eslint/eslint-plugin": "^2.29.0",
"@typescript-eslint/parser": "^2.29.0",
"ava": "^3.8.0",
Expand All @@ -39,6 +40,7 @@
"npm-run-all": "^4.1.5",
"nyc": "^15.0.1",
"prettier": "^2.0.5",
"putasset": "^5.0.3",
"ts-node": "^8.9.1",
"tsconfig-paths": "^3.9.0",
"typescript": "^3.8.3"
Expand Down
4 changes: 3 additions & 1 deletion scripts/mv-artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ const { existsSync } = require('fs')
const { platform } = require('os')
const { join } = require('path')

const supporttedPlatforms = require('./platforms')

const MOVE_ALL = process.env.MOVE_TARGET === 'all'

const platforms = MOVE_ALL ? ['linux', 'darwin', 'win32'] : [platform()]
const platforms = MOVE_ALL ? supporttedPlatforms : [platform()]

const packages = ['crc32', 'jieba']

Expand Down
1 change: 1 addition & 0 deletions scripts/platforms.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = ['linux', 'darwin', 'win32']
65 changes: 65 additions & 0 deletions scripts/upload-to-release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
const { execSync } = require('child_process')
const { join } = require('path')
const { existsSync } = require('fs')
const chalk = require('chalk')
const putasset = require('putasset')
const { Octokit } = require('@octokit/rest')

const supporttedPlatforms = require('./platforms')

const headCommit = execSync('git log -1 --pretty=%B', {
encoding: 'utf8',
})

;(async () => {
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/')
const octokit = new Octokit({
auth: process.env.GITHUB_TOKEN,
})
const packages = headCommit
.split('\n')
.map((line) => line.trim())
.filter((line, index) => line.length && index)
.map((line) => line.substr(2))
.map(parseTag)
.filter((pkgInfo) => pkgInfo.isNativePackage)
for (const package of packages) {
await octokit.repos.createRelease({
owner,
repo,
tag_name: package.tag,
})
await Promise.all(
supporttedPlatforms.map(async (platform) => {
const binary = join(package.pkgDir, `${package.name}.${platform}.node`)
const downloadUrl = await putasset(process.env.GITHUB_TOKEN, {
owner,
repo,
tag: package.tag,
filename: binary,
})
console.info(`${chalk.green(binary)} upload success`)
console.info(`Download url: ${chalk.blueBright(downloadUrl)}`)
}),
)
}
})()

/**
* @param {string} tag
*/
function parseTag(tag) {
const [, packageWithVersion] = tag.split('/')
const [name, version] = packageWithVersion.split('@')
const pkgDir = join(__dirname, '..', 'packages', name)
const tomlFilePath = join(pkgDir, 'Cargo.toml')
const isNativePackage = existsSync(tomlFilePath)

return {
name,
version,
pkgDir,
tag,
isNativePackage,
}
}
94 changes: 91 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,18 @@
dependencies:
"@octokit/types" "^2.0.0"

"@octokit/core@^2.4.3":
version "2.5.0"
resolved "https://registry.yarnpkg.com/@octokit/core/-/core-2.5.0.tgz#4706258893a7ac6ab35d58d2fb9f2d2ba19a41a5"
integrity sha512-uvzmkemQrBgD8xuGbjhxzJN1darJk9L2cS+M99cHrDG2jlSVpxNJVhoV86cXdYBqdHCc9Z995uLCczaaHIYA6Q==
dependencies:
"@octokit/auth-token" "^2.4.0"
"@octokit/graphql" "^4.3.1"
"@octokit/request" "^5.4.0"
"@octokit/types" "^2.0.0"
before-after-hook "^2.1.0"
universal-user-agent "^5.0.0"

"@octokit/endpoint@^6.0.1":
version "6.0.1"
resolved "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.1.tgz#16d5c0e7a83e3a644d1ddbe8cded6c3d038d31d7"
Expand All @@ -1015,6 +1027,15 @@
is-plain-object "^3.0.0"
universal-user-agent "^5.0.0"

"@octokit/graphql@^4.3.1":
version "4.4.0"
resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-4.4.0.tgz#4540b48bbf796b837b311ba6ea5104760db530ca"
integrity sha512-Du3hAaSROQ8EatmYoSAJjzAz3t79t9Opj/WY1zUgxVUGfIKn0AEjg+hlOLscF6fv6i/4y/CeUvsWgIfwMkTccw==
dependencies:
"@octokit/request" "^5.3.0"
"@octokit/types" "^2.0.0"
universal-user-agent "^5.0.0"

"@octokit/plugin-enterprise-rest@^3.6.1":
version "3.6.2"
resolved "https://registry.npmjs.org/@octokit/plugin-enterprise-rest/-/plugin-enterprise-rest-3.6.2.tgz#74de25bef21e0182b4fa03a8678cd00a4e67e561"
Expand All @@ -1027,6 +1048,13 @@
dependencies:
"@octokit/types" "^2.0.1"

"@octokit/plugin-paginate-rest@^2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.2.0.tgz#9ae0c14c1b90ec0d96d2ef1b44706b4505a91cee"
integrity sha512-KoNxC3PLNar8UJwR+1VMQOw2IoOrrFdo5YOiDKnBhpVbKpw+zkBKNMNKwM44UWL25Vkn0Sl3nYIEGKY+gW5ebw==
dependencies:
"@octokit/types" "^2.12.1"

"@octokit/plugin-request-log@^1.0.0":
version "1.0.0"
resolved "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-1.0.0.tgz#eef87a431300f6148c39a7f75f8cfeb218b2547e"
Expand All @@ -1040,6 +1068,14 @@
"@octokit/types" "^2.0.1"
deprecation "^2.3.1"

"@octokit/plugin-rest-endpoint-methods@3.10.0":
version "3.10.0"
resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-3.10.0.tgz#47f780d69192e45f09f71ded76f0b121b40e2d48"
integrity sha512-Z2DBsdnkWKuVBVFiLoEUKP/82ylH4Ij5F1Mss106hnQYXTxDfCWAyHW+hJ6ophuHVJ9Flaaue3fYn4CggzkHTg==
dependencies:
"@octokit/types" "^2.14.0"
deprecation "^2.3.1"

"@octokit/request-error@^1.0.2":
version "1.2.1"
resolved "https://registry.npmjs.org/@octokit/request-error/-/request-error-1.2.1.tgz#ede0714c773f32347576c25649dc013ae6b31801"
Expand All @@ -1058,7 +1094,7 @@
deprecation "^2.0.0"
once "^1.4.0"

"@octokit/request@^5.2.0":
"@octokit/request@^5.2.0", "@octokit/request@^5.3.0", "@octokit/request@^5.4.0":
version "5.4.2"
resolved "https://registry.npmjs.org/@octokit/request/-/request-5.4.2.tgz#74f8e5bbd39dc738a1b127629791f8ad1b3193ee"
integrity sha512-zKdnGuQ2TQ2vFk9VU8awFT4+EYf92Z/v3OlzRaSh4RIP0H6cvW1BFPXq4XYvNez+TPQjqN+0uSkCYnMFFhcFrw==
Expand Down Expand Up @@ -1094,13 +1130,30 @@
once "^1.4.0"
universal-user-agent "^4.0.0"

"@octokit/rest@^17.1.3", "@octokit/rest@^17.8.0":
version "17.8.0"
resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-17.8.0.tgz#85da66a98d9f5dfadab079dbb15f6031bd7e5460"
integrity sha512-m2pdo9+DoEoqQ7wRXV1ihffhE1gbvoC20nvchphluEusbZI6Y9HyXABGiXL+mByy2uUMR2cgBDqBJQQ6bY8Uvg==
dependencies:
"@octokit/core" "^2.4.3"
"@octokit/plugin-paginate-rest" "^2.2.0"
"@octokit/plugin-request-log" "^1.0.0"
"@octokit/plugin-rest-endpoint-methods" "3.10.0"

"@octokit/types@^2.0.0", "@octokit/types@^2.0.1", "@octokit/types@^2.11.1":
version "2.12.1"
resolved "https://registry.npmjs.org/@octokit/types/-/types-2.12.1.tgz#4a26b4a85ec121043d3b0745b5798f9d8fd968ca"
integrity sha512-LRLR1tjbcCfAmUElvTmMvLEzstpx6Xt/aQVTg2xvd+kHA2Ekp1eWl5t+gU7bcwjXHYEAzh4hH4WH+kS3vh+wRw==
dependencies:
"@types/node" ">= 8"

"@octokit/types@^2.12.1", "@octokit/types@^2.14.0":
version "2.15.0"
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-2.15.0.tgz#b2070520207727bc6ab3a9caa1e4f60b0434bfa8"
integrity sha512-0mnpenB8rLhBVu8VUklp38gWi+EatjvcEcLWcdProMKauSaQWWepOAybZ714sOGsEyhXPlIcHICggn8HUsCXVw==
dependencies:
"@types/node" ">= 8"

"@samverschueren/stream-to-observable@^0.3.0":
version "0.3.0"
resolved "https://registry.npmjs.org/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz#ecdf48d532c58ea477acfcab80348424f8d0662f"
Expand Down Expand Up @@ -1673,7 +1726,7 @@ bcrypt-pbkdf@^1.0.0:
dependencies:
tweetnacl "^0.14.3"

before-after-hook@^2.0.0:
before-after-hook@^2.0.0, before-after-hook@^2.1.0:
version "2.1.0"
resolved "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.1.0.tgz#b6c03487f44e24200dd30ca5e6a1979c5d2fb635"
integrity sha512-IWIbu7pMqyw3EAJHzzHbWa85b6oud/yfKYg5rqB5hNE8CeMi3nX+2C2sj0HswfblST86hpVEOAb9x34NZd6P7A==
Expand Down Expand Up @@ -1941,6 +1994,11 @@ chardet@^0.7.0:
resolved "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e"
integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==

checkup@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/checkup/-/checkup-1.3.0.tgz#d3800276fea5d0f247ffc951be78c8b02f8e0d76"
integrity sha1-04ACdv6l0PJH/8lRvnjIsC+ODXY=

chokidar@^3.4.0:
version "3.4.0"
resolved "https://registry.npmjs.org/chokidar/-/chokidar-3.4.0.tgz#b30611423ce376357c765b9b8f904b9fba3c0be8"
Expand Down Expand Up @@ -4967,7 +5025,7 @@ mime-db@1.44.0:
resolved "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz#fa11c5eb0aca1334b4233cb4d52f10c5a6272f92"
integrity sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==

mime-types@^2.1.12, mime-types@~2.1.19:
mime-types@^2.1.12, mime-types@^2.1.21, mime-types@~2.1.19:
version "2.1.27"
resolved "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz#47949f98e279ea53119f5722e0f34e529bec009f"
integrity sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==
Expand Down Expand Up @@ -6067,6 +6125,19 @@ pupa@^2.0.1:
dependencies:
escape-goat "^2.0.0"

putasset@^5.0.3:
version "5.0.3"
resolved "https://registry.yarnpkg.com/putasset/-/putasset-5.0.3.tgz#2fa82a8fc5e2333869df8ffb0e1f8618b1c87b9b"
integrity sha512-LGRp0SLOC4PDP/BawMaG3/hw6iKgQPRXcBF7WIzx2XTYwHVk2sS3gpvZqz6bf9GhKMal2phs+DF7J6eIAXEL4w==
dependencies:
"@octokit/rest" "^17.1.3"
checkup "^1.3.0"
mime-types "^2.1.21"
readjson "^2.0.1"
try-catch "^3.0.0"
try-to-catch "^3.0.0"
yargs-parser "^18.1.1"

q@^1.5.1:
version "1.5.1"
resolved "https://registry.npmjs.org/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7"
Expand Down Expand Up @@ -6227,6 +6298,13 @@ readdirp@~3.4.0:
dependencies:
picomatch "^2.2.1"

readjson@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/readjson/-/readjson-2.0.1.tgz#1822964dfd0bc0b49c8f983c192a9dd5309eb9e1"
integrity sha512-6WuJWYFKx9IVT0zogHlyRC6p+RttAC457garckmGQ8qKICT/xLVrpmvlwp8nTwPHzopbdXIJ593Df8AErIbgeQ==
dependencies:
try-catch "^3.0.0"

redent@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde"
Expand Down Expand Up @@ -7268,6 +7346,16 @@ trim-off-newlines@^1.0.0, trim-off-newlines@^1.0.1:
resolved "https://registry.npmjs.org/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz#9f9ba9d9efa8764c387698bcbfeb2c848f11adb3"
integrity sha1-n5up2e+odkw4dpi8v+sshI8RrbM=

try-catch@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/try-catch/-/try-catch-3.0.0.tgz#7996d8b89895e2e8ae62cbdbeb4fe17470f8131b"
integrity sha512-3uAqUnoemzca1ENvZ72EVimR+E8lqBbzwZ9v4CEbLjkaV3Q+FtdmPUt7jRtoSoTiYjyIMxEkf6YgUpe/voJ1ng==

try-to-catch@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/try-to-catch/-/try-to-catch-3.0.0.tgz#a1903b44d13d5124c54d14a461d22ec1f52ea14b"
integrity sha512-eIm6ZXwR35jVF8By/HdbbkcaCDTBI5PpCPkejRKrYp0jyf/DbCCcRhHD7/O9jtFI3ewsqo9WctFEiJTS6i+CQA==

ts-node@^8.9.1:
version "8.10.1"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.10.1.tgz#77da0366ff8afbe733596361d2df9a60fc9c9bd3"
Expand Down