ci: fix docs build
This commit is contained in:
parent
943b13088f
commit
3580575b82
2 changed files with 27 additions and 22 deletions
2
.github/workflows/docs.yaml
vendored
2
.github/workflows/docs.yaml
vendored
|
@ -26,6 +26,8 @@ jobs:
|
||||||
- name: Setup Pages
|
- name: Setup Pages
|
||||||
uses: actions/configure-pages@v3
|
uses: actions/configure-pages@v3
|
||||||
- name: Build
|
- name: Build
|
||||||
|
env:
|
||||||
|
BUILD_FOR_DOCS: 1
|
||||||
run: pnpm run -r --workspace-concurrency=1 build
|
run: pnpm run -r --workspace-concurrency=1 build
|
||||||
- name: Build docs
|
- name: Build docs
|
||||||
run: |
|
run: |
|
||||||
|
|
|
@ -7,8 +7,9 @@ const { Readable } = require('stream')
|
||||||
const git = require('../../scripts/git-utils')
|
const git = require('../../scripts/git-utils')
|
||||||
|
|
||||||
const GITHUB_TOKEN = process.env.GITHUB_TOKEN
|
const GITHUB_TOKEN = process.env.GITHUB_TOKEN
|
||||||
|
const SKIP_PREBUILT = process.env.BUILD_FOR_DOCS === '1'
|
||||||
|
|
||||||
if (!GITHUB_TOKEN) {
|
if (!GITHUB_TOKEN && !SKIP_PREBUILT) {
|
||||||
throw new Error('GITHUB_TOKEN is required to publish crypto-node')
|
throw new Error('GITHUB_TOKEN is required to publish crypto-node')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,31 +152,33 @@ module.exports = ({ fs, glob, path, packageDir, outDir }) => ({
|
||||||
async final() {
|
async final() {
|
||||||
const libDir = path.join(packageDir, 'lib')
|
const libDir = path.join(packageDir, 'lib')
|
||||||
|
|
||||||
// generate sources hash
|
if (!SKIP_PREBUILT) {
|
||||||
const hashes = []
|
// generate sources hash
|
||||||
|
const hashes = []
|
||||||
|
|
||||||
|
for (const file of glob.sync(path.join(libDir, '**/*'))) {
|
||||||
|
const hash = crypto.createHash('sha256')
|
||||||
|
hash.update(fs.readFileSync(file))
|
||||||
|
hashes.push(hash.digest('hex'))
|
||||||
|
}
|
||||||
|
|
||||||
for (const file of glob.sync(path.join(libDir, '**/*'))) {
|
|
||||||
const hash = crypto.createHash('sha256')
|
const hash = crypto.createHash('sha256')
|
||||||
hash.update(fs.readFileSync(file))
|
.update(hashes.join('\n'))
|
||||||
hashes.push(hash.digest('hex'))
|
.digest('hex')
|
||||||
|
console.log(hash)
|
||||||
|
|
||||||
|
console.log('[i] Checking for prebuilt artifacts for %s', hash)
|
||||||
|
let artifacts = await findArtifactsByHash(hash)
|
||||||
|
|
||||||
|
if (!artifacts) {
|
||||||
|
console.log('[i] No artifacts found, running workflow')
|
||||||
|
artifacts = await runWorkflow(git.getCurrentCommit(), hash)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('[i] Extracting artifacts')
|
||||||
|
await extractArtifacts(artifacts)
|
||||||
}
|
}
|
||||||
|
|
||||||
const hash = crypto.createHash('sha256')
|
|
||||||
.update(hashes.join('\n'))
|
|
||||||
.digest('hex')
|
|
||||||
console.log(hash)
|
|
||||||
|
|
||||||
console.log('[i] Checking for prebuilt artifacts for %s', hash)
|
|
||||||
let artifacts = await findArtifactsByHash(hash)
|
|
||||||
|
|
||||||
if (!artifacts) {
|
|
||||||
console.log('[i] No artifacts found, running workflow')
|
|
||||||
artifacts = await runWorkflow(git.getCurrentCommit(), hash)
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('[i] Extracting artifacts')
|
|
||||||
await extractArtifacts(artifacts)
|
|
||||||
|
|
||||||
// copy native sources and binding.gyp file
|
// copy native sources and binding.gyp file
|
||||||
|
|
||||||
fs.cpSync(libDir, path.join(outDir, 'lib'), { recursive: true })
|
fs.cpSync(libDir, path.join(outDir, 'lib'), { recursive: true })
|
||||||
|
|
Loading…
Reference in a new issue