Skip to content

Commit

Permalink
chore(repo): try and fix publish
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz committed Jan 31, 2023
1 parent 5ef930d commit 20e1634
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 37 deletions.
19 changes: 14 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ name: publish
env:
DEBUG: napi:*
NX_RUN_GROUP: ${{ github.run_id }}-${{ github.run_attempt }}
NX_VERBOSE_LOGGING: true
'on':
push:
tags:
- '*.*.*'
- "[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+"
jobs:
build:
if: "!contains(github.event.head_commit.message, 'skip ci')"
Expand Down Expand Up @@ -218,7 +220,14 @@ jobs:
shell: bash
- name: Publish
run: |
git checkout -b publish/$GITHUB_REF_NAME
npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN
yarn nx-release --local=false $GITHUB_REF_NAME
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create Github Release
uses: softprops/action-gh-release@v1
with:
body_path: ${{ github.workspace }}/CHANGELOG.md
env:
GH_TOKEN: ${{ github.token }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
10 changes: 3 additions & 7 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"packages": ["build/packages/*"],
"version": "PLACEHOLDER",
"packages": ["build/packages/*", "build/packages/nx/native-packages/*"],
"version": "15.7.0",
"granularPathspec": false,
"command": {
"publish": {
"graphType": "all"
}
}
"command": { "publish": { "graphType": "all" } }
}
2 changes: 1 addition & 1 deletion packages/nx/.npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
native-packages/
./*.node
/*.node
3 changes: 3 additions & 0 deletions packages/nx/native-packages/darwin-arm64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
],
"engines": {
"node": ">= 10"
},
"publishConfig": {
"access": "public"
}
}
3 changes: 3 additions & 0 deletions packages/nx/native-packages/darwin-x64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
],
"engines": {
"node": ">= 10"
},
"publishConfig": {
"access": "public"
}
}
3 changes: 3 additions & 0 deletions packages/nx/native-packages/linux-arm-gnueabihf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
],
"engines": {
"node": ">= 10"
},
"publishConfig": {
"access": "public"
}
}
3 changes: 3 additions & 0 deletions packages/nx/native-packages/linux-arm64-gnu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"engines": {
"node": ">= 10"
},
"publishConfig": {
"access": "public"
},
"libc": [
"glibc"
]
Expand Down
5 changes: 4 additions & 1 deletion packages/nx/native-packages/linux-arm64-musl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
},
"libc": [
"musl"
]
],
"publishConfig": {
"access": "public"
}
}
5 changes: 4 additions & 1 deletion packages/nx/native-packages/linux-x64-gnu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
},
"libc": [
"glibc"
]
],
"publishConfig": {
"access": "public"
}
}
5 changes: 4 additions & 1 deletion packages/nx/native-packages/linux-x64-musl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
},
"libc": [
"musl"
]
],
"publishConfig": {
"access": "public"
}
}
3 changes: 3 additions & 0 deletions packages/nx/native-packages/win32-arm64-msvc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
],
"engines": {
"node": ">= 10"
},
"publishConfig": {
"access": "public"
}
}
3 changes: 3 additions & 0 deletions packages/nx/native-packages/win32-x64-msvc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
],
"engines": {
"node": ">= 10"
},
"publishConfig": {
"access": "public"
}
}
14 changes: 12 additions & 2 deletions packages/nx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"directory": "packages/nx"
},
"scripts": {
"postinstall": "node ./bin/compute-project-graph",
"prepublishOnly": "napi prepublish --skip-gh-release --prefix ./native-packages $NAPI_DRY_RUN"
"postinstall": "node ./bin/compute-project-graph"
},
"keywords": [
"Monorepo",
Expand Down Expand Up @@ -79,6 +78,17 @@
"optional": true
}
},
"optionalDependencies": {
"@nrwl/nx-win32-x64-msvc": "*",
"@nrwl/nx-darwin-x64": "*",
"@nrwl/nx-linux-x64-gnu": "*",
"@nrwl/nx-darwin-arm64": "*",
"@nrwl/nx-linux-arm64-gnu": "*",
"@nrwl/nx-linux-arm64-musl": "*",
"@nrwl/nx-win32-arm64-msvc": "*",
"@nrwl/nx-linux-arm-gnueabihf": "*",
"@nrwl/nx-linux-x64-musl": "*"
},
"nx-migrations": {
"migrations": "./migrations.json",
"packageGroup": [
Expand Down
45 changes: 26 additions & 19 deletions scripts/nx-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import * as publish from '@lerna/publish/index';
const lernaJsonPath = join(__dirname, '../lerna.json');
const originalLernaJson = readFileSync(lernaJsonPath);

import * as enquirer from 'enquirer';

function hideFromGitIndex(uncommittedFiles: string[]) {
execSync(`git update-index --assume-unchanged ${uncommittedFiles.join(' ')}`);

Expand All @@ -25,6 +27,10 @@ function hideFromGitIndex(uncommittedFiles: string[]) {
(async () => {
const options = parseArgs();

if (options.clearLocalRegistry) {
execSync('yarn local-registry clear');
}

const currentLatestVersion = execSync('npm view nx version')
.toString()
.trim();
Expand All @@ -39,23 +45,23 @@ function hideFromGitIndex(uncommittedFiles: string[]) {
? 'previous'
: 'latest';

if (options.local) {
process.env.LOCAL_RELEASE = 'true';
// with local builds, we do not want napi to modify the base package.json to include optional dependencies that do not exist.
// when we pass `--dry-run` as an argument to napi prepublish, it will skip modifying any files
// `napi prepublish` is used in package.json's `prepublishOnly` scripts
process.env.NAPI_DRY_RUN = '--dry-run';
}
if (!options.local && !process.env.NPM_TOKEN) {
execSync('git status --ahead-behind');

if (!options.local && !options.force) {
console.log('Authenticating to NPM');
execSync('npm adduser', {
stdio: [0, 1, 2],
const { result } = await enquirer.prompt<{ result: boolean }>({
message:
'This is a local machine. Do you want to tag this version and push it for publishing?',
type: 'confirm',
name: 'result',
});
}

if (options.clearLocalRegistry) {
execSync('yarn local-registry clear');
if (result) {
execSync(`git tag ${options.version}`);
execSync(`git push origin ${options.version}`);
}
console.log(
'Check github: https://github.com/nrwl/nx/actions/workflows/publish.yml'
);
}

const buildCommand = 'yarn build';
Expand Down Expand Up @@ -84,7 +90,9 @@ function hideFromGitIndex(uncommittedFiles: string[]) {
}

if (!options.local) {
execSync('npx nx run-many --target=artifacts');
execSync('npx nx run-many --target=artifacts', {
stdio: [0, 1, 2],
});
}

const versionOptions = {
Expand All @@ -93,15 +101,14 @@ function hideFromGitIndex(uncommittedFiles: string[]) {
conventionalPrerelease: options.tag === 'next',
preid: options.preid,
forcePublish: true,
createRelease: options.tag !== 'next' ? 'github' : undefined,
noChangelog: options.tag === 'next',
createRelease: 'github',
tagVersionPrefix: '',
exact: true,
gitRemote: options.gitRemote,
gitTagVersion: options.tag !== 'next',
gitTagVersion: false,
message: 'chore(misc): publish %v',
loglevel: options.loglevel ?? 'info',
yes: false,
yes: !options.local && !!process.env.NPM_TOKEN,
};

if (options.local) {
Expand Down

0 comments on commit 20e1634

Please sign in to comment.