Skip to content

Commit 7a70eac

Browse files
authored
save
1 parent 508612c commit 7a70eac

File tree

4 files changed

+60
-20
lines changed

4 files changed

+60
-20
lines changed

.github/workflows/npm-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: npm publish
22
on:
33
release:
4-
types: released
4+
types: published
55
workflow_dispatch:
66
inputs:
77
tag:
@@ -30,4 +30,4 @@ jobs:
3030
- run: npm publish --provenance --tag "$TAG"
3131
env:
3232
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
33-
TAG: ${{ inputs.tag }}
33+
TAG: ${{ inputs.tag || ((github.event.release.prerelease && 'next') || 'latest') }}

README.md

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,35 @@ console.log(cut);
8080
//=> 'C:\\myproject\\node_modules\\portablegit\\out\\portablegit\\usr\\bin\\cut'
8181
```
8282

83-
This can be useful if you need to resolve the path to a specific binary (`cat.exe`, `cut.exe`, etc.) that isn't exposed by default. Note that you don't need to use the `.exe` suffix since Windows will helpfully add `.exe` suffix when attempting to run the file.
83+
This can be useful if you need to resolve the path to a specific binary (`cat.exe`, `cut.exe`, etc.) that isn't exposed by default.
8484

8585
## Development
8686

8787
![Node.js](https://img.shields.io/static/v1?style=for-the-badge&message=Node.js&color=339933&logo=Node.js&logoColor=FFFFFF&label=)
8888
![Windows](https://img.shields.io/static/v1?style=for-the-badge&message=Windows&color=0078D4&logo=Windows&logoColor=FFFFFF&label=)
8989

90-
You'll need a Windows computer to test this package locally. You can run `npm run build` to make sure everything looks good locally. `npm run generate` redownloads the configured version of Git for Windows PortableGit as a 7zip self-extracting archive.
91-
92-
Each new upcoming release will first be tried as a prerelease `X.Y.Z-rc.N` first to make sure that everything is 99% guarenteed to work when autopublishing. Make sure to `--tag next`!
93-
94-
This package currently relies on **manual updates** to bump the Git for Windows version. Make sure you update the `version` field in `package.json` and the `gfwVersion` and `filename` constants in `scripts.js` `generate()`.
95-
96-
You can publish a release to GitHub releases and npm using [the npm publish GitHub actions workflow](https://github.com/jcbhmr/portablegit.js/actions/workflows/npm-publish.yml).
90+
- You'll need a Windows computer to test this package locally.
91+
- You can run `npm run build` to make sure everything looks good locally.
92+
- `npm run generate` redownloads the configured version of Git for Windows PortableGit as a 7zip self-extracting archive.
93+
- Each new upcoming release should first be tried as a prerelease `X.Y.Z-rc.N`.
94+
- This package currently relies on **manual updates** to bump the Git for Windows version.
95+
- Make sure you update the `version` field in `package.json` and the constants in `scripts.js` `generate()`.
96+
- This project may in the future start squashing Git history or use Git LFS to reduce the repository size.
97+
98+
Steps to release:
99+
100+
1. Change the version in `package.json` to the new version RC like `2.45.21-rc.1`.
101+
2. Change the version in `scripts.js` `generate()` to the new version tag like `2.45.2.windows.1`.
102+
3. Change the file name in `scripts.js` `generate()` to the new version tag like `PortableGit-2.45.2-64-bit.7z.exe`.
103+
4. Run `npm run generate` to vendor the new version.
104+
5. Run `npm run build` and `npm test` to make sure everything works. Check that `git --version` matches the new version.
105+
6. Push to GitHub.
106+
7. Create a new release on GitHub with the new `v2.45.21-rc.1` tag.
107+
8. Watch and wait for CI to pass. This will publush a `next` `2.45.21-rc.1` version to npm.
108+
9. Make sure it works using `npx -p portablegit@next git --version` or similar.
109+
10. Change the version in `package.json` to the new version like `2.45.21`.
110+
11. Push to GitHub.
111+
12. Create a new release on GitHub with the new `v2.45.21` tag.
112+
13. Watch and wait for CI to pass. This will publish a `latest` `2.45.21` version to npm.
113+
114+
**TL;DR:** Do a prelease `-rc.1` first to make sure things work before doing the actual release. This lets us mirror the Git for Windows version numbers without a special suffix if we get things wrong.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"clean": "rimraf out",
5151
"test": "node --test",
5252
"format": "prettier -w .",
53-
"postinstall": "node scripts.js postinstall"
53+
"postinstall": "node scripts.js postinstall",
54+
"squash": "node scripts.js squash"
5455
},
5556
"os": [
5657
"win32"

scripts.js

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,55 @@ async function generate() {
1414
console.debug("url=%o", url);
1515
const response = await fetch(url);
1616
assert(response.status === 200, `${response.status} ${response.url}`);
17-
const dest = new URL(import.meta.resolve("./PortableGit-64-bit.7z.exe"))
18-
await response.body.pipeTo(
19-
Writable.toWeb(createWriteStream(dest)),
20-
);
17+
const dest = new URL(import.meta.resolve("./PortableGit-64-bit.7z.exe"));
18+
await response.body.pipeTo(Writable.toWeb(createWriteStream(dest)));
2119
console.log("Downloaded %s to %s", url, dest);
2220
}
2321

2422
// POSTINSTALL RUNS WITH NO DEV DEPENDENCIES!
2523
async function postinstall() {
2624
const { $ } = await import("execa");
2725
const { existsSync } = await import("node:fs");
28-
const { sep } = await import("node:path")
29-
const { fileURLToPath } = await import("node:url")
26+
const { sep } = await import("node:path");
27+
const { fileURLToPath } = await import("node:url");
3028

31-
if (process.env.INIT_CWD === process.cwd() || process.env.INIT_CWD?.startsWith(process.cwd() + sep)) {
29+
if (
30+
process.env.INIT_CWD === process.cwd() ||
31+
process.env.INIT_CWD?.startsWith(process.cwd() + sep)
32+
) {
3233
// Skip! Local dev `npm install`, not as a dep.
34+
console.debug("Skipping postinstall in local dev");
3335
} else {
3436
// May have already been installed once and had the files deleted.
3537
if (existsSync(new URL(import.meta.resolve("./out/post-install.bat")))) {
36-
await $({
38+
const { failed, exitCode, signal, signalDescription, command } = await $({
3739
cwd: fileURLToPath(import.meta.resolve("./out/")),
3840
stdio: "inherit",
3941
reject: false,
42+
verbose: "short",
4043
})`post-install.bat`;
44+
if (failed) {
45+
console.error("$ %o failed", command);
46+
if (exitCode) {
47+
console.error("exitCode=%o", exitCode);
48+
} else if (signal) {
49+
console.error(
50+
"signal=%o signalDescription=%o",
51+
signal,
52+
signalDescription
53+
);
54+
}
55+
}
4156
} else {
4257
// Assume already ran.
4358
}
4459
}
4560
}
4661

47-
await { generate, postinstall }[process.argv[2]]();
62+
async function squash() {
63+
const { $ } = await import("execa");
64+
65+
await $({ stdio: "inherit", verbose: "short" })`git --version`;
66+
}
67+
68+
await { generate, postinstall, squash }[process.argv[2]]();

0 commit comments

Comments
 (0)