4 changed files with 136 additions and 5 deletions
@ -125,6 +125,9 @@ importers: |
|||
rotating-file-stream: |
|||
specifier: ^3.2.5 |
|||
version: 3.2.5 |
|||
semver: |
|||
specifier: ^7.7.0 |
|||
version: 7.7.0 |
|||
sharp: |
|||
specifier: ^0.33.5 |
|||
version: 0.33.5 |
|||
@ -216,6 +219,9 @@ importers: |
|||
'@types/randomstring': |
|||
specifier: ^1.3.0 |
|||
version: 1.3.0 |
|||
'@types/semver': |
|||
specifier: ^7.5.8 |
|||
version: 7.5.8 |
|||
'@types/stats-lite': |
|||
specifier: ^2.2.2 |
|||
version: 2.2.2 |
|||
@ -243,6 +249,9 @@ importers: |
|||
nodemon: |
|||
specifier: ^3.1.9 |
|||
version: 3.1.9 |
|||
simple-git: |
|||
specifier: ^3.27.0 |
|||
version: 3.27.0 |
|||
ts-node: |
|||
specifier: ^10.9.2 |
|||
version: 10.9.2(@types/[email protected])([email protected]) |
|||
@ -646,6 +655,12 @@ packages: |
|||
'@jridgewell/[email protected]': |
|||
resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} |
|||
|
|||
'@kwsites/[email protected]': |
|||
resolution: {integrity: sha512-m9/5YGR18lIwxSFDwfE3oA7bWuq9kdau6ugN4H2rJeyhFQZcG9AgSHkQtSD15a8WvTgfz9aikZMrKPHvbpqFiw==} |
|||
|
|||
'@kwsites/[email protected]': |
|||
resolution: {integrity: sha512-GaHYm+c0O9MjZRu0ongGBRbinu8gVAMd2UZjji6jVmqKtZluZnptXGWhz1E8j8D2HJ3f/yMxKAUC0b+57wncIw==} |
|||
|
|||
'@mongodb-js/[email protected]': |
|||
resolution: {integrity: sha512-tVkljjeEaAhCqTzajSdgbQ6gE6f3oneVwa3iXR6csiEwXXOFsiC6Uh9iAjAhXPtqa/XMDHWjjeNH/77m/Yq2dw==} |
|||
|
|||
@ -827,6 +842,9 @@ packages: |
|||
'@types/[email protected]': |
|||
resolution: {integrity: sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==} |
|||
|
|||
'@types/[email protected]': |
|||
resolution: {integrity: sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==} |
|||
|
|||
'@types/[email protected]': |
|||
resolution: {integrity: sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA==} |
|||
|
|||
@ -2482,6 +2500,9 @@ packages: |
|||
[email protected]: |
|||
resolution: {integrity: sha512-Rtlj66/b0ICeFzYTuNvX/EF1igRbbnGSvEyT79McoZa/DeGhMyC5pWKOEsZKnpkqtSeovd5FL/bjHWC3CIIvCQ==} |
|||
|
|||
[email protected]: |
|||
resolution: {integrity: sha512-ivHoFS9Yi9GY49ogc6/YAi3Fl9ROnF4VyubNylgCkA+RVqLaKWnDSzXOVzya8csELIaWaYNutsEuAhZrtOjozA==} |
|||
|
|||
[email protected]: |
|||
resolution: {integrity: sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==} |
|||
|
|||
@ -3177,6 +3198,14 @@ snapshots: |
|||
'@jridgewell/resolve-uri': 3.1.2 |
|||
'@jridgewell/sourcemap-codec': 1.5.0 |
|||
|
|||
'@kwsites/[email protected]': |
|||
dependencies: |
|||
debug: 4.4.0([email protected]) |
|||
transitivePeerDependencies: |
|||
- supports-color |
|||
|
|||
'@kwsites/[email protected]': {} |
|||
|
|||
'@mongodb-js/[email protected]': |
|||
dependencies: |
|||
sparse-bitfield: 3.0.3 |
|||
@ -3372,6 +3401,8 @@ snapshots: |
|||
|
|||
'@types/[email protected]': {} |
|||
|
|||
'@types/[email protected]': {} |
|||
|
|||
'@types/[email protected]': |
|||
dependencies: |
|||
'@types/mime': 1.3.5 |
|||
@ -5264,6 +5295,14 @@ snapshots: |
|||
|
|||
[email protected]: {} |
|||
|
|||
[email protected]: |
|||
dependencies: |
|||
'@kwsites/file-exists': 1.1.1 |
|||
'@kwsites/promise-deferred': 1.1.1 |
|||
debug: 4.4.0([email protected]) |
|||
transitivePeerDependencies: |
|||
- supports-color |
|||
|
|||
[email protected]: |
|||
dependencies: |
|||
is-arrayish: 0.3.2 |
|||
|
@ -0,0 +1,80 @@ |
|||
// release.ts
|
|||
// Copyright (C) 2025 DTP Technologies, LLC
|
|||
// All Rights Reserved
|
|||
|
|||
import env from "./config/env.js"; |
|||
import assert from "node:assert"; |
|||
|
|||
import path from "node:path"; |
|||
import fs from "node:fs"; |
|||
|
|||
import semver from "semver"; |
|||
import SimpleGit from "simple-git"; |
|||
|
|||
const release = process.argv[2] as semver.ReleaseType; |
|||
assert (release && semver.RELEASE_TYPES.includes(release), "Must specify the release type: major, minor, patch, build"); |
|||
|
|||
const pkgVersion = new semver.SemVer(env.pkg.version); |
|||
assert(pkgVersion, "A valid version is required in package.json"); |
|||
|
|||
const newVersion = new semver.SemVer(env.pkg.version); |
|||
newVersion.inc(release); |
|||
env.pkg.version = newVersion.format(); |
|||
|
|||
const releaseTag = `v${newVersion.format()}`; |
|||
console.log('tagging release:', pkgVersion.format(), release, newVersion.format(), releaseTag); |
|||
|
|||
(async ( ) => { |
|||
try { |
|||
|
|||
const simpleGit = SimpleGit(env.root); |
|||
|
|||
/* |
|||
* Make sure we're on the develop branch. Don't switch to it, we've already |
|||
* read package.json and other configs. Must be on develop when running a |
|||
* release. |
|||
*/ |
|||
const branch = await simpleGit.branch(); |
|||
assert(branch.current === "develop", "Not on develop branch, please fix."); |
|||
|
|||
/* |
|||
* Pull origin develop to make sure we're in sync. |
|||
*/ |
|||
await simpleGit.pull("origin", "develop"); |
|||
|
|||
/* |
|||
* Make sure the repo is of clean status |
|||
*/ |
|||
const status = await simpleGit.status(); |
|||
assert(!status.detached, "git repo is detached, please fix."); |
|||
assert(status.not_added.length === 0, "You have untracked files, please fix."); |
|||
assert(status.modified.length === 0, "You have modified files, please fix."); |
|||
|
|||
/* |
|||
* Write package.json to disk |
|||
*/ |
|||
const pkgFilename = path.join(env.root, "package.json"); |
|||
await fs.promises.writeFile(pkgFilename, JSON.stringify(env.pkg, null, 2), "utf-8"); |
|||
|
|||
/* |
|||
* Commit package.json, tag the repo for release, and push to develop on |
|||
* origin. |
|||
*/ |
|||
await simpleGit.commit(`releasing ${releaseTag} to master`); |
|||
await simpleGit.addTag(releaseTag); |
|||
await simpleGit.push("origin", "develop"); |
|||
|
|||
/* |
|||
* Switch to master, integrate changes from develop, and push. |
|||
*/ |
|||
await simpleGit.checkout("master"); |
|||
await simpleGit.pull("origin", "master"); |
|||
await simpleGit.pull(".", "develop"); |
|||
await simpleGit.push("origin","master"); |
|||
|
|||
simpleGit.checkout("develop"); |
|||
} catch (error) { |
|||
console.error(`Failed to process release: ${(error as Error).message}`, { error }); |
|||
} |
|||
|
|||
})(); |
Loading…
Reference in new issue