-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The publishing process of prebuilt-tdlib is heavily changed, everything is now in the publish.js script (check-prebuilds.js and write-tdlib-json.js are subsumed), which prepares the prebuilt-tdlib package (updates its name and version, removes private) and publishes it. It is no longer necessary to specify the full padded npm version to run the prebuilt-tdlib workflow. The input parameter is changed from npm-version to npm-patch (accepts a single number). The name of prebuilt-tdlib/package.json in this repository is now prebuilt-tdlib-dev, which can allow to install prebuilt-tdlib as a dev dependency here in the future. The prebuilt-tdlib package is now published with the tdlib field in package.json (contains "commit" and "version" properties), which should enable to run convenient queries like `npm info prebuilt-tdlib tdlib.commit`.
- Loading branch information
Showing
7 changed files
with
106 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/usr/bin/env/node | ||
// @flow | ||
|
||
const path = require('path') | ||
const fs = require('fs') | ||
const { execSync } = require('child_process') | ||
|
||
const packageName = 'prebuilt-tdlib' | ||
|
||
const tdlibCommit = process.env.TDLIB_COMMIT_HASH | ||
let tdlibVersion = process.env.TDLIB_VERSION | ||
const npmTag = process.env.NPM_TAG | ||
const patchVersion = process.argv[2] | ||
|
||
if (!tdlibCommit) throw new Error('Expected TDLIB_COMMIT_HASH') | ||
if (!tdlibVersion) throw new Error('Expected TDLIB_VERSION') | ||
if (!npmTag) throw new Error('Expected NPM_TAG') | ||
if (!patchVersion) throw new Error('Expected the patch version') | ||
|
||
if (Number.isNaN(Number(patchVersion))) | ||
throw new Error(`Incorrect patch version: ${patchVersion}`) | ||
|
||
if (tdlibCommit.length < 40) throw new Error('Too short TDLib commit') | ||
|
||
tdlibVersion = tdlibVersion.replace(/^v/, '') | ||
|
||
let [tdlibMajor, tdlibMinor, tdlibPatch] = tdlibVersion.split('.') | ||
|
||
if (tdlibMajor == null || tdlibMinor == null || tdlibPatch == null) | ||
throw new Error(`Incorrect TDLib version: ${tdlibVersion}`) | ||
|
||
tdlibMinor = tdlibMinor.padStart(3, '0') | ||
tdlibPatch = tdlibPatch.padStart(3, '0') | ||
|
||
const npmVersion = `0.${tdlibMajor}${tdlibMinor}${tdlibPatch}.${patchVersion}` | ||
|
||
console.log(`Preparing to publish ${npmVersion}`) | ||
|
||
const packageJson = require('./package.json') | ||
|
||
delete packageJson.private | ||
packageJson.name = packageName | ||
packageJson.version = npmVersion | ||
packageJson.tdlib = { | ||
commit: tdlibCommit, | ||
version: tdlibVersion | ||
} | ||
|
||
const tdlibJson = | ||
{ commit: tdlibCommit, version: tdlibVersion, ref: tdlibCommit } | ||
|
||
fs.writeFileSync( | ||
path.join(__dirname, 'prebuilds', 'tdlib.json'), | ||
JSON.stringify(tdlibJson) + '\n' | ||
) | ||
|
||
fs.writeFileSync( | ||
path.join(__dirname, 'package.json'), | ||
JSON.stringify(packageJson, null, ' ') + '\n' | ||
) | ||
|
||
// Check | ||
|
||
function checkExists (pathparts/*: string[] */) { | ||
const p = path.join(__dirname, 'prebuilds', ...pathparts) | ||
if (fs.existsSync(p)) return | ||
throw new Error(`'${p}' does not exist`) | ||
} | ||
|
||
checkExists(['tdlib-linux-x64', 'libtdjson.so']) | ||
checkExists(['tdlib-macos', 'libtdjson.dylib']) | ||
checkExists(['tdlib-windows-x64', 'tdjson.dll']) | ||
|
||
checkExists(['tdlib.json']) | ||
|
||
// Publish | ||
|
||
const publishCommand = | ||
`npm publish --provenance --access public --tag ${npmTag} -w prebuilt-tdlib-dev` | ||
|
||
const addTagCommand = | ||
`npm dist-tag add ${packageName}@${npmVersion} td-${tdlibVersion} ` + | ||
'-w prebuilt-tdlib-dev' | ||
|
||
execSync(publishCommand, { stdio: 'inherit' }) | ||
execSync(addTagCommand, { stdio: 'inherit' }) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters