chore: Github Action npm experimental publish

This commit is contained in:
mathuo 2023-10-22 11:14:30 +01:00
parent e3ed4251ed
commit d4d79b220f
No known key found for this signature in database
GPG Key ID: C6EEDEFD6CA07281
3 changed files with 92 additions and 1 deletions

29
.github/workflows/experimental.yml vendored Normal file
View File

@ -0,0 +1,29 @@
name: Publish Experimental Package to npmjs
on:
workflow_dispatch:
# release:
# types: [published]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-
- run: yarn
- run: npm run set-experimental-verisons
- run: npm run build
- run: npm run test
- run: npm publish --tag experimental --dry-run
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

View File

@ -18,6 +18,7 @@
"clean": "lerna run clean",
"bootstrap": "lerna bootstrap",
"test:cov": "jest --coverage",
"set-experimental-versions": "node scripts/set-experimental-versions",
"version-beta-build": "lerna version prerelease --preid beta",
"publish-app": "lerna publish",
"docs": "typedoc",

View File

@ -0,0 +1,61 @@
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const rootDir = path.join(__dirname, '..');
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()
)}`;
}
function shortGitHash() {
return cp
.execSync('git rev-parse --short HEAD', {
cwd: rootDir,
})
.toString()
.replace(/\n/g, '');
}
const version = `0.0.0-experimental-${shortGitHash()}-${formatDate()}`;
// dockview-core
const dockviewCorePath = path.join(
rootDir,
'packages',
'dockview-core',
'package.json'
);
const dockviewCorePackageJson = JSON.parse(
fs.readFileSync(dockviewCorePath).toString()
);
dockviewCorePackageJson.version = version;
fs.writeFileSync(
dockviewCorePath,
JSON.stringify(dockviewCorePackageJson, null, 4)
);
// dockview
const dockviewPath = path.join(rootDir, 'packages', 'dockview', 'package.json');
const dockviewPackageJson = JSON.parse(
fs.readFileSync(dockviewPath).toString()
);
dockviewPackageJson.version = version;
dockviewPackageJson.dependencies['dockview-core'] = dockviewPackageJson.version;
fs.writeFileSync(dockviewPath, JSON.stringify(dockviewPackageJson, null, 4));