forked from ReactiveX/rxjs
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add release utilities (ReactiveX#7395)
- Loading branch information
1 parent
e19c7ef
commit 480c6a2
Showing
13 changed files
with
1,203 additions
and
1,911 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Install Dependencies | ||
description: 'Prepares the repo by installing dependencies' | ||
inputs: | ||
node-version: | ||
description: 'The node version to setup' | ||
required: true | ||
registry-url: | ||
description: 'Define registry-url' | ||
required: false | ||
default: 'https://registry.npmjs.org' | ||
|
||
# outputs: - no outputs | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Use Node.js ${{ inputs.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ inputs.node-version }} | ||
registry-url: ${{ inputs.registry-url }} | ||
|
||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT | ||
shell: bash | ||
|
||
- uses: actions/cache@v3 | ||
id: yarn-cache | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
shell: bash | ||
env: | ||
YARN_CACHE_FOLDER: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: publish | ||
|
||
on: | ||
# Run manually using the GitHub UI | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Version to publish' | ||
required: false | ||
default: '' | ||
# ...or whenever a GitHub release gets created | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
publish: | ||
name: Publish to npm | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write # needed for provenance data generation | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # include tags | ||
|
||
- name: Install Dependencies | ||
uses: ./.github/actions/install-dependencies | ||
with: | ||
node-version: 20 | ||
|
||
- name: Prepare packages for publishing | ||
run: yarn prepare-packages | ||
|
||
- name: Apply updated version to packages | ||
run: | | ||
# Use the version from the workflow input if it's set, otherwise use the tag name from the release | ||
VERSION=${{ github.event.inputs.version || github.ref_name }} | ||
yarn nx release version $VERSION | ||
- name: Publish packages to npm | ||
run: | | ||
if [[ $GITHUB_REF == 'refs/heads/7.x' ]]; then | ||
yarn nx release publish --registry https://registry.npmjs.org --tag latest | ||
elif [[ $GITHUB_REF == 'refs/heads/master' ]]; then | ||
yarn nx release publish --registry https://registry.npmjs.org --tag next | ||
else | ||
echo "Branch not recognized for publishing, should be either '7.x' or 'master'" | ||
exit 1 | ||
fi | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
NPM_CONFIG_PROVENANCE: true |
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 |
---|---|---|
|
@@ -33,3 +33,6 @@ package-lock.json | |
|
||
integration/import/**/rx.json | ||
integration/import/**/operators.json | ||
|
||
|
||
.nx/cache |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"affected": { | ||
"defaultBase": "master" | ||
}, | ||
"nxCloudAccessToken": "OWE4MTMzMTEtNDZlZi00MWMwLWJkYmEtN2EwYTQ1ZWNjMzRkfHJlYWQ=", | ||
"targetDefaults": { | ||
"build": { | ||
"dependsOn": ["^build"], | ||
"cache": true | ||
}, | ||
"test:circular": { | ||
"dependsOn": ["build"] | ||
} | ||
}, | ||
"release": { | ||
"releaseTagPattern": "{version}", | ||
"changelog": { | ||
"git": { | ||
"commit": true, | ||
"tag": true | ||
}, | ||
"workspaceChangelog": { | ||
"createRelease": "github", | ||
"file": false | ||
}, | ||
"projectChangelogs": true | ||
}, | ||
"groups": { | ||
"npm": { | ||
"projects": ["rxjs"], | ||
"version": { | ||
"generatorOptions": { | ||
"currentVersionResolver": "git-tag", | ||
"specifierSource": "conventional-commits" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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,12 +1,21 @@ | ||
const fs = require('fs'); | ||
|
||
// Load the packages from the package.json workspaces | ||
const packageJson = JSON.parse(fs.readFileSync('package.json')); | ||
const packages = packageJson.workspaces; | ||
|
||
packages | ||
.filter((path) => path.startsWith('packages')) | ||
.forEach((packagePath) => { | ||
fs.copyFileSync('LICENSE.txt', `${packagePath}/LICENSE.txt`); | ||
fs.copyFileSync('CODE_OF_CONDUCT.md', `${packagePath}/CODE_OF_CONDUCT.md`); | ||
}); | ||
// @ts-check | ||
|
||
const { copyFileSync } = require('fs'); | ||
const { createProjectGraphAsync, joinPathFragments, workspaceRoot } = require('@nx/devkit'); | ||
|
||
const getWorkspacePath = (...pathFragments) => joinPathFragments(workspaceRoot, ...pathFragments); | ||
|
||
(async () => { | ||
const projectGraph = await createProjectGraphAsync(); | ||
|
||
for (const projectConfig of Object.values(projectGraph.nodes)) { | ||
const projectRoot = projectConfig.data.root; | ||
if (!projectRoot.startsWith('packages')) { | ||
continue; | ||
} | ||
copyFileSync(getWorkspacePath('LICENSE.txt'), getWorkspacePath(projectRoot, `LICENSE.txt`)); | ||
copyFileSync(getWorkspacePath('CODE_OF_CONDUCT.md'), getWorkspacePath(projectRoot, `CODE_OF_CONDUCT.md`)); | ||
} | ||
|
||
process.exit(0); | ||
})(); |
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,58 @@ | ||
// @ts-check | ||
|
||
const { execSync } = require('node:child_process'); | ||
const { releaseChangelog, releaseVersion } = require('nx/src/command-line/release'); | ||
// There are multiple copies of outdated yargs in the workspace, access a known modern one | ||
const yargs = require('nx/node_modules/yargs'); | ||
|
||
(async () => { | ||
try { | ||
const options = await yargs | ||
// @ts-expect-error - don't use the default meaning of version in yargs | ||
.version(false) | ||
.option('version', { | ||
description: 'Explicit version specifier to use, if overriding conventional commits', | ||
type: 'string', | ||
}) | ||
.option('dryRun', { | ||
alias: 'd', | ||
description: 'Whether or not to perform a dry-run of the release process, defaults to true', | ||
type: 'boolean', | ||
default: true, | ||
}) | ||
.option('verbose', { | ||
description: 'Whether or not to enable verbose logging, defaults to false', | ||
type: 'boolean', | ||
default: false, | ||
}) | ||
.parseAsync(); | ||
|
||
// Prepare the packages for publishing | ||
execSync('yarn prepare-packages', { | ||
stdio: 'inherit', | ||
maxBuffer: 1024 * 1000000, | ||
}); | ||
|
||
const { workspaceVersion, projectsVersionData } = await releaseVersion({ | ||
specifier: options.version, | ||
// stage package.json updates to be committed later by the changelog command | ||
stageChanges: true, | ||
dryRun: options.dryRun, | ||
verbose: options.verbose, | ||
}); | ||
|
||
// This will create a release on GitHub, which will act as a trigger for the publish.yml workflow | ||
await releaseChangelog({ | ||
versionData: projectsVersionData, | ||
version: workspaceVersion, | ||
interactive: 'workspace', | ||
dryRun: options.dryRun, | ||
verbose: options.verbose, | ||
}); | ||
|
||
process.exit(0); | ||
} catch (err) { | ||
console.error(err); | ||
process.exit(1); | ||
} | ||
})(); |
Oops, something went wrong.