Skip to content

Commit ea80744

Browse files
authored
Merge pull request #133 from nanoapi-io/chore/release-binaries
ci for binaries release
2 parents f382f0d + 4f98552 commit ea80744

File tree

8 files changed

+118
-28
lines changed

8 files changed

+118
-28
lines changed

.github/workflows/release.yml

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,17 @@ on:
88
workflow_dispatch:
99
inputs:
1010
release_type:
11+
type: choice
1112
description: "Release type: patch, minor, major"
1213
required: true
13-
default: patch
14+
options:
15+
- patch
16+
- minor
17+
- major
18+
release_notes:
19+
type: string
20+
description: "Release notes"
21+
required: true
1422

1523
jobs:
1624
release:
@@ -28,24 +36,33 @@ jobs:
2836
with:
2937
token: ${{ steps.generate_token.outputs.token }}
3038

31-
- name: Set up Node.js
32-
uses: actions/setup-node@v3
39+
- name: Set up Deno
40+
uses: denoland/setup-deno@v2
3341
with:
34-
node-version: "22"
42+
deno-version: "2.x"
3543

36-
- name: Install dependencies
37-
run: npm install
44+
- name: Compile
45+
run: |
46+
deno task compie:all
3847
39-
- name: Login with git
48+
- name: Bump version
49+
id: bump_version
4050
run: |
41-
git config --global user.email "info@nanoapi.io"
42-
git config --global user.name "nanoapi.io"
51+
VERSION=$(deno run -A scripts/bump_version.ts ${{ inputs.release_type }} ${{ inputs.release_notes }})
52+
echo "release_version=$VERSION" >> $GITHUB_OUTPUT
4353
44-
- name: Login to npm registry
45-
run: npm set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}"
54+
- name: Create release
55+
uses: softprops/action-gh-release@v1
56+
with:
57+
body: ${{ inputs.release_notes }}
58+
tag_name: v${{ steps.bump_version.outputs.release_version }}
59+
files: |
60+
dist/*
61+
CHANGELOG.md
4662
47-
- name: Run release-it for CLI
48-
run: npm run release -- ${{ github.event.inputs.release_type }} --ci
49-
env:
50-
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
51-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
63+
- name: Commit and push changes
64+
run: |
65+
# Commit and push changes
66+
git add CHANGELOG.md
67+
git commit -m "[skip ci] update changelog for version ${{ steps.bump_version.outputs.release_version }}"
68+
git push
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# Changelog
2-
3-
## [Unreleased]
4-
51
## [1.0.7] - 2025-04-30
62

73
Fix some small bug on the FE, mainly unify the colors of edges and their

deno.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
2-
"workspace": ["./packages/app", "./packages/cli", "./packages/shared"],
2+
"version": "1.0.7",
3+
"workspace": [
4+
"./packages/app",
5+
"./packages/cli",
6+
"./packages/shared"
7+
],
38
"nodeModulesDir": "auto",
49
"tasks": {
510
"dev:app": "deno task --config packages/app/deno.json dev",

deno.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli/deno.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "@napi/cli",
3-
"version": "1.0.7",
43
"exports": "./src/index.ts",
54
"imports": {
65
"@napi/shared": "../shared/src/index.ts",
@@ -19,10 +18,10 @@
1918
},
2019
"tasks": {
2120
"dev": "NODE_ENV=development deno run --allow-all --watch src/index.ts",
22-
"compile": "deno compile --allow-all --include=../app/dist --output=dist/napi src/index.ts",
23-
"compile-linux": "deno compile --allow-all --include=../app/dist --output=dist/napi.linux --target=x86_64-unknown-linux-gnu src/index.ts",
24-
"compile-macos": "deno compile --allow-all --include=../app/dist --output=dist/napi.macos --target=x86_64-apple-darwin src/index.ts",
25-
"compile-windows": "deno compile --allow-all --include=../app/dist --output=dist/napi.exe --target=x86_64-pc-windows-msvc src/index.ts",
21+
"compile": "deno compile --allow-all --include=../app/dist --output=../../dist/napi src/index.ts",
22+
"compile-linux": "deno compile --allow-all --include=../app/dist --output=../../dist/napi.linux --target=x86_64-unknown-linux-gnu src/index.ts",
23+
"compile-macos": "deno compile --allow-all --include=../app/dist --output=../../dist/napi.macos --target=x86_64-apple-darwin src/index.ts",
24+
"compile-windows": "deno compile --allow-all --include=../app/dist --output=../../dist/napi.exe --target=x86_64-pc-windows-msvc src/index.ts",
2625
"test": "deno test --allow-all"
2726
}
2827
}

packages/cli/src/cli/helpers/checkNpmVersion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import localPackageJson from "../../../deno.json" with { type: "json" };
1+
import localPackageJson from "../../../../../deno.json" with { type: "json" };
22
import process from "node:process";
33

44
export async function checkVersionMiddleware() {

packages/cli/src/telemetry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { EventEmitter } from "node:events";
22
import os from "node:os";
33
import { getOrCreateGlobalConfig } from "./config/globalConfig.ts";
4-
import denoJson from "../deno.json" with { type: "json" };
4+
import denoJson from "../../../deno.json" with { type: "json" };
55
import process from "node:process";
66

77
export enum TelemetryEvents {

scripts/bump_version.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import path from "node:path";
2+
3+
const releaseType: string = Deno.args[0];
4+
if (
5+
!releaseType ||
6+
releaseType !== "patch" && releaseType !== "minor" && releaseType !== "major"
7+
) {
8+
console.error("Invalid release type");
9+
Deno.exit(1);
10+
}
11+
const releaseNotes: string = Deno.args[1];
12+
if (!releaseNotes) {
13+
console.error("Release notes are required");
14+
Deno.exit(1);
15+
}
16+
17+
const denoJsonPath = path.resolve(
18+
import.meta.dirname as string,
19+
"..",
20+
"deno.json",
21+
);
22+
const denoJson = JSON.parse(await Deno.readTextFile(denoJsonPath)) as {
23+
version: string;
24+
};
25+
26+
const [major, minor, patch] = denoJson.version.split(".").map(Number);
27+
28+
let newVersion: string;
29+
30+
if (releaseType === "patch") {
31+
newVersion = `${major}.${minor}.${patch + 1}`;
32+
} else if (releaseType === "minor") {
33+
newVersion = `${major}.${minor + 1}.0`;
34+
} else {
35+
newVersion = `${major + 1}.0.0`;
36+
}
37+
38+
denoJson.version = newVersion;
39+
40+
await Deno.writeTextFile(
41+
denoJsonPath,
42+
JSON.stringify(denoJson, null, 2) + "\n",
43+
);
44+
45+
const changeLogPath = path.resolve(
46+
import.meta.dirname as string,
47+
"..",
48+
"CHANGELOG.md",
49+
);
50+
const currentChangeLog = await Deno.readTextFile(changeLogPath);
51+
52+
const newContent =
53+
`## [${newVersion}] - ${new Date().toISOString().split("T")[0]}` + "\n\n" +
54+
releaseNotes + "\n";
55+
const allContent = newContent + "\n" + currentChangeLog;
56+
57+
await Deno.writeTextFile(
58+
changeLogPath,
59+
allContent,
60+
);
61+
62+
console.log(newVersion);
63+
Deno.exit(0);

0 commit comments

Comments
 (0)