Skip to content

Commit

Permalink
ci: update octokit (#854)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn authored Jul 4, 2024
1 parent 3d60556 commit 3c9d1bb
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 117 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Download skia binary
run: |
git config --global --add safe.directory $(pwd)
node ./scripts/release-skia-binary.js --download
node ./scripts/release-skia-binary.mjs --download
- name: 'Lint JS/TS'
run: yarn lint
Expand Down Expand Up @@ -204,7 +204,7 @@ jobs:
if: ${{ matrix.settings.setup }}

- name: Download skia binary
run: node ./scripts/release-skia-binary.js --download --target=${{ matrix.settings.downloadTarget }}
run: node ./scripts/release-skia-binary.mjs --download --target=${{ matrix.settings.downloadTarget }}

- name: 'Build'
if: ${{ !matrix.settings.docker }}
Expand Down Expand Up @@ -282,7 +282,7 @@ jobs:

- name: Download icudtl.dat
if: matrix.settings.host == 'windows-latest'
run: node ./scripts/release-skia-binary.js --download-icu
run: node ./scripts/release-skia-binary.mjs --download-icu

- name: Test bindings
run: yarn test:ci
Expand Down Expand Up @@ -599,7 +599,7 @@ jobs:
run: brew install nasm llvm

- name: Download skia binary
run: node ./scripts/release-skia-binary.js --download
run: node ./scripts/release-skia-binary.mjs --download

- name: Test
run: |
Expand Down Expand Up @@ -636,7 +636,7 @@ jobs:
- name: Download skia binary
run: |
git config --global --add safe.directory $(pwd)
node ./scripts/release-skia-binary.js --download
node ./scripts/release-skia-binary.mjs --download
- name: 'Build'
run: yarn build
Expand Down Expand Up @@ -697,7 +697,7 @@ jobs:
run: yarn artifacts

- name: Download ICU for Windows
run: node ./scripts/release-skia-binary.js --download-icu
run: node ./scripts/release-skia-binary.mjs --download-icu

- name: List packages
run: ls -R ./npm
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/skia.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
run: yarn install --immutable --mode=skip-build

- name: Upload release
run: node ./scripts/release-skia-binary.js --upload
run: node ./scripts/release-skia-binary.mjs --upload
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -144,7 +144,7 @@ jobs:
run: yarn install --immutable --mode=skip-build

- name: Upload release
run: node ./scripts/release-skia-binary.js --upload --target=aarch64-apple-darwin
run: node ./scripts/release-skia-binary.mjs --upload --target=aarch64-apple-darwin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down Expand Up @@ -184,7 +184,7 @@ jobs:
run: yarn install --immutable --mode=skip-build

- name: Upload release
run: node ./scripts/release-skia-binary.js --upload --target=x86_64-unknown-linux-musl
run: node ./scripts/release-skia-binary.mjs --upload --target=x86_64-unknown-linux-musl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down Expand Up @@ -224,7 +224,7 @@ jobs:
run: yarn install --immutable --mode=skip-build

- name: Upload release
run: node ./scripts/release-skia-binary.js --upload --target=aarch64-unknown-linux-gnu
run: node ./scripts/release-skia-binary.mjs --upload --target=aarch64-unknown-linux-gnu
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down Expand Up @@ -264,7 +264,7 @@ jobs:
run: yarn install --immutable --mode=skip-build

- name: Upload release
run: node ./scripts/release-skia-binary.js --upload --target=aarch64-unknown-linux-musl
run: node ./scripts/release-skia-binary.mjs --upload --target=aarch64-unknown-linux-musl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down Expand Up @@ -325,7 +325,7 @@ jobs:
run: yarn install --immutable --mode=skip-build

- name: Upload release
run: node ./scripts/release-skia-binary.js --upload --target=armv7-unknown-linux-gnueabihf
run: node ./scripts/release-skia-binary.mjs --upload --target=armv7-unknown-linux-gnueabihf
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down Expand Up @@ -362,6 +362,6 @@ jobs:
run: yarn install --immutable --mode=skip-build

- name: Upload release
run: node ./scripts/release-skia-binary.js --upload --target=aarch64-linux-android
run: node ./scripts/release-skia-binary.mjs --upload --target=aarch64-linux-android
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ $ cd canvas

# Download Skia binaries:
# It will pull the binaries match the git hash in `./skia` submodule
$ node scripts/release-skia-binary.js --download
$ node scripts/release-skia-binary.mjs --download

# Install NPM packages, build the Node.js addon:
$ yarn install --ignore-scripts
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ $ cd canvas

# Download Skia binaries:
# It will pull the binaries match the git hash in `./skia` submodule
$ node scripts/release-skia-binary.js --download
$ node scripts/release-skia-binary.mjs --download

# Install NPM packages, build the Node.js addon:
$ npm install -g yarn
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"@jimp/jpeg": "^0.22.10",
"@jimp/png": "^0.22.10",
"@napi-rs/cli": "^2.18.0",
"@octokit/rest": "^20.0.2",
"@octokit/rest": "^21.0.0",
"@swc-node/register": "^1.8.0",
"@swc/core": "^1.4.0",
"@taplo/cli": "^0.7.0",
Expand Down
2 changes: 1 addition & 1 deletion scripts/__test__/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sep } from 'path'
import { sep } from 'node:path'

