-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
publish: Update JS job for multiple packages (#89)
* publish: Update JS job for multiple packages #### Problem The repo now contains multiple JS packages, but the publish job only works with one of them. #### Summary of changes Update the publish script to get things in line with Rust: * take in a package path to test * change testing to work for any JS package * publish to either `@solana-program` or `@solana` * generate a changelog * Address feedback
- Loading branch information
Showing
4 changed files
with
100 additions
and
27 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 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 |
---|---|---|
@@ -1,35 +1,45 @@ | ||
#!/usr/bin/env zx | ||
import 'zx/globals'; | ||
import { cliArguments, workingDirectory } from '../utils.mjs'; | ||
import { cliArguments, getPackageJson, workingDirectory } from '../utils.mjs'; | ||
|
||
const [level, tag = 'latest'] = cliArguments(); | ||
const [folder, level, tag = 'latest'] = cliArguments(); | ||
if (!folder) { | ||
throw new Error('A path to a directory with a JS package — e.g. "clients/js" — must be provided.'); | ||
} | ||
if (!level) { | ||
throw new Error('A version level — e.g. "path" — must be provided.'); | ||
throw new Error('A version level — e.g. "patch" — must be provided.'); | ||
} | ||
|
||
// Go to the client directory and install the dependencies. | ||
cd(path.join(workingDirectory, 'clients', 'js')); | ||
cd(path.join(workingDirectory, folder)); | ||
await $`pnpm install`; | ||
|
||
const tagName = path.basename(folder); | ||
const packageJson = getPackageJson(folder); | ||
const oldVersion = packageJson.version; | ||
const oldGitTag = `${tagName}@v${oldVersion}`; | ||
|
||
// Update the version. | ||
const versionArgs = [ | ||
'--no-git-tag-version', | ||
...(level.startsWith('pre') ? [`--preid ${tag}`] : []), | ||
]; | ||
let { stdout } = await $`pnpm version ${level} ${versionArgs}`; | ||
const newVersion = stdout.slice(1).trim(); | ||
const newGitTag = `${tagName}@v${newVersion}`; | ||
|
||
// Expose the new version to CI if needed. | ||
if (process.env.CI) { | ||
await $`echo "new_version=${newVersion}" >> $GITHUB_OUTPUT`; | ||
await $`echo "new_git_tag=${newGitTag}" >> $GITHUB_OUTPUT`; | ||
await $`echo "old_git_tag=${oldGitTag}" >> $GITHUB_OUTPUT`; | ||
} | ||
|
||
// Publish the package. | ||
// This will also build the package before publishing (see prepublishOnly script). | ||
await $`pnpm publish --no-git-checks --tag ${tag}`; | ||
|
||
// Commit the new version. | ||
await $`git commit -am "Publish JS client v${newVersion}"`; | ||
await $`git commit -am "Publish ${tagName} v${newVersion}"`; | ||
|
||
// Tag the new version. | ||
await $`git tag -a js@v${newVersion} -m "JS client v${newVersion}"`; | ||
await $`git tag -a ${newGitTag} -m "${tagName} v${newVersion}"`; |
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