Skip to content

Commit 0d43d35

Browse files
committed
fix(ci): unblock windows and homebrew releases
1 parent a79ed1b commit 0d43d35

3 files changed

Lines changed: 159 additions & 45 deletions

File tree

.github/workflows/backfill-release-assets.yml

Lines changed: 64 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ env:
1717
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
1818

1919
jobs:
20-
build-binaries:
20+
build-unix-binaries:
2121
name: Build ${{ matrix.os }} release assets
2222
runs-on: ${{ matrix.os }}
2323
timeout-minutes: 30
@@ -30,15 +30,9 @@ jobs:
3030
- os: ubuntu-latest
3131
asset_os: linux
3232
asset_arch: amd64
33-
archive_format: tar.gz
3433
- os: macos-latest
3534
asset_os: darwin
3635
asset_arch: arm64
37-
archive_format: tar.gz
38-
- os: windows-latest
39-
asset_os: windows
40-
asset_arch: amd64
41-
archive_format: zip
4236

4337
steps:
4438
- name: Check out repository
@@ -71,21 +65,69 @@ jobs:
7165
$assetBase = "putio-cli-$version-${{ matrix.asset_os }}-${{ matrix.asset_arch }}"
7266
$releaseDir = ".artifacts/release"
7367
New-Item -ItemType Directory -Force -Path $releaseDir | Out-Null
68+
$binaryPath = ".artifacts/sea/putio"
69+
$stageDir = "$releaseDir/stage"
70+
New-Item -ItemType Directory -Force -Path $stageDir | Out-Null
71+
Copy-Item $binaryPath "$stageDir/putio"
72+
tar -czf "$releaseDir/$assetBase.tar.gz" -C $stageDir putio
73+
Remove-Item -Recurse -Force $stageDir
74+
$assetPath = "$releaseDir/$assetBase.tar.gz"
75+
76+
$hash = (Get-FileHash -Algorithm SHA256 $assetPath).Hash.ToLower()
77+
"$hash $(Split-Path $assetPath -Leaf)" | Out-File "$assetPath.sha256" -Encoding ascii -NoNewline
78+
79+
- name: Generate SHA-256 checksums
80+
shell: pwsh
81+
run: Get-ChildItem .artifacts/release
82+
83+
- name: Upload binary assets to the GitHub release
84+
uses: softprops/action-gh-release@v2
85+
with:
86+
tag_name: ${{ inputs.tag_name }}
87+
files: |
88+
.artifacts/release/*
89+
90+
build-windows-binary:
91+
name: Build windows-latest release assets
92+
runs-on: windows-latest
93+
timeout-minutes: 30
94+
permissions:
95+
contents: write
96+
97+
steps:
98+
- name: Check out repository
99+
uses: actions/checkout@v6
100+
with:
101+
fetch-depth: 0
102+
103+
- name: Check out release tag
104+
run: git checkout ${{ inputs.tag_name }}
105+
106+
- name: Set up Vite+
107+
uses: voidzero-dev/setup-vp@v1
108+
with:
109+
node-version-file: ".node-version"
110+
cache: true
111+
112+
- name: Install dependencies
113+
run: vp install
114+
115+
- name: Build SEA binary
116+
run: vp run build:sea
74117

75-
if ("${{ runner.os }}" -eq "Windows") {
76-
$binaryPath = ".artifacts/sea/putio.exe"
77-
Compress-Archive -Path $binaryPath -DestinationPath "$releaseDir/$assetBase.zip" -Force
78-
$assetPath = "$releaseDir/$assetBase.zip"
79-
} else {
80-
$binaryPath = ".artifacts/sea/putio"
81-
$stageDir = "$releaseDir/stage"
82-
New-Item -ItemType Directory -Force -Path $stageDir | Out-Null
83-
Copy-Item $binaryPath "$stageDir/putio"
84-
tar -czf "$releaseDir/$assetBase.tar.gz" -C $stageDir putio
85-
Remove-Item -Recurse -Force $stageDir
86-
$assetPath = "$releaseDir/$assetBase.tar.gz"
87-
}
118+
- name: Verify SEA binary
119+
run: vp run verify:sea
88120

121+
- name: Package release assets
122+
shell: pwsh
123+
run: |
124+
$version = "${{ inputs.tag_name }}".TrimStart("v")
125+
$assetBase = "putio-cli-$version-windows-amd64"
126+
$releaseDir = ".artifacts/release"
127+
New-Item -ItemType Directory -Force -Path $releaseDir | Out-Null
128+
$binaryPath = ".artifacts/sea/putio.exe"
129+
Compress-Archive -Path $binaryPath -DestinationPath "$releaseDir/$assetBase.zip" -Force
130+
$assetPath = "$releaseDir/$assetBase.zip"
89131
$hash = (Get-FileHash -Algorithm SHA256 $assetPath).Hash.ToLower()
90132
"$hash $(Split-Path $assetPath -Leaf)" | Out-File "$assetPath.sha256" -Encoding ascii -NoNewline
91133
@@ -104,7 +146,7 @@ jobs:
104146
if: inputs.update_homebrew_tap
105147
name: Update Homebrew tap
106148
needs:
107-
- build-binaries
149+
- build-unix-binaries
108150
runs-on: ubuntu-latest
109151
timeout-minutes: 20
110152
permissions:
@@ -119,6 +161,7 @@ jobs:
119161
github_token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
120162
commit_owner: semantic-release-bot
121163
commit_email: ui@put.io
164+
branch: main
122165
formula_folder: Formula
123166
formula_name: putio
124167
install: 'bin.install "putio"'

.github/workflows/ci.yml

Lines changed: 67 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9292
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
9393

94-
build-binaries:
94+
build-unix-binaries:
9595
if: needs.release.outputs.new_release_published == 'true'
9696
name: Build ${{ matrix.os }} release assets
9797
needs:
@@ -107,15 +107,9 @@ jobs:
107107
- os: ubuntu-latest
108108
asset_os: linux
109109
asset_arch: amd64
110-
archive_format: tar.gz
111110
- os: macos-latest
112111
asset_os: darwin
113112
asset_arch: arm64
114-
archive_format: tar.gz
115-
- os: windows-latest
116-
asset_os: windows
117-
asset_arch: amd64
118-
archive_format: zip
119113

120114
steps:
121115
- name: Check out repository
@@ -148,21 +142,72 @@ jobs:
148142
$assetBase = "putio-cli-$version-${{ matrix.asset_os }}-${{ matrix.asset_arch }}"
149143
$releaseDir = ".artifacts/release"
150144
New-Item -ItemType Directory -Force -Path $releaseDir | Out-Null
145+
$binaryPath = ".artifacts/sea/putio"
146+
$stageDir = "$releaseDir/stage"
147+
New-Item -ItemType Directory -Force -Path $stageDir | Out-Null
148+
Copy-Item $binaryPath "$stageDir/putio"
149+
tar -czf "$releaseDir/$assetBase.tar.gz" -C $stageDir putio
150+
Remove-Item -Recurse -Force $stageDir
151+
$assetPath = "$releaseDir/$assetBase.tar.gz"
152+
153+
$hash = (Get-FileHash -Algorithm SHA256 $assetPath).Hash.ToLower()
154+
"$hash $(Split-Path $assetPath -Leaf)" | Out-File "$assetPath.sha256" -Encoding ascii -NoNewline
155+
156+
- name: Generate SHA-256 checksums
157+
shell: pwsh
158+
run: Get-ChildItem .artifacts/release
159+
160+
- name: Upload binary assets to the GitHub release
161+
uses: softprops/action-gh-release@v2
162+
with:
163+
tag_name: ${{ needs.release.outputs.new_release_git_tag }}
164+
files: |
165+
.artifacts/release/*
151166
152-
if ("${{ runner.os }}" -eq "Windows") {
153-
$binaryPath = ".artifacts/sea/putio.exe"
154-
Compress-Archive -Path $binaryPath -DestinationPath "$releaseDir/$assetBase.zip" -Force
155-
$assetPath = "$releaseDir/$assetBase.zip"
156-
} else {
157-
$binaryPath = ".artifacts/sea/putio"
158-
$stageDir = "$releaseDir/stage"
159-
New-Item -ItemType Directory -Force -Path $stageDir | Out-Null
160-
Copy-Item $binaryPath "$stageDir/putio"
161-
tar -czf "$releaseDir/$assetBase.tar.gz" -C $stageDir putio
162-
Remove-Item -Recurse -Force $stageDir
163-
$assetPath = "$releaseDir/$assetBase.tar.gz"
164-
}
167+
build-windows-binary:
168+
if: needs.release.outputs.new_release_published == 'true'
169+
name: Build windows-latest release assets
170+
needs:
171+
- release
172+
runs-on: windows-latest
173+
timeout-minutes: 30
174+
permissions:
175+
contents: write
165176

177+
steps:
178+
- name: Check out repository
179+
uses: actions/checkout@v6
180+
with:
181+
fetch-depth: 0
182+
183+
- name: Check out release tag
184+
run: git checkout ${{ needs.release.outputs.new_release_git_tag }}
185+
186+
- name: Set up Vite+
187+
uses: voidzero-dev/setup-vp@v1
188+
with:
189+
node-version-file: ".node-version"
190+
cache: true
191+
192+
- name: Install dependencies
193+
run: vp install
194+
195+
- name: Build SEA binary
196+
run: vp run build:sea
197+
198+
- name: Verify SEA binary
199+
run: vp run verify:sea
200+
201+
- name: Package release assets
202+
shell: pwsh
203+
run: |
204+
$version = "${{ needs.release.outputs.new_release_version }}"
205+
$assetBase = "putio-cli-$version-windows-amd64"
206+
$releaseDir = ".artifacts/release"
207+
New-Item -ItemType Directory -Force -Path $releaseDir | Out-Null
208+
$binaryPath = ".artifacts/sea/putio.exe"
209+
Compress-Archive -Path $binaryPath -DestinationPath "$releaseDir/$assetBase.zip" -Force
210+
$assetPath = "$releaseDir/$assetBase.zip"
166211
$hash = (Get-FileHash -Algorithm SHA256 $assetPath).Hash.ToLower()
167212
"$hash $(Split-Path $assetPath -Leaf)" | Out-File "$assetPath.sha256" -Encoding ascii -NoNewline
168213
@@ -182,7 +227,7 @@ jobs:
182227
name: Update Homebrew tap
183228
needs:
184229
- release
185-
- build-binaries
230+
- build-unix-binaries
186231
runs-on: ubuntu-latest
187232
timeout-minutes: 20
188233
permissions:
@@ -197,6 +242,7 @@ jobs:
197242
github_token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
198243
commit_owner: semantic-release-bot
199244
commit_email: ui@put.io
245+
branch: main
200246
formula_folder: Formula
201247
formula_name: putio
202248
install: 'bin.install "putio"'

scripts/build-sea.mjs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,24 @@ const seaSentinelFuse = "NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2";
2222
const localBin = (name) =>
2323
join(root, "node_modules", ".bin", `${name}${platform === "win32" ? ".cmd" : ""}`);
2424

25-
const run = (command, args, options = {}) =>
26-
execFileSync(command, args, {
25+
const run = (command, args, options = {}) => {
26+
if (platform === "win32" && /\.(cmd|bat)$/i.test(command)) {
27+
return execFileSync(process.env.comspec ?? "cmd.exe", ["/d", "/s", "/c", command, ...args], {
28+
cwd: root,
29+
encoding: "utf8",
30+
stdio: "inherit",
31+
windowsVerbatimArguments: true,
32+
...options,
33+
});
34+
}
35+
36+
return execFileSync(command, args, {
2737
cwd: root,
2838
encoding: "utf8",
2939
stdio: "inherit",
3040
...options,
3141
});
42+
};
3243

3344
const downloadFile = async (url, destination) => {
3445
await mkdir(dirname(destination), { recursive: true });
@@ -83,7 +94,21 @@ const resolveOfficialNodeRuntime = async () => {
8394
);
8495

8596
mkdirSync(runtimeDir, { recursive: true });
86-
run("tar", ["-xf", archivePath, "-C", runtimeDir]);
97+
if (platform === "win32") {
98+
run(
99+
process.env.SYSTEMROOT
100+
? join(process.env.SYSTEMROOT, "System32", "WindowsPowerShell", "v1.0", "powershell.exe")
101+
: "powershell.exe",
102+
[
103+
"-NoLogo",
104+
"-NoProfile",
105+
"-Command",
106+
`Expand-Archive -LiteralPath '${archivePath.replace(/'/g, "''")}' -DestinationPath '${runtimeDir.replace(/'/g, "''")}' -Force`,
107+
],
108+
);
109+
} else {
110+
run("tar", ["-xf", archivePath, "-C", runtimeDir]);
111+
}
87112
await unlink(archivePath);
88113

89114
if (!existsSync(nodeBinary)) {

0 commit comments

Comments
 (0)