import test from 'ava'

Expand Down
20 changes: 10 additions & 10 deletions scripts/release-skia-binary.js → scripts/release-skia-binary.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const { execSync } = require('child_process')
const { promises: fs, copyFileSync, statSync } = require('fs')
const { platform } = require('os')
const { parse, join } = require('path')
import { execSync } from 'node:child_process'
import { promises as fs, copyFileSync, statSync } from 'node:fs'
import { platform } from 'node:os'
import { parse, join } from 'node:path'

const { Octokit } = require('@octokit/rest')
const { green } = require('colorette')
import { Octokit } from '@octokit/rest'
import { green } from 'colorette'

const { libPath, TAG, OWNER, REPO } = require('./utils')
import { libPath, TAG, OWNER, REPO, dirname } from './utils.mjs'

const PLATFORM_NAME = platform()

Expand Down Expand Up @@ -97,7 +97,7 @@ async function upload() {
})
}
console.info(green(`Uploading [${ICU_DAT}] to github release: [${TAG}]`))
const icuDataPath = join(__dirname, '..', 'skia', 'out', 'Static', ICU_DAT)
const icuDataPath = join(dirname, '..', 'skia', 'out', 'Static', ICU_DAT)
await CLIENT.repos.uploadReleaseAsset({
owner: OWNER,
repo: REPO,
Expand Down Expand Up @@ -126,7 +126,7 @@ async function download() {
}
if (PLATFORM_NAME === 'win32') {
await downloadIcu()
await fs.copyFile(join(__dirname, '..', ICU_DAT), join(__dirname, '..', 'npm', 'win32-x64-msvc', ICU_DAT))
await fs.copyFile(join(dirname, '..', ICU_DAT), join(dirname, '..', 'npm', 'win32-x64-msvc', ICU_DAT))
}
}

Expand All @@ -135,7 +135,7 @@ function downloadIcu() {
execSync(`curl -J -L -H "Accept: application/octet-stream" ${downloadUrl} -o ${ICU_DAT}`, {
stdio: 'inherit',
})
copyFileSync(join(__dirname, '..', ICU_DAT), join(__dirname, '..', 'npm', 'win32-x64-msvc', ICU_DAT))
copyFileSync(join(dirname, '..', ICU_DAT), join(dirname, '..', 'npm', 'win32-x64-msvc', ICU_DAT))
return Promise.resolve(null)
}

Expand Down
21 changes: 11 additions & 10 deletions scripts/utils.js → scripts/utils.mjs
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
const { execSync } = require('child_process')
const { join } = require('path')
import { execSync } from 'node:child_process'
import { join } from 'node:path'
import { fileURLToPath } from 'node:url'

const OWNER = 'Brooooooklyn'
const REPO = 'canvas'
export const OWNER = 'Brooooooklyn'
export const REPO = 'canvas'

const [FULL_HASH] =
process.env.NODE_ENV === 'ava' ? ['000000'] : execSync(`git submodule status skia`).toString('utf8').trim().split(' ')

const SHORT_HASH = FULL_HASH.substring(0, 8)

const TAG = `skia-${SHORT_HASH}`
export const dirname = join(fileURLToPath(import.meta.url), '..')

export const TAG = `skia-${SHORT_HASH}`

/**
* @param {string} lib Static lib name
* @param {string} hostPlatform require('os').platform()
* @param {string | undefined} triple rust target triple
* @returns {{ binary: string; copy: string; downloadUrl: string; filename: string }}
*/
function libPath(lib, hostPlatform, triple, tag = TAG) {
export function libPath(lib, hostPlatform, triple, tag = TAG) {
let platformName
if (!triple) {
switch (hostPlatform) {
Expand Down Expand Up @@ -57,11 +60,9 @@ function libPath(lib, hostPlatform, triple, tag = TAG) {
throw new TypeError(`[${triple}] is not a valid target`)
}
}
const binary = join(__dirname, '..', 'skia', 'out', 'Static', hostPlatform === 'win32' ? `${lib}.lib` : `lib${lib}.a`)
const binary = join(dirname, '..', 'skia', 'out', 'Static', hostPlatform === 'win32' ? `${lib}.lib` : `lib${lib}.a`)

const copy = join(__dirname, '..', platformName)
const copy = join(dirname, '..', platformName)
const downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/download/${tag}/${platformName}`
return { binary, copy, downloadUrl, filename: platformName }
}

module.exports = { libPath, OWNER, REPO, TAG }
Loading

0 comments on commit 3c9d1bb

Please sign in to comment.