Skip to content

Commit cedea05

Browse files
authored
Merge pull request #480 from mienaiyami/release/v2.23
Release/v2.23
2 parents 14938de + cac51e0 commit cedea05

File tree

9 files changed

+548
-179
lines changed

9 files changed

+548
-179
lines changed

.github/workflows/release.yml

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
echo "Tag points to commit: $COMMIT_SHA"
3535
3636
- name: Check if commit is on master or beta branch
37+
if: ${{ !contains(steps.get-version.outputs.version, 'test') }}
3738
run: |
3839
COMMIT_SHA="${{ steps.get-version.outputs.commit-sha }}"
3940
BRANCHES=$(git branch -r --contains $COMMIT_SHA | grep -E 'origin/(master|beta)' || true)
@@ -45,6 +46,7 @@ jobs:
4546
echo "Commit is on branch(es): $BRANCHES"
4647
4748
- name: Wait for CI to pass
49+
if: ${{ !contains(steps.get-version.outputs.version, 'test') }}
4850
uses: actions/github-script@v7
4951
with:
5052
script: |
@@ -119,6 +121,11 @@ jobs:
119121
- name: Install dependencies
120122
run: pnpm install
121123

124+
- name: Install dpkg-deb for pacman package creation
125+
run: |
126+
sudo apt-get update
127+
sudo apt-get install -y dpkg-dev
128+
122129
- name: forge make deb
123130
run: pnpm make:deb
124131

