Commit 1c4ba9f0d6
Unregistered key
Layout: unified · split
.github/workflows/ci-cd.yml +12 −8
| @@ -26,9 +26,9 @@ jobs: | ||
| 26 | 26 | ref: ${{ github.event.pull_request.head.sha || (github.event.inputs.pr_number && format('refs/pull/{0}/head', github.event.inputs.pr_number)) || github.sha }} |
| 27 | 27 | |
| 28 | 28 | - name: Set up Go |
| 29 | uses: actions/setup-go@v2 | |
| 29 | uses: actions/setup-go@v4 | |
| 30 | 30 | with: |
| 31 | go-version: '1.24.0' | |
| 31 | go-version: '1.21' | |
| 32 | 32 | |
| 33 | 33 | - name: Install Dependencies |
| 34 | 34 | run: go mod tidy |
| @@ -38,6 +38,7 @@ jobs: | ||
| 38 | 38 | ./Build/buildlinux |
| 39 | 39 | mkdir -p release/linux |
| 40 | 40 | mv curd-linux-x86_64 release/linux/ |
| 41 | mv curd-linux-arm64 release/linux/ | |
| 41 | 42 | env: |
| 42 | 43 | GITHUB_EVENT_NAME: ${{ github.event_name }} |
| 43 | 44 | GITHUB_REF: ${{ github.ref }} |
| @@ -52,9 +53,9 @@ jobs: | ||
| 52 | 53 | run: | |
| 53 | 54 | ./Build/buildmac-arm64 |
| 54 | 55 | |
| 55 | - name: Install LLVM | |
| 56 | - name: Install LLVM and gcc-mingw-w64 | |
| 56 | 57 | run: | |
| 57 | sudo apt-get update && sudo apt-get install -y llvm | |
| 58 | sudo apt-get update && sudo apt-get install -y llvm gcc-mingw-w64 | |
| 58 | 59 | # Find the llvm-lipo command |
| 59 | 60 | LIPO_CMD=$(find /usr/bin -name "llvm-lipo*" | head -n 1) |
| 60 | 61 | echo "Found lipo command: $LIPO_CMD" |
| @@ -72,7 +73,7 @@ jobs: | ||
| 72 | 73 | run: | |
| 73 | 74 | ./Build/buildwindows |
| 74 | 75 | mkdir -p release/windows |
| 75 | mv curd-windows.exe release/windows | |
| 76 | mv curd-windows-x86_64.exe release/windows/curd-windows-x86_64.exe | |
| 76 | 77 | env: |
| 77 | 78 | GITHUB_EVENT_NAME: ${{ github.event_name }} |
| 78 | 79 | GITHUB_REF: ${{ github.ref }} |
| @@ -85,10 +86,11 @@ jobs: | ||
| 85 | 86 | name: curd-binaries |
| 86 | 87 | path: | |
| 87 | 88 | release/linux/curd-linux-x86_64 |
| 89 | release/linux/curd-linux-arm64 | |
| 88 | 90 | release/macos/curd-macos-x86_64 |
| 89 | 91 | release/macos/curd-macos-arm64 |
| 90 | 92 | release/macos/curd-macos-universal |
| 91 | release/windows/curd-windows.exe | |
| 93 | release/windows/curd-windows-x86_64.exe | |
| 92 | 94 | retention-days: 1 |
| 93 | 95 | if-no-files-found: error |
| 94 | 96 | |
| @@ -142,11 +144,12 @@ jobs: | ||
| 142 | 144 | Get-ChildItem -Path "Build" -Recurse |
| 143 | 145 | |
| 144 | 146 | # Move files to their respective directories |
| 145 | Move-Item "Build/windows/curd-windows.exe" "$release_dir/windows/" | |
| 147 | Move-Item "Build/windows/curd-windows-x86_64.exe" "$release_dir/windows/" | |
| 146 | 148 | Move-Item "Build/macos/curd-macos-universal" "$release_dir/macos/" |
| 147 | 149 | Move-Item "Build/macos/curd-macos-x86_64" "$release_dir/macos/" |
| 148 | 150 | Move-Item "Build/macos/curd-macos-arm64" "$release_dir/macos/" |
| 149 | 151 | Move-Item "Build/linux/curd-linux-x86_64" "$release_dir/linux/" |
| 152 | Move-Item "Build/linux/curd-linux-arm64" "$release_dir/linux/" | |
| 150 | 153 | Copy-Item "Build/mpv/mpv.exe" "$release_dir/windows/" |
| 151 | 154 | shell: pwsh |
| 152 | 155 | |
| @@ -174,10 +177,11 @@ jobs: | ||
| 174 | 177 | generate_release_notes: true |
| 175 | 178 | files: | |
| 176 | 179 | releases/curd-${{ env.CURD_VERSION }}/linux/curd-linux-x86_64 |
| 180 | releases/curd-${{ env.CURD_VERSION }}/linux/curd-linux-arm64 | |
| 177 | 181 | releases/curd-${{ env.CURD_VERSION }}/macos/curd-macos-x86_64 |
| 178 | 182 | releases/curd-${{ env.CURD_VERSION }}/macos/curd-macos-arm64 |
| 179 | 183 | releases/curd-${{ env.CURD_VERSION }}/macos/curd-macos-universal |
| 180 | releases/curd-${{ env.CURD_VERSION }}/windows/curd-windows.exe | |
| 184 | releases/curd-${{ env.CURD_VERSION }}/windows/curd-windows-x86_64.exe | |
| 181 | 185 | Build/Output/curd-windows-installer.exe |
| 182 | 186 | env: |
| 183 | 187 | GITHUB_TOKEN: ${{ secrets.ACTIONS_PAT }} |
Build/buildlinux +4 −5
| @@ -1,5 +1,4 @@ | ||
| 1 | VERSION=$(cat VERSION.txt) | |
| 2 | CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o curd-linux-x86_64 -ldflags="-X main.version=${VERSION} -s -w" -trimpath cmd/curd/main.go | |
| 3 | if [[ "$GITHUB_EVENT_NAME" == "push" && "$GITHUB_REF" == "refs/heads/main" && "$GITHUB_EVENT_HEAD_COMMIT_MESSAGE" == *"release:"* ]] || [[ "$COMPRESS" == "true" ]]; then | |
| 4 | upx --best --ultra-brute curd-linux-x86_64 | |
| 5 | fi | |
| \ No newline at end of file | ||
| 1 | #!/bin/bash | |
| 2 | ||
| 3 | ./Build/buildlinux-arm64 | |
| 4 | ./Build/buildlinux-x86_64 | |
Build/buildlinux-arm64 added +5
| @@ -0,0 +1,5 @@ | ||
| 1 | VERSION=$(cat VERSION.txt) | |
| 2 | CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o curd-linux-arm64 -ldflags="-X main.version=${VERSION} -s -w" -trimpath cmd/curd/main.go | |
| 3 | if [[ "$GITHUB_EVENT_NAME" == "push" && "$GITHUB_REF" == "refs/heads/main" && "$GITHUB_EVENT_HEAD_COMMIT_MESSAGE" == *"release:"* ]] || [[ "$COMPRESS" == "true" ]]; then | |
| 4 | upx --best --ultra-brute curd-linux-arm64 | |
| 5 | fi | |
| \ No newline at end of file | ||
Build/buildlinux-x86_64 added +5
| @@ -0,0 +1,5 @@ | ||
| 1 | VERSION=$(cat VERSION.txt) | |
| 2 | CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o curd-linux-x86_64 -ldflags="-X main.version=${VERSION} -s -w" -trimpath cmd/curd/main.go | |
| 3 | if [[ "$GITHUB_EVENT_NAME" == "push" && "$GITHUB_REF" == "refs/heads/main" && "$GITHUB_EVENT_HEAD_COMMIT_MESSAGE" == *"release:"* ]] || [[ "$COMPRESS" == "true" ]]; then | |
| 4 | upx --best --ultra-brute curd-linux-x86_64 | |
| 5 | fi | |
| \ No newline at end of file | ||
Build/buildmac
Build/buildwindows +13 −5
| @@ -1,5 +1,13 @@ | ||
| 1 | VERSION=$(cat VERSION.txt) | |
| 2 | CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o curd-windows.exe -ldflags="-X main.version=${VERSION}" cmd/curd/main.go | |
| 3 | if [[ "$GITHUB_EVENT_NAME" == "push" && "$GITHUB_REF" == "refs/heads/main" && "$GITHUB_EVENT_HEAD_COMMIT_MESSAGE" == *"release:"* ]] || [[ "$COMPRESS" == "true" ]]; then | |
| 4 | upx --best --ultra-brute curd-windows.exe | |
| 5 | fi | |
| \ No newline at end of file | ||
| 1 | #!/bin/bash | |
| 2 | ||
| 3 | # Set required Windows build environment variables | |
| 4 | export CGO_ENABLED=1 | |
| 5 | export GOOS=windows | |
| 6 | ||
| 7 | # Build for ARM64 (Broken due to npipe and rich-go) | |
| 8 | # export GOARCH=arm64 | |
| 9 | # CC=x86_64-w64-mingw32-gcc ./Build/buildwindows-arm64 | |
| 10 | ||
| 11 | # Build for x86_64 | |
| 12 | export GOARCH=amd64 | |
| 13 | CC=x86_64-w64-mingw32-gcc ./Build/buildwindows-x86_64 | |
Build/buildwindows-arm64 added +5
| @@ -0,0 +1,5 @@ | ||
| 1 | VERSION=$(cat VERSION.txt) | |
| 2 | CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -o curd-windows-arm64.exe -ldflags="-X main.version=${VERSION}" cmd/curd/main.go | |
| 3 | if [[ "$GITHUB_EVENT_NAME" == "push" && "$GITHUB_REF" == "refs/heads/main" && "$GITHUB_EVENT_HEAD_COMMIT_MESSAGE" == *"release:"* ]] || [[ "$COMPRESS" == "true" ]]; then | |
| 4 | upx --best --ultra-brute curd-windows-arm64.exe | |
| 5 | fi | |
| \ No newline at end of file | ||
Build/buildwindows-x86_64 added +5
| @@ -0,0 +1,5 @@ | ||
| 1 | VERSION=$(cat VERSION.txt) | |
| 2 | CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o curd-windows-x86_64.exe -ldflags="-X main.version=${VERSION}" cmd/curd/main.go | |
| 3 | if [[ "$GITHUB_EVENT_NAME" == "push" && "$GITHUB_REF" == "refs/heads/main" && "$GITHUB_EVENT_HEAD_COMMIT_MESSAGE" == *"release:"* ]] || [[ "$COMPRESS" == "true" ]]; then | |
| 4 | upx --best --ultra-brute curd-windows-x86_64.exe | |
| 5 | fi | |
| \ No newline at end of file | ||
Build/curd-windows-build.iss +1 −1
| @@ -15,7 +15,7 @@ Name: "desktopicon"; Description: "Create a &desktop shortcut"; GroupDescription | ||
| 15 | 15 | |
| 16 | 16 | [Files] |
| 17 | 17 | ; Copy the Curd executable to the install directory |
| 18 | Source: "..\releases\curd-{#SetupSetting("AppVersion")}\windows\curd-windows.exe"; DestDir: "{app}"; DestName: "curd.exe"; Flags: ignoreversion | |
| 18 | Source: "..\releases\curd-{#SetupSetting("AppVersion")}\windows\curd-windows-x86_64.exe"; DestDir: "{app}"; DestName: "curd.exe"; Flags: ignoreversion | |
| 19 | 19 | Source: "mpv\mpv.exe"; DestDir: "{app}\bin"; Flags: ignoreversion |
| 20 | 20 | |
| 21 | 21 | [Icons] |
Build/mpv.zip added
Binary file not shown.
Build/release +18 −3
| @@ -23,6 +23,13 @@ else | ||
| 23 | 23 | exit 1 |
| 24 | 24 | fi |
| 25 | 25 | |
| 26 | if [ -f "curd-linux-arm64" ]; then | |
| 27 | mv curd-linux-arm64 "$linux_folder" | |
| 28 | else | |
| 29 | echo "Linux build failed. Please check Build/buildlinux-arm64." | |
| 30 | exit 1 | |
| 31 | fi | |
| 32 | ||
| 26 | 33 | # Build macOS binaries |
| 27 | 34 | echo "Building macOS binaries..." |
| 28 | 35 | bash Build/buildmac |
| @@ -63,13 +70,21 @@ mkdir -p "Build/mpv" | ||
| 63 | 70 | gunzip -c Build/mpv.exe.gz > "Build/mpv/mpv.exe" |
| 64 | 71 | |
| 65 | 72 | # Move the Windows binary to the release folder |
| 66 | if [ -f "curd-windows.exe" ]; then | |
| 67 | mv curd-windows.exe "$windows_folder" | |
| 73 | if [ -f "curd-windows-x86_64.exe" ]; then | |
| 74 | mv curd-windows-x86_64.exe "$windows_folder" | |
| 68 | 75 | else |
| 69 | echo "Windows build failed. Please check Build/buildwindows." | |
| 76 | echo "Windows build failed. Please check Build/buildwindows-x86_64." | |
| 70 | 77 | exit 1 |
| 71 | 78 | fi |
| 72 | 79 | |
| 80 | # NOTE: Broken due to npipe and rich-go | |
| 81 | # if [ -f "curd-windows-arm64.exe" ]; then | |
| 82 | # mv curd-windows-arm64.exe "$windows_folder" | |
| 83 | # else | |
| 84 | # echo "Windows build failed. Please check Build/buildwindows-arm64." | |
| 85 | # exit 1 | |
| 86 | # fi | |
| 87 | ||
| 73 | 88 | # Create Windows installer with Inno Setup |
| 74 | 89 | echo "Creating Windows installer..." |
| 75 | 90 | wine "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" "$installer_script" |
Build/requirements.txt added +2
| @@ -0,0 +1,2 @@ | ||
| 1 | mingw-w64-gcc # Build arm64 windows binary | |
| 2 | llvm-lipo # Build universal macos binary | |
| \ No newline at end of file | ||
internal/curd.go +37 −19
| @@ -457,8 +457,10 @@ func UpdateCurd(repo, fileName string) error { | ||
| 457 | 457 | var binaryName string |
| 458 | 458 | switch runtime.GOOS { |
| 459 | 459 | case "windows": |
| 460 | if strings.HasSuffix(executablePath, "curd.exe") { | |
| 461 | binaryName = "curd-windows.exe" | |
| 460 | if runtime.GOARCH == "arm64" { | |
| 461 | binaryName = "curd-windows-arm64.exe" | |
| 462 | } else { | |
| 463 | binaryName = "curd-windows-x86_64.exe" | |
| 462 | 464 | } |
| 463 | 465 | case "darwin": // macOS |
| 464 | 466 | switch runtime.GOARCH { |
| @@ -470,9 +472,12 @@ func UpdateCurd(repo, fileName string) error { | ||
| 470 | 472 | binaryName = "curd-macos-universal" |
| 471 | 473 | } |
| 472 | 474 | case "linux": |
| 473 | if runtime.GOARCH == "amd64" { | |
| 475 | switch runtime.GOARCH { | |
| 476 | case "amd64": | |
| 474 | 477 | binaryName = "curd-linux-x86_64" |
| 475 | } else { | |
| 478 | case "arm64": | |
| 479 | binaryName = "curd-linux-arm64" | |
| 480 | default: | |
| 476 | 481 | return fmt.Errorf("unsupported Linux architecture: %s", runtime.GOARCH) |
| 477 | 482 | } |
| 478 | 483 | default: |
| @@ -504,25 +509,38 @@ func UpdateCurd(repo, fileName string) error { | ||
| 504 | 509 | } |
| 505 | 510 | defer out.Close() |
| 506 | 511 | |
| 507 | // Write the downloaded content to the temporary file | |
| 508 | _, err = io.Copy(out, resp.Body) | |
| 509 | if err != nil { | |
| 510 | return fmt.Errorf("failed to save downloaded file: %v", err) | |
| 512 | // Set file permissions | |
| 513 | if err := out.Chmod(0755); err != nil { | |
| 514 | return fmt.Errorf("failed to set file permissions: %v", err) | |
| 511 | 515 | } |
| 512 | 516 | |
| 513 | // Close and rename the temporary file to replace the current executable | |
| 514 | out.Close() | |
| 515 | ||
| 516 | // Replace the current executable with the downloaded curd | |
| 517 | if err := os.Rename(tmpPath, executablePath); err != nil { | |
| 518 | return fmt.Errorf("failed to replace the current executable: %v", err) | |
| 517 | // Copy the downloaded content to the temporary file | |
| 518 | if _, err := io.Copy(out, resp.Body); err != nil { | |
| 519 | return fmt.Errorf("failed to write to temporary file: %v", err) | |
| 519 | 520 | } |
| 520 | CurdOut(fmt.Sprintf("Downloaded curd executable to %v", executablePath)) | |
| 521 | 521 | |
| 522 | if runtime.GOOS != "windows" { | |
| 523 | // Ensure the new file has executable permissions | |
| 524 | if err := os.Chmod(executablePath, 0755); err != nil { | |
| 525 | return fmt.Errorf("failed to set permissions on the new file: %v", err) | |
| 522 | // Close the file before renaming | |
| 523 | out.Close() | |
| 524 | ||
| 525 | // Replace the old executable with the new one | |
| 526 | if runtime.GOOS == "windows" { | |
| 527 | // On Windows, we need to rename the old file first | |
| 528 | oldPath := executablePath + ".old" | |
| 529 | err = os.Rename(executablePath, oldPath) | |
| 530 | if err != nil { | |
| 531 | return fmt.Errorf("failed to rename old executable: %v", err) | |
| 532 | } | |
| 533 | err = os.Rename(tmpPath, executablePath) | |
| 534 | if err != nil { | |
| 535 | // Try to restore the old executable if the rename fails | |
| 536 | os.Rename(oldPath, executablePath) | |
| 537 | return fmt.Errorf("failed to rename new executable: %v", err) | |
| 538 | } | |
| 539 | os.Remove(oldPath) | |
| 540 | } else { | |
| 541 | // On Unix systems, we can directly rename | |
| 542 | if err := os.Rename(tmpPath, executablePath); err != nil { | |
| 543 | return fmt.Errorf("failed to replace executable: %v", err) | |
| 526 | 544 | } |
| 527 | 545 | } |
| 528 | 546 | |