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