@@ -132,7 +139,10 @@ jobs:
132139
- uses: actions/upload-artifact@v4
133140
with:
134141
name: linux-build-files
135-
path: ./out/all/*
142+
path: |
143+
./out/all/*
144+
./out/make/*
145+
./build-artifacts/*
136146
if-no-files-found: error
137147

138148
build:
@@ -163,13 +173,29 @@ jobs:
163173
id: linux-build-files-downloader
164174
with:
165175
name: linux-build-files
166-
path: ./out/all/
176+
path: ./linux-artifacts/
177+
merge-multiple: true
178+
179+
- name: Move Linux artifacts and build artifacts
180+
shell: bash
181+
run: |
182+
if [ -d "./linux-artifacts/out" ]; then
183+
mkdir -p ./out
184+
cp -r ./linux-artifacts/out/* ./out/ || true
185+
fi
186+
if [ -d "./linux-artifacts/build-artifacts" ]; then
187+
mkdir -p ./build-artifacts
188+
cp -r ./linux-artifacts/build-artifacts/* ./build-artifacts/ || true
189+
fi
167190
168191
- name: Build for windows
169192
run: |
170193
pnpm make:win32
171194
pnpm make:win64
172195
196+
- name: Generate release artifacts
197+
run: pnpm generate:release
198+
173199
- name: Set version
174200
id: version
175201
shell: bash
@@ -197,8 +223,11 @@ jobs:
197223
with:
198224
tag_name: ${{steps.version.outputs.version}}
199225
name: ${{steps.version.outputs.version}}
200-
files: ./out/all/*
226+
files: |
227+
./out/all/*
228+
./artifacts.json
229+
./checksums.txt
201230
body_path: changelog-temp.md
202231
generate_release_notes: true
203232
discussion_category_name: General
204-
prerelease: ${{ contains(steps.version.outputs.version, 'beta') || contains(steps.version.outputs.version, 'alpha') }}
233+
prerelease: ${{ contains(steps.version.outputs.version, 'beta') || contains(steps.version.outputs.version, 'alpha') || contains(steps.version.outputs.version, 'test') }}

changelog.md

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,14 @@
1212
>
1313
> Issue is only present to users using "Setup" version.
1414
>
15-
> We are actively working on a permanent solution to this issue. For more information, see <https://github.com/mienaiyami/yomikiru/discussions/451>
15+
> I'm actively working on a permanent solution to this issue. For more information, see <https://github.com/mienaiyami/yomikiru/discussions/451>
1616
17-
# 2.22.0
17+
# 2.23.0
1818

19-
- feat: improve directory flattening and error handling for unrar command, fix: #465 & #352.
20-
- fix: #464.
21-
- fix: #460, fix chapter data fetching and sorting logic, fix prev/next chapter selection logic.
22-
- refactor: enhance update installation process with user prompts and improved handling of installation on quit.
23-
- fix: temporary fix for #450, #451.
24-
- chore(dev): migrate to biomejs.
25-
- feat(dev): implement global error handling and reporting system.
19+
- fix: #260, disable drag to scroll for right and bottom edge in reader.
20+
- fix: #458, improve error handling during window destruction process.
21+
- feat(dev): setup arch linux build workflow and better release artifacts generation and files for release.
2622

27-
## 2.21.2
23+
## 2.22.5
2824

29-
- fix: add file exists check for each old settings file, #453.
30-
- fix(test): update GitHub Actions runner to ubuntu-22.04 (GLIBC version 2.35), #452.
31-
32-
## 2.21.1
33-
34-
- Fixed migration of history and bookmarks from JSON to SQLite, #448.
35-
36-
## 2.21.0
37-
38-
All changes are from beta. To join beta, check `Settings -> About -> Update Channel` after downloading this version.
39-
40-
## 2.21.0-beta.4
41-
42-
<https://github.com/mienaiyami/yomikiru/releases/tag/v2.21.0-beta.4>
43-
44-
## 2.21.0-beta.3
45-
46-
<https://github.com/mienaiyami/yomikiru/releases/tag/v2.21.0-beta.3>
47-
48-
## 2.21.0-beta.2
49-
50-
<https://github.com/mienaiyami/yomikiru/releases/tag/v2.21.0-beta.2>
51-
52-
## 2.21.0-beta.1
53-
54-
<https://github.com/mienaiyami/yomikiru/releases/tag/v2.21.0-beta.1>
25+
<https://github.com/mienaiyami/yomikiru/releases/tag/v2.22.5>

forge.config.ts

Lines changed: 101 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
1+
import { execSync } from "node:child_process";
12
import fs from "node:fs";
23
import path from "node:path";
34
import { MakerDeb } from "@electron-forge/maker-deb";
45
import { MakerSquirrel } from "@electron-forge/maker-squirrel";
56
import { MakerZIP } from "@electron-forge/maker-zip";
67
import { AutoUnpackNativesPlugin } from "@electron-forge/plugin-auto-unpack-natives";
78
import { WebpackPlugin } from "@electron-forge/plugin-webpack";
8-
import type { ForgeConfig } from "@electron-forge/shared-types";
9+
import type { ForgeConfig, ForgeMakeResult } from "@electron-forge/shared-types";
10+
import packageJSON from "./package.json";
911
import { mainConfig } from "./webpack/webpack.main.config";
1012
import { preloadConfig } from "./webpack/webpack.preload.config";
1113
import { rendererConfig } from "./webpack/webpack.renderer.config";
1214

13-
// ! its not possible to build all targets at once anymore, because of `better-sqlite3` rebuild
15+
// ! its not possible to build all targets arch at once for windows anymore, because of `better-sqlite3` rebuild
16+
17+
const MAIN_OUT_DIR = path.resolve("./out/all");
18+
19+
const { productName: appName } = packageJSON;
1420

1521
const config: ForgeConfig = {
1622
packagerConfig: {
17-
name: "Yomikiru",
23+
name: appName,
1824
asar: true,
1925
// needed for migrating better-sqlite3
2026
extraResource: ["./drizzle"],
21-
executableName: process.platform === "win32" ? "Yomikiru" : "yomikiru",
27+
executableName: process.platform === "win32" ? appName : appName.toLowerCase(),
2228
},
23-
// rebuildConfig: {
24-
// extraModules: ["better-sqlite3"],
25-
// force: true,
26-
// },
2729
plugins: [
2830
new AutoUnpackNativesPlugin({}),
2931
new WebpackPlugin({
@@ -69,117 +71,102 @@ const config: ForgeConfig = {
6971
),
7072
],
7173
hooks: {
72-
postMake: async (_config, makeResults) => {
73-
// const appName = config.packagerConfig.name;
74-
const appName = "Yomikiru";
75-
const appVersion = makeResults[0].packageJSON.version;
76-
77-
const MAP = {
78-
"win32+zip+ia32": {
79-
name: `${appName}-win32-v${appVersion}-Portable.zip`,
80-
text: "Download 32-bit Portable (zip)",
81-
icon: "windows&logoColor=blue",
82-
},
83-
"win32+zip+x64": {
84-
name: `${appName}-win32-v${appVersion}-Portable-x64.zip`,
85-
text: "Download 64-bit Portable (zip)",
86-
icon: "windows&logoColor=blue",
87-
},
88-
"win32+exe+ia32": {
89-
name: `${appName}-v${appVersion}-Setup.exe`,
90-
text: "Download 32-bit Setup (exe)",
91-
icon: "windows&logoColor=blue",
92-
},
93-
"win32+exe+x64": {
94-
name: `${appName}-v${appVersion}-Setup-x64.exe`,
95-
text: "Download 64-bit Setup (exe)",
96-
icon: "windows&logoColor=blue",
97-
},
98-
"linux+deb+x64": {
99-
name: `${appName}-v${appVersion}-amd64.deb`,
100-
text: "Download 64-bit Linux (Debian)",
101-
icon: "debian&logoColor=red",
102-
},
103-
"linux+deb+amd64": {
104-
name: `${appName}-v${appVersion}-amd64.deb`,
105-
text: "Download 64-bit Linux (Debian)",
106-
icon: "debian&logoColor=red",
107-
},
108-
"darwin+zip+x64": {
109-
name: `${appName}-v${appVersion}-macOS-x64.zip`,
110-
text: "Download 64-bit macOS (zip)",
111-
icon: "apple&logoColor=black",
112-
},
74+
postMake: async (_config: unknown, makeResults: ForgeMakeResult[]) => {
75+
const BUILD_ARTIFACTS_DIR = path.resolve("./build-artifacts");
76+
77+
if (!fs.existsSync(BUILD_ARTIFACTS_DIR)) {
78+
fs.mkdirSync(BUILD_ARTIFACTS_DIR, { recursive: true });
79+
}
80+
81+
if (!fs.existsSync(MAIN_OUT_DIR)) {
82+
fs.mkdirSync(MAIN_OUT_DIR, { recursive: true });
83+
}
84+
85+
const platform = makeResults[0].platform;
86+
const arch = makeResults[0].arch;
87+
const timestamp = Date.now();
88+
const filename = `${platform}-${arch}-${timestamp}.json`;
89+
const filePath = path.join(BUILD_ARTIFACTS_DIR, filename);
90+
91+
// normalize paths to be relative to process.cwd() for cross-platform compatibility
92+
const normalizePath = (filePath: string): string => {
93+
const cwd = process.cwd();
94+
if (path.isAbsolute(filePath)) {
95+
const relative = path.relative(cwd, filePath);
96+
return relative.startsWith("..") ? filePath : relative;
97+
}
98+
return filePath;
11399
};
114100

115-
const makeDlBtn = ({
116-
text,
117-
name,
118-
icon,
119-
url,
120-
}: {
121-
text: string;
122-
name: string;
123-
icon: string;
124-
url: string;
125-
}) =>
126-
`[![${text}](https://img.shields.io/badge/${encodeURIComponent(text).replace(
127-
/-/g,
128-
"--",
129-
)}-${encodeURIComponent(name).replace(/-/g, "--")}-brightgreen?logo=${icon})](${
130-
url
131-
}/releases/download/v${appVersion}/${name})\n`;
132-
133-
const mainOutDir = path.resolve("./out/all");
134-
135-
// const filesToUploadTxt = "files-to-upload.txt";
136-
const downloadBtnsTxt = "download-btns.txt";
137-
const initialDownloadBtns =
138-
`## Downloads\n\n` +
139-
// linux is built in another job and downloaded here as artifact
140-
makeDlBtn({
141-
...MAP["linux+deb+amd64"],
142-
url: makeResults[0].packageJSON.author.url,
143-
}) +
144-
"\n";
145-
146-
if (!fs.existsSync(downloadBtnsTxt)) fs.writeFileSync(downloadBtnsTxt, initialDownloadBtns, "utf-8");
147-
// if (!fs.existsSync(filesToUploadTxt))
148-
// fs.writeFileSync(
149-
// filesToUploadTxt,
150-
// path.join(mainOutDir, MAP["linux+deb+amd64"].name.replace(/\\/g, "/")) + " ",
151-
// "utf-8",
152-
// );
153-
154-
if (!fs.existsSync(mainOutDir)) fs.mkdirSync(mainOutDir);
155-
156-
makeResults.forEach((res, idx) => {
157-
// on windows squirrel, there are 3 artifacts and 2nd is the executable
158-
const mainIdx = res.artifacts.length === 1 ? 0 : 1;
159-
const key =
160-
`${res.platform}+${path.extname(res.artifacts[mainIdx]).replace(".", "")}+${res.arch}` as keyof typeof MAP;
161-
if (!MAP[key]) {
162-
console.error(`Unknown artifact: ${key}`);
163-
process.exit(1);
101+
const artifactsToSave = makeResults.map((result) => ({
102+
platform: result.platform,
103+
arch: result.arch,
104+
artifacts: result.artifacts.map(normalizePath),
105+
}));
106+
107+
let pacmanArtifactPath: string | null = null;
108+
if (platform === "linux") {
109+
const appName = makeResults[0].packageJSON.productName;
110+
const appVersion = makeResults[0].packageJSON.version;
111+
const expectedPkgName = `${appName}-v${appVersion}-x86_64.pkg.tar.xz`;
112+
const pkgFile = path.join(MAIN_OUT_DIR, expectedPkgName);
113+
114+
const debArtifact = makeResults[0].artifacts.find((a: string) => a.endsWith(".deb"));
115+
if (debArtifact && fs.existsSync(debArtifact) && !fs.existsSync(pkgFile)) {
116+
try {
117+
const tempDir = path.join(MAIN_OUT_DIR, `temp-pacman-${Date.now()}`);
118+
fs.mkdirSync(tempDir, { recursive: true });
119+
120+
execSync(`dpkg-deb -x "${debArtifact}" "${tempDir}/extracted"`, { stdio: "inherit" });
121+
execSync(`dpkg-deb -e "${debArtifact}" "${tempDir}/control"`, { stdio: "inherit" });
122+
123+
const pkgDir = path.join(tempDir, "pkg");
124+
const extractedDir = path.join(tempDir, "extracted");
125+
if (fs.existsSync(extractedDir)) {
126+
fs.mkdirSync(pkgDir, { recursive: true });
127+
const usrDir = path.join(pkgDir, "usr");
128+
fs.cpSync(extractedDir, usrDir, { recursive: true });
129+
}
130+
131+
const pkgInfoPath = path.join(pkgDir, ".PKGINFO");
132+
const stats = fs.statSync(debArtifact);
133+
const pkgInfo = `pkgname = ${appName.toLowerCase()}
134+
pkgver = ${appVersion}
135+
pkgdesc = ${packageJSON.description}
136+
url = ${packageJSON.author.url}
137+
packager = ${packageJSON.author.name}
138+
arch = x86_64
139+
size = ${stats.size}
140+
license = ${packageJSON.license}
141+
`;
142+
fs.writeFileSync(pkgInfoPath, pkgInfo);
143+
144+
const mtreePath = path.join(pkgDir, ".MTREE");
145+
fs.writeFileSync(mtreePath, "#mtree\n");
146+
147+
execSync(
148+
`cd "${pkgDir}" && tar -cJf "${pkgFile}" .PKGINFO .MTREE usr 2>/dev/null || (tar -cf - .PKGINFO .MTREE usr | xz > "${pkgFile}")`,
149+
{ stdio: "inherit" },
150+
);
151+
152+
console.log(`Created pacman package: ${pkgFile}`);
153+
pacmanArtifactPath = normalizePath(pkgFile);
154+
155+
fs.rmSync(tempDir, { recursive: true, force: true });
156+
} catch (error) {
157+
console.warn(`Failed to create pacman package: ${error}`);
158+
}
159+
} else if (fs.existsSync(pkgFile)) {
160+
pacmanArtifactPath = normalizePath(pkgFile);
164161
}
165-
const { name, text, icon } = MAP[key];
166-
167-
const newPath = path.join(mainOutDir, name);
168-
fs.renameSync(res.artifacts[mainIdx], newPath);
169-
170-
makeResults[idx].artifacts[mainIdx] = newPath;
171-
172-
// fs.appendFileSync(filesToUploadTxt, newPath.replace(/\\/g, "/") + " ", "utf-8");
162+
}
173163

174-
const downloadBtn = makeDlBtn({
175-
text,
176-
name,
177-
icon,
178-
url: res.packageJSON.author.url,
179-
});
164+
if (pacmanArtifactPath) {
165+
artifactsToSave[0].artifacts.push(pacmanArtifactPath);
166+
}
180167

181-
fs.appendFileSync(downloadBtnsTxt, downloadBtn, "utf-8");
182-
});
168+
fs.writeFileSync(filePath, JSON.stringify(artifactsToSave, null, 2), "utf-8");
169+
console.log(`Saved build artifacts to: ${filePath}`);
183170

184171
return makeResults;
185172
},

0 commit comments

Comments
 (0)