mirror of
https://github.com/mathuo/dockview
synced 2025-09-01 15:06:25 +00:00
Merge pull request #368 from mathuo/366-move-npm-publishing-to-github-actions
chore: Github Publish Actions
This commit is contained in:
commit
b4ff626b74
2
.github/workflows/experimental.yml
vendored
2
.github/workflows/experimental.yml
vendored
@ -21,7 +21,7 @@ jobs:
|
|||||||
${{ runner.os }}-node-
|
${{ runner.os }}-node-
|
||||||
|
|
||||||
- run: yarn
|
- run: yarn
|
||||||
- run: npm run set-experimental-verisons
|
- run: npm run set-experimental-versions
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
- run: npm run test
|
- run: npm run test
|
||||||
- run: npm publish --tag experimental --dry-run
|
- run: npm publish --tag experimental --dry-run
|
||||||
|
@ -25,8 +25,7 @@
|
|||||||
"docs": "typedoc",
|
"docs": "typedoc",
|
||||||
"rebuild": "npm run clean && npm run build",
|
"rebuild": "npm run clean && npm run build",
|
||||||
"test": "cross-env ../../node_modules/.bin/jest --selectProjects dockview-core",
|
"test": "cross-env ../../node_modules/.bin/jest --selectProjects dockview-core",
|
||||||
"test:cov": "cross-env ../../node_modules/.bin/jest --selectProjects dockview-core --coverage",
|
"test:cov": "cross-env ../../node_modules/.bin/jest --selectProjects dockview-core --coverage"
|
||||||
"dev-publish": "node ./scripts/publishExperimental.js"
|
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist",
|
"dist",
|
||||||
|
@ -1,63 +0,0 @@
|
|||||||
const cp = require('child_process');
|
|
||||||
const fs = require('fs-extra');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const rootDir = path.join(__dirname, '..');
|
|
||||||
const publishDir = path.join(rootDir, '__publish__');
|
|
||||||
|
|
||||||
cp.execSync('npm run clean', { cwd: rootDir, stdio: 'inherit' });
|
|
||||||
cp.execSync('npm run test', { cwd: __dirname, stdio: 'inherit' });
|
|
||||||
cp.execSync('npm run build', { cwd: rootDir, stdio: 'inherit' });
|
|
||||||
|
|
||||||
if (fs.existsSync(publishDir)) {
|
|
||||||
fs.removeSync(publishDir);
|
|
||||||
}
|
|
||||||
fs.mkdirSync(publishDir);
|
|
||||||
|
|
||||||
if (!fs.existsSync(path.join(publishDir, 'dist'))) {
|
|
||||||
fs.mkdirSync(path.join(publishDir, 'dist'));
|
|
||||||
}
|
|
||||||
|
|
||||||
const package = JSON.parse(
|
|
||||||
fs.readFileSync(path.join(rootDir, 'package.json')).toString()
|
|
||||||
);
|
|
||||||
|
|
||||||
for (const file of package.files) {
|
|
||||||
fs.copySync(path.join(rootDir, file), path.join(publishDir, file));
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = cp
|
|
||||||
.execSync('git rev-parse --short HEAD', {
|
|
||||||
cwd: rootDir,
|
|
||||||
})
|
|
||||||
.toString()
|
|
||||||
.replace(/\n/g, '');
|
|
||||||
|
|
||||||
function formatDate() {
|
|
||||||
const date = new Date();
|
|
||||||
|
|
||||||
function pad(value) {
|
|
||||||
if (value.toString().length === 1) {
|
|
||||||
return `0${value}`;
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return `${date.getFullYear()}${pad(date.getMonth() + 1)}${pad(
|
|
||||||
date.getDate()
|
|
||||||
)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
package.version = `0.0.0-experimental-${result}-${formatDate()}`;
|
|
||||||
package.scripts = {};
|
|
||||||
|
|
||||||
fs.writeFileSync(
|
|
||||||
path.join(publishDir, 'package.json'),
|
|
||||||
JSON.stringify(package, null, 4)
|
|
||||||
);
|
|
||||||
|
|
||||||
const command = 'npm publish --tag experimental';
|
|
||||||
|
|
||||||
cp.execSync(command, { cwd: publishDir, stdio: 'inherit' });
|
|
||||||
|
|
||||||
fs.removeSync(publishDir);
|
|
@ -25,8 +25,7 @@
|
|||||||
"prepublishOnly": "npm run rebuild && npm run test",
|
"prepublishOnly": "npm run rebuild && npm run test",
|
||||||
"rebuild": "npm run clean && npm run build",
|
"rebuild": "npm run clean && npm run build",
|
||||||
"test": "cross-env ../../node_modules/.bin/jest --selectProjects dockview",
|
"test": "cross-env ../../node_modules/.bin/jest --selectProjects dockview",
|
||||||
"test:cov": "cross-env ../../node_modules/.bin/jest --selectProjects dockview --coverage",
|
"test:cov": "cross-env ../../node_modules/.bin/jest --selectProjects dockview --coverage"
|
||||||
"dev-publish": "node ./scripts/publishExperimental.js"
|
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist",
|
"dist",
|
||||||
|
@ -1,64 +0,0 @@
|
|||||||
const cp = require('child_process');
|
|
||||||
const fs = require('fs-extra');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const rootDir = path.join(__dirname, '..');
|
|
||||||
const publishDir = path.join(rootDir, '__publish__');
|
|
||||||
|
|
||||||
cp.execSync('npm run clean', { cwd: rootDir, stdio: 'inherit' });
|
|
||||||
cp.execSync('npm run test', { cwd: __dirname, stdio: 'inherit' });
|
|
||||||
cp.execSync('npm run build', { cwd: rootDir, stdio: 'inherit' });
|
|
||||||
|
|
||||||
if (fs.existsSync(publishDir)) {
|
|
||||||
fs.removeSync(publishDir);
|
|
||||||
}
|
|
||||||
fs.mkdirSync(publishDir);
|
|
||||||
|
|
||||||
if (!fs.existsSync(path.join(publishDir, 'dist'))) {
|
|
||||||
fs.mkdirSync(path.join(publishDir, 'dist'));
|
|
||||||
}
|
|
||||||
|
|
||||||
const package = JSON.parse(
|
|
||||||
fs.readFileSync(path.join(rootDir, 'package.json')).toString()
|
|
||||||
);
|
|
||||||
|
|
||||||
for (const file of package.files) {
|
|
||||||
fs.copySync(path.join(rootDir, file), path.join(publishDir, file));
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = cp
|
|
||||||
.execSync('git rev-parse --short HEAD', {
|
|
||||||
cwd: rootDir,
|
|
||||||
})
|
|
||||||
.toString()
|
|
||||||
.replace(/\n/g, '');
|
|
||||||
|
|
||||||
function formatDate() {
|
|
||||||
const date = new Date();
|
|
||||||
|
|
||||||
function pad(value) {
|
|
||||||
if (value.toString().length === 1) {
|
|
||||||
return `0${value}`;
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return `${date.getFullYear()}${pad(date.getMonth() + 1)}${pad(
|
|
||||||
date.getDate()
|
|
||||||
)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
package.version = `0.0.0-experimental-${result}-${formatDate()}`;
|
|
||||||
package.dependencies['dockview-core'] = package.version;
|
|
||||||
package.scripts = {};
|
|
||||||
|
|
||||||
fs.writeFileSync(
|
|
||||||
path.join(publishDir, 'package.json'),
|
|
||||||
JSON.stringify(package, null, 4)
|
|
||||||
);
|
|
||||||
|
|
||||||
const command = 'npm publish --tag experimental';
|
|
||||||
|
|
||||||
cp.execSync(command, { cwd: publishDir, stdio: 'inherit' });
|
|
||||||
|
|
||||||
fs.removeSync(publishDir);
|
|
@ -59,3 +59,13 @@ dockviewPackageJson.version = version;
|
|||||||
dockviewPackageJson.dependencies['dockview-core'] = dockviewPackageJson.version;
|
dockviewPackageJson.dependencies['dockview-core'] = dockviewPackageJson.version;
|
||||||
|
|
||||||
fs.writeFileSync(dockviewPath, JSON.stringify(dockviewPackageJson, null, 4));
|
fs.writeFileSync(dockviewPath, JSON.stringify(dockviewPackageJson, null, 4));
|
||||||
|
|
||||||
|
// sanity check
|
||||||
|
|
||||||
|
const dvCore = JSON.parse(fs.readFileSync(dockviewCorePath).toString());
|
||||||
|
const dv = JSON.parse(fs.readFileSync(dockviewPath).toString());
|
||||||
|
|
||||||
|
console.log(`dockview-core version: ${dvCore.version}`);
|
||||||
|
console.log(
|
||||||
|
`dockview version: ${dv.version} dockview-core dependency version: ${dv.dependencies['dockview-core']}`
|
||||||
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user