Browse Source

Merge pull request #5110 from abpframework/ci/publish.ps1

Improved the publish.ps1 to be able to publish RC packages
pull/5112/head
Bunyamin Coskuner 6 years ago
committed by GitHub
parent
commit
4934a3e412
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .github/workflows/angular.yml
  2. 10
      npm/get-version.js
  3. 17
      npm/ng-packs/scripts/publish.ts
  4. 15
      npm/package-lock.json
  5. 1
      npm/package.json
  6. 6
      npm/preview-publish.ps1
  7. 21
      npm/publish-utils.js
  8. 20
      npm/publish.ps1

1
.github/workflows/angular.yml

@ -3,6 +3,7 @@ on:
pull_request: pull_request:
paths: paths:
- 'npm/ng-packs/**' - 'npm/ng-packs/**'
- '!npm/ng-packs/scripts/**'
jobs: jobs:
build-test-lint: build-test-lint:
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04

10
npm/get-version.js

@ -1,10 +0,0 @@
const fse = require('fs-extra');
const commonProps = fse.readFileSync('../common.props').toString();
const versionTag = '<Version>';
const versionEndTag = '</Version>';
const first = commonProps.indexOf(versionTag) + versionTag.length;
const last = commonProps.indexOf(versionEndTag);
console.log(commonProps.substring(first, last));

17
npm/ng-packs/scripts/publish.ts

