Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 33 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@ on:
workflow_dispatch:
inputs:
release_type:
type: choice
description: "Release type: patch, minor, major"
required: true
default: patch
options:
- patch
- minor
- major
release_notes:
type: string
description: "Release notes"
required: true

jobs:
release:
Expand All @@ -28,24 +36,33 @@ jobs:
with:
token: ${{ steps.generate_token.outputs.token }}

- name: Set up Node.js
uses: actions/setup-node@v3
- name: Set up Deno
uses: denoland/setup-deno@v2
with:
node-version: "22"
deno-version: "2.x"

- name: Install dependencies
run: npm install
- name: Compile
run: |
deno task compie:all

- name: Login with git
- name: Bump version
id: bump_version
run: |
git config --global user.email "info@nanoapi.io"
git config --global user.name "nanoapi.io"
VERSION=$(deno run -A scripts/bump_version.ts ${{ inputs.release_type }} ${{ inputs.release_notes }})
echo "release_version=$VERSION" >> $GITHUB_OUTPUT

- name: Login to npm registry
run: npm set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}"
- name: Create release
uses: softprops/action-gh-release@v1
with:
body: ${{ inputs.release_notes }}
tag_name: v${{ steps.bump_version.outputs.release_version }}
files: |
dist/*
CHANGELOG.md

- name: Run release-it for CLI
run: npm run release -- ${{ github.event.inputs.release_type }} --ci
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Commit and push changes
run: |
# Commit and push changes
git add CHANGELOG.md
git commit -m "[skip ci] update changelog for version ${{ steps.bump_version.outputs.release_version }}"
git push
4 changes: 0 additions & 4 deletions packages/cli/CHANGELOG.md → CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# Changelog

## [Unreleased]

## [1.0.7] - 2025-04-30

Fix some small bug on the FE, mainly unify the colors of edges and their
Expand Down
7 changes: 6 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"workspace": ["./packages/app", "./packages/cli", "./packages/shared"],
"version": "1.0.7",
"workspace": [
"./packages/app",
"./packages/cli",
"./packages/shared"
],
"nodeModulesDir": "auto",
"tasks": {
"dev:app": "deno task --config packages/app/deno.json dev",
Expand Down
10 changes: 10 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions packages/cli/deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "@napi/cli",
"version": "1.0.7",
"exports": "./src/index.ts",
"imports": {
"@napi/shared": "../shared/src/index.ts",
Expand All @@ -19,10 +18,10 @@
},
"tasks": {
"dev": "NODE_ENV=development deno run --allow-all --watch src/index.ts",
"compile": "deno compile --allow-all --include=../app/dist --output=dist/napi src/index.ts",
"compile-linux": "deno compile --allow-all --include=../app/dist --output=dist/napi.linux --target=x86_64-unknown-linux-gnu src/index.ts",
"compile-macos": "deno compile --allow-all --include=../app/dist --output=dist/napi.macos --target=x86_64-apple-darwin src/index.ts",
"compile-windows": "deno compile --allow-all --include=../app/dist --output=dist/napi.exe --target=x86_64-pc-windows-msvc src/index.ts",
"compile": "deno compile --allow-all --include=../app/dist --output=../../dist/napi src/index.ts",
"compile-linux": "deno compile --allow-all --include=../app/dist --output=../../dist/napi.linux --target=x86_64-unknown-linux-gnu src/index.ts",
"compile-macos": "deno compile --allow-all --include=../app/dist --output=../../dist/napi.macos --target=x86_64-apple-darwin src/index.ts",
"compile-windows": "deno compile --allow-all --include=../app/dist --output=../../dist/napi.exe --target=x86_64-pc-windows-msvc src/index.ts",
"test": "deno test --allow-all"
}
}
2 changes: 1 addition & 1 deletion packages/cli/src/cli/helpers/checkNpmVersion.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import localPackageJson from "../../../deno.json" with { type: "json" };
import localPackageJson from "../../../../../deno.json" with { type: "json" };
import process from "node:process";

export async function checkVersionMiddleware() {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/telemetry.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EventEmitter } from "node:events";
import os from "node:os";
import { getOrCreateGlobalConfig } from "./config/globalConfig.ts";
import denoJson from "../deno.json" with { type: "json" };
import denoJson from "../../../deno.json" with { type: "json" };
import process from "node:process";

export enum TelemetryEvents {
Expand Down
63 changes: 63 additions & 0 deletions scripts/bump_version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import path from "node:path";

const releaseType: string = Deno.args[0];
if (
!releaseType ||
releaseType !== "patch" && releaseType !== "minor" && releaseType !== "major"
) {
console.error("Invalid release type");
Deno.exit(1);
}
const releaseNotes: string = Deno.args[1];
if (!releaseNotes) {
console.error("Release notes are required");
Deno.exit(1);
}

const denoJsonPath = path.resolve(
import.meta.dirname as string,
"..",
"deno.json",
);
const denoJson = JSON.parse(await Deno.readTextFile(denoJsonPath)) as {
version: string;
};

const [major, minor, patch] = denoJson.version.split(".").map(Number);

let newVersion: string;

if (releaseType === "patch") {
newVersion = `${major}.${minor}.${patch + 1}`;
} else if (releaseType === "minor") {
newVersion = `${major}.${minor + 1}.0`;
} else {
newVersion = `${major + 1}.0.0`;
}

denoJson.version = newVersion;

await Deno.writeTextFile(
denoJsonPath,
JSON.stringify(denoJson, null, 2) + "\n",
);

const changeLogPath = path.resolve(
import.meta.dirname as string,
"..",
"CHANGELOG.md",
);
const currentChangeLog = await Deno.readTextFile(changeLogPath);

const newContent =
`## [${newVersion}] - ${new Date().toISOString().split("T")[0]}` + "\n\n" +
releaseNotes + "\n";
const allContent = newContent + "\n" + currentChangeLog;

await Deno.writeTextFile(
changeLogPath,
allContent,
);

console.log(newVersion);
Deno.exit(0);