@ -8,7 +8,9 @@ program
'-v, --nextVersion <version>', '-v, --nextVersion <version>',
'next semantic version. Available versions: ["major", "minor", "patch", "premajor", "preminor", "prepatch", "prerelease", "or type a custom version"]', 'next semantic version. Available versions: ["major", "minor", "patch", "premajor", "preminor", "prepatch", "prerelease", "or type a custom version"]',
) )
.option('-p, --preview', 'publish with preview tag'); .option('-p, --preview', 'publishes with preview tag')
.option('-r, --rc', 'publishes with next tag')
.option('-g, --skipGit', 'skips git push');
program.parse(process.argv); program.parse(process.argv);
@ -55,14 +57,13 @@ const publish = async () => {
await fse.rename('../lerna.publish.json', '../lerna.json'); await fse.rename('../lerna.publish.json', '../lerna.json');
let tag: string;
if (program.preview) tag = 'preview';
if (program.rc) tag = 'next';
await execa( await execa(
'yarn', 'yarn',
[ ['lerna', 'exec', '--', `"npm publish --registry ${registry}${tag ? ` --tag ${tag}` : ''}"`],
'lerna',
'exec',
'--',
`"npm publish --registry ${registry}${program.preview ? ' --tag preview' : ''}"`,
],
{ {
stdout: 'inherit', stdout: 'inherit',
cwd: '../', cwd: '../',
@ -71,7 +72,7 @@ const publish = async () => {
await fse.rename('../lerna.json', '../lerna.publish.json'); await fse.rename('../lerna.json', '../lerna.publish.json');
if (!program.preview) { if (!program.preview && !program.skipGit) {
await execa('git', ['add', '../packages/*', '../package.json', '../lerna.version.json'], { await execa('git', ['add', '../packages/*', '../package.json', '../lerna.version.json'], {
stdout: 'inherit', stdout: 'inherit',
}); });

15
npm/package-lock.json

@ -2209,11 +2209,9 @@
} }
}, },
"commander": { "commander": {
"version": "2.20.3", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", "resolved": "https://registry.npmjs.org/commander/-/commander-6.0.0.tgz",
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "integrity": "sha512-s7EA+hDtTYNhuXkTlhqew4txMZVdszBmKWSPEMxGr8ru8JXR7bLUFIAtPhcSuFdJQ0ILMxnJi8GkQL0yvDy/YA=="
"dev": true,
"optional": true
}, },
"compare-func": { "compare-func": {
"version": "1.3.2", "version": "1.3.2",
@ -7411,6 +7409,13 @@
"source-map": "~0.6.1" "source-map": "~0.6.1"
}, },
"dependencies": { "dependencies": {
"commander": {
"version": "2.20.3",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
"dev": true,
"optional": true
},
"source-map": { "source-map": {
"version": "0.6.1", "version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",

1
npm/package.json

@ -13,6 +13,7 @@
"npm-check-updates": "^3.1.25" "npm-check-updates": "^3.1.25"
}, },
"dependencies": { "dependencies": {
"commander": "^6.0.0",
"execa": "^3.4.0", "execa": "^3.4.0",
"fs-extra": "^8.1.0" "fs-extra": "^8.1.0"
} }

6
npm/preview-publish.ps1

@ -8,8 +8,8 @@ param(
npm install npm install
$NextVersion = $(node get-version.js) $NextVersion = $(node publish-utils.js --nextVersion)
$rootFolder = (Get-Item -Path "./" -Verbose).FullName $RootFolder = (Get-Item -Path "./" -Verbose).FullName
if(-Not $Version) { if(-Not $Version) {
$Version = $NextVersion; $Version = $NextVersion;
@ -34,7 +34,7 @@ foreach ($command in $commands) {
Invoke-Expression $command Invoke-Expression $command
if($LASTEXITCODE -ne '0' -And $command -notlike '*cd *'){ if($LASTEXITCODE -ne '0' -And $command -notlike '*cd *'){
Write-Host ("Process failed! " + $command) Write-Host ("Process failed! " + $command)
Set-Location $rootFolder Set-Location $RootFolder
exit $LASTEXITCODE exit $LASTEXITCODE
} }
} }

21
npm/publish-utils.js

@ -0,0 +1,21 @@
const { program } = require('commander');
const fse = require('fs-extra');
program.version('0.0.1');
program.option('-n, --nextVersion', 'version in common.props');
program.option('-r, --rc', 'whether version is rc');
program.parse(process.argv);
if (program.nextVersion) console.log(getVersion());
if (program.rc) console.log(getVersion().includes('rc'));
function getVersion() {
const commonProps = fse.readFileSync('../common.props').toString();
const versionTag = '<Version>';
const versionEndTag = '</Version>';
const first = commonProps.indexOf(versionTag) + versionTag.length;
const last = commonProps.indexOf(versionEndTag);
return commonProps.substring(first, last);
}

20
npm/publish.ps1

@ -4,21 +4,31 @@ param(
npm install npm install
$NextVersion = $(node get-version.js) $NextVersion = $(node publish-utils.js --nextVersion)
$rootFolder = (Get-Item -Path "./" -Verbose).FullName $RootFolder = (Get-Item -Path "./" -Verbose).FullName
if(-Not $Version) { if(-Not $Version) {
$Version = $NextVersion; $Version = $NextVersion;
} }
$NgPacksPublishCommand = "npm run publish-packages -- --nextVersion $Version --skipGit"
$PacksPublishCommand = "npm run lerna -- exec 'npm publish --registry https://registry.npmjs.org'"
$IsRc = $(node publish-utils.js --rc) -eq "true";
if($IsRc) {
$NgPacksPublishCommand += " --rc"
$PacksPublishCommand = $PacksPublishCommand.Substring(0,$PacksPublishCommand.Length-1) + " --tag next'"
}
$commands = ( $commands = (
"cd ng-packs\scripts", "cd ng-packs\scripts",
"npm install", "npm install",
"npm run publish-packages -- --nextVersion $Version", $NgPacksPublishCommand,
"cd ../../", "cd ../../",
"npm run lerna -- version $Version --yes --no-commit-hooks --skip-git --force-publish", "npm run lerna -- version $Version --yes --no-commit-hooks --skip-git --force-publish",
"npm run replace-with-tilde", "npm run replace-with-tilde",
"npm run lerna -- exec 'npm publish --registry https://registry.npmjs.org'", $PacksPublishCommand,
"npm run update-gulp" "npm run update-gulp"
) )
@ -27,7 +37,7 @@ foreach ($command in $commands) {
Invoke-Expression $command Invoke-Expression $command
if($LASTEXITCODE -ne '0' -And $command -notlike '*cd *'){ if($LASTEXITCODE -ne '0' -And $command -notlike '*cd *'){
Write-Host ("Process failed! " + $command) Write-Host ("Process failed! " + $command)
Set-Location $rootFolder Set-Location $RootFolder
exit $LASTEXITCODE exit $LASTEXITCODE
} }
} }
Loading…
Cancel
Save