Commit 318aa57684

318aa576843c8e54df8d3a0f1271ff911cb9772d

parent: d6f6aca641

Unsigned

Wraient <wraient.911@gmail.com> · 2025-02-13 17:50 UTC

chore: CI/CD Implementation

Layout: unified · split

.github/workflows/ci-cd.yml +73 −51
@@ -14,12 +14,14 @@ jobs:
1414
1515 steps:
1616 - name: Checkout code
17 uses: actions/checkout@v2
17 uses: actions/checkout@v4
18 with:
19 fetch-depth: 0 # Fetch all history and tags
1820
1921 - name: Set up Go
2022 uses: actions/setup-go@v2
2123 with:
22 go-version: '1.23.2'
24 go-version: '1.24.0'
2325
2426 - name: Install Dependencies
2527 run: go mod tidy
@@ -27,57 +29,68 @@ jobs:
2729 - name: Build Linux binary
2830 run: |
2931 ./Build/buildlinux
32 mkdir -p release/linux
33 mv curd-linux-x86_64 release/linux/
3034
31 - name: Build macOS Intel binary
35 - name: Build macOS x86_64 binary
3236 run: |
33 ./Build/buildmac
37 ./Build/buildmac-x86_64
3438
3539 - name: Build macOS ARM64 binary
3640 run: |
3741 ./Build/buildmac-arm64
3842
39 - name: Create Universal macOS binary
43 - name: Install LLVM
4044 run: |
41 mkdir -p Build/macos
42 mv curd Build/macos/curd-amd64
43 mv curd-arm64 Build/macos/curd-arm64
44 lipo -create Build/macos/curd-amd64 Build/macos/curd-arm64 -output Build/macos/curd
45 rm Build/macos/curd-amd64 Build/macos/curd-arm64
45 sudo apt-get update && sudo apt-get install -y llvm
46 # Find the llvm-lipo command
47 LIPO_CMD=$(find /usr/bin -name "llvm-lipo*" | head -n 1)
48 echo "Found lipo command: $LIPO_CMD"
49 echo "LIPO_CMD=$LIPO_CMD" >> $GITHUB_ENV
4650
47 - name: Revert Changes in player.go
51 - name: Create Universal macOS binary
4852 run: |
49 git checkout -- internal/player.go
53 ${{ env.LIPO_CMD }} -create "curd-macos-x86_64" "curd-macos-arm64" -output "curd-macos-universal"
54 mkdir -p release/macos
55 mv curd-macos-x86_64 release/macos
56 mv curd-macos-arm64 release/macos
57 mv curd-macos-universal release/macos
5058
5159 - name: Build Windows binary (cross-compile)
5260 run: |
5361 ./Build/buildwindows
62 mkdir -p release/windows
63 mv curd-windows.exe release/windows
5464
5565 - name: Upload Artifacts
5666 uses: actions/upload-artifact@v4
5767 with:
5868 name: curd-binaries
5969 path: |
60 Build/curd
61 Build/curd.exe
62 Build/macos/curd
70 release/linux/curd-linux-x86_64
71 release/macos/curd-macos-x86_64
72 release/macos/curd-macos-arm64
73 release/macos/curd-macos-universal
74 release/windows/curd-windows.exe
6375 retention-days: 1
6476 if-no-files-found: error
6577
66 - name: List Build Directory
67 run: |
68 echo "Listing contents of Build directory:"
69 ls -R Build
70
7178 release:
72 runs-on: windows-latest # Use Windows runner for creating the installer
73 needs: build # Ensure the build job is complete before running this job
74 if: github.ref == 'refs/heads/main' && github.event_name == 'push' # Only run on pushes to main
79 runs-on: windows-latest
80 needs: build
81 permissions:
82 contents: write
83 actions: read
84 if: |
85 github.ref == 'refs/heads/main' &&
86 github.event_name == 'push' &&
87 (contains(github.event.head_commit.message, 'release:'))
7588
7689 steps:
7790 - name: Checkout code
78 uses: actions/checkout@v2
91 uses: actions/checkout@v4
7992 with:
80 lfs: true
93 fetch-depth: 0
8194
8295 - name: Download and extract MPV binary
8396 run: |
@@ -95,32 +108,39 @@ jobs:
95108 with:
96109 name: curd-binaries
97110 path: Build
98 repository: ${{ github.repository }} # Explicitly set repository
99 github-token: ${{ secrets.GITHUB_TOKEN }} # Add token for authentication
100111
101 - name: Bump Version
102 id: bump_version
112 - name: Organize Release Files
103113 run: |
104 $current_version = Get-Content VERSION.txt
105 $version_parts = $current_version -split '\.'
106 $major = $version_parts[0]
107 $minor = $version_parts[1]
108 $patch = [int]$version_parts[2] + 1
109 $new_version = "$major.$minor.$patch"
110 $new_version | Set-Content VERSION.txt
111 git config user.name "GitHub Actions"
112 git config user.email "actions@github.com"
113 git add VERSION.txt
114 git commit -m "Bump version to $new_version"
115 git tag "v$new_version"
116 echo "::set-output name=new_version::$new_version"
114 $version = Get-Content VERSION.txt
115 echo "CURD_VERSION=$version" >> $env:GITHUB_ENV
116 $release_dir = "releases/curd-$version"
117
118 # Create directory structure
119 New-Item -ItemType Directory -Force -Path "$release_dir/windows"
120 New-Item -ItemType Directory -Force -Path "$release_dir/macos"
121 New-Item -ItemType Directory -Force -Path "$release_dir/linux"
122
123 # List contents of Build directory to debug
124 Write-Host "Contents of Build directory:"
125 Get-ChildItem -Path "Build" -Recurse
126
127 # Move files to their respective directories
128 Move-Item "Build/windows/curd-windows.exe" "$release_dir/windows/"
129 Move-Item "Build/macos/curd-macos-universal" "$release_dir/macos/"
130 Move-Item "Build/macos/curd-macos-x86_64" "$release_dir/macos/"
131 Move-Item "Build/macos/curd-macos-arm64" "$release_dir/macos/"
132 Move-Item "Build/linux/curd-linux-x86_64" "$release_dir/linux/"
133 Copy-Item "Build/mpv/mpv.exe" "$release_dir/windows/"
134 shell: pwsh
117135
118136 - name: Update Inno Setup Script with New Version
119137 run: |
120 $new_version = Get-Content VERSION.txt
121138 $iss_path = "Build/curd-windows-build.iss"
122 (Get-Content $iss_path) -replace "AppVersion=.*", "AppVersion=$new_version" | Set-Content $iss_path
123
139 $content = Get-Content $iss_path
140 $content = $content -replace '^AppVersion=.*', "AppVersion=$env:CURD_VERSION"
141 Set-Content $iss_path $content
142 shell: pwsh
143
124144 - name: Create Windows Installer
125145 run: |
126146 & "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" "Build\curd-windows-build.iss"
@@ -130,15 +150,17 @@ jobs:
130150 id: create_release
131151 uses: softprops/action-gh-release@v1
132152 with:
133 tag_name: "v${{ steps.bump_version.outputs.new_version }}" # Use the bumped version as tag
134 name: "Curd v${{ steps.bump_version.outputs.new_version }}" # Use new version in release name
153 tag_name: "v${{ env.CURD_VERSION }}"
154 name: "Curd v${{ env.CURD_VERSION }}"
135155 draft: false
136156 prerelease: false
137157 generate_release_notes: true
138158 files: |
139 Build/curd
140 Build/curd.exe
141 Build/macos/curd
142 Build/Output/CurdInstaller.exe
159 releases/curd-${{ env.CURD_VERSION }}/linux/curd-linux-x86_64
160 releases/curd-${{ env.CURD_VERSION }}/macos/curd-macos-x86_64
161 releases/curd-${{ env.CURD_VERSION }}/macos/curd-macos-arm64
162 releases/curd-${{ env.CURD_VERSION }}/macos/curd-macos-universal
163 releases/curd-${{ env.CURD_VERSION }}/windows/curd-windows.exe
164 Build/Output/curd-windows-installer.exe
143165 env:
144166 GITHUB_TOKEN: ${{ secrets.ACTIONS_PAT }}
Build/buildlinux +2 −2
@@ -1,2 +1,2 @@
1CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o curd -ldflags="-s -w" -trimpath cmd/curd/main.go
2upx --best --ultra-brute curd
\ No newline at end of file
1CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o curd-linux-x86_64 -ldflags="-s -w" -trimpath cmd/curd/main.go
2upx --best --ultra-brute curd-linux-x86_64
\ No newline at end of file
Build/buildmac +5 −1
@@ -1 +1,5 @@
1CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o curd -ldflags="-s -w" -trimpath cmd/curd/main.go
\ No newline at end of file
1#!/bin/bash
2
3./Build/buildmac-arm64
4./Build/buildmac-x86_64
5
Build/buildmac-arm64 +1 −1
@@ -1 +1 @@
1CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o curd -ldflags="-s -w" -trimpath cmd/curd/main.go
\ No newline at end of file
1CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o curd-macos-arm64 -ldflags="-s -w" -trimpath cmd/curd/main.go
\ No newline at end of file
Build/buildmac-x86_64 added +1
@@ -0,0 +1 @@
1CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o curd-macos-x86_64 -ldflags="-s -w" -trimpath cmd/curd/main.go
\ No newline at end of file
Build/buildwindows +2 −2
@@ -1,2 +1,2 @@
1GOOS=windows GOARCH=amd64 go build -o curd.exe -ldflags "-s -w" ./cmd/curd/main.go
2upx --best --ultra-brute curd.exe
\ No newline at end of file
1GOOS=windows GOARCH=amd64 go build -o curd-windows.exe -ldflags "-s -w" ./cmd/curd/main.go
2upx --best --ultra-brute curd-windows.exe
\ No newline at end of file
Build/curd-windows-build.iss +6 −6
@@ -1,10 +1,10 @@
11[Setup]
22AppName=Curd Installer
3AppVersion=1.0.5
3AppVersion=1.0.8
44DefaultDirName={userappdata}\Curd
55PrivilegesRequired=lowest
66AllowNoIcons=yes
7OutputBaseFilename=CurdInstaller
7OutputBaseFilename=curd-windows-installer
88UsePreviousAppDir=yes
99Compression=lzma2
1010SolidCompression=yes
@@ -15,11 +15,11 @@ Name: "desktopicon"; Description: "Create a &desktop shortcut"; GroupDescription
1515
1616[Files]
1717; Copy the Curd executable to the install directory
18Source: "Z:releases/curd-1.0.5/windows/curd.exe"; DestDir: "{app}"; Flags: ignoreversion
19Source: "Z:/home/wraient/Projects/curd/Build/mpv.exe"; DestDir: "{app}\bin"; Flags: ignoreversion
18Source: "..\releases\curd-{#SetupSetting("AppVersion")}\windows\curd-windows.exe"; DestDir: "{app}"; Flags: ignoreversion
19Source: "mpv\mpv.exe"; DestDir: "{app}\bin"; Flags: ignoreversion
2020
2121[Icons]
2222; Create the application icon in the Start Menu
23Name: "{group}\Curd"; Filename: "{app}\curd.exe"
23Name: "{group}\Curd"; Filename: "{app}\curd-windows.exe"
2424; Create a desktop shortcut if the user checked the option
25Name: "{userdesktop}\Curd"; Filename: "{app}\curd.exe"; Tasks: desktopicon
25Name: "{userdesktop}\Curd"; Filename: "{app}\curd-windows.exe"; Tasks: desktopicon
Build/release +19 −27
@@ -10,15 +10,14 @@ installer_script="Build/curd-windows-build.iss"
1010
1111# Ensure required directories exist
1212mkdir -p "$windows_folder" "$linux_folder" "$macos_folder"
13mkdir -p "$windows_folder/bin"
1413
1514# Build Linux binary
1615echo "Building Linux binary..."
1716bash Build/buildlinux
1817
1918# Move the Linux binary to the release folder
20if [ -f "curd" ]; then
21 mv curd "$linux_folder/curd-linux-x86_64"
19if [ -f "curd-linux-x86_64" ]; then
20 mv curd-linux-x86_64 "$linux_folder"
2221else
2322 echo "Linux build failed. Please check Build/buildlinux."
2423 exit 1
@@ -27,18 +26,17 @@ fi
2726# Build macOS binaries
2827echo "Building macOS binaries..."
2928bash Build/buildmac
30if [ -f "curd" ]; then
31 mv curd "$macos_folder/curd-macos-x86_64"
29if [ -f "curd-macos-x86_64" ]; then
30 mv curd-macos-x86_64 "$macos_folder"
3231else
33 echo "macOS Intel build failed. Please check Build/buildmac."
32 echo "macOS x86-64 build failed. Please check Build/buildmac-x86_64."
3433 exit 1
3534fi
3635
37bash Build/buildmac-arm64
38if [ -f "curd" ]; then
39 mv curd "$macos_folder/curd-macos-arm64"
36if [ -f "curd-macos-arm64" ]; then
37 mv curd-macos-arm64 "$macos_folder"
4038else
41 echo "macOS ARM build failed. Please check Build/buildmac-arm64."
39 echo "macOS arm64 build failed. Please check Build/buildmac-arm64."
4240 exit 1
4341fi
4442
@@ -47,49 +45,43 @@ echo "Creating macOS Universal binary..."
4745llvm-lipo -create "$macos_folder/curd-macos-x86_64" "$macos_folder/curd-macos-arm64" -output "$macos_folder/curd-macos-universal"
4846# rm "$macos_folder/curd-macos-x86_64" "$macos_folder/curd-macos-arm64"
4947
48if [ ! -f "$macos_folder/curd-macos-universal" ]; then
49 echo "macOS arm64 build failed. Please check Build/buildmac."
50 exit 1
51fi
5052
5153# Update version in the installer script
5254sed -i "s/^AppVersion=.*/AppVersion=$version/" "$installer_script"
5355
54# Update Source paths in the installer script
55sed -i "s|Source: \".*curd.exe\"|Source: \"Z:$windows_folder/curd.exe\"|" "$installer_script"
56# sed -i "s|Source: \".*mpv.exe\"|Source: \"Z:$windows_folder/mpv.exe\"|" "$installer_script"
57
5856# Build Windows binary
5957echo "Building Windows binary..."
6058bash Build/buildwindows
6159
6260# Uncompress mpv.exe.gz
6361echo "Uncompressing mpv.exe..."
64gunzip -c Build/mpv.exe.gz > "Build/mpv.exe"
62mkdir -p "Build/mpv"
63gunzip -c Build/mpv.exe.gz > "Build/mpv/mpv.exe"
6564
6665# Move the Windows binary to the release folder
67if [ -f "curd.exe" ]; then
68 mv curd.exe "$windows_folder/curd-windows.exe"
66if [ -f "curd-windows.exe" ]; then
67 mv curd-windows.exe "$windows_folder"
6968else
7069 echo "Windows build failed. Please check Build/buildwindows."
7170 exit 1
7271fi
7372
74# # Copy mpv.exe to the Windows release folder
75# if [ -f "Build/mpv.exe" ]; then
76# cp "Build/mpv.exe" "$windows_folder/"
77# else
78# echo "mpv.exe not found. Skipping copy."
79# fi
80
8173# Create Windows installer with Inno Setup
8274echo "Creating Windows installer..."
8375wine "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" "$installer_script"
8476
8577# Move installer to the release folder
86installer_output="Build/Output/CurdInstaller.exe" # Replace with actual output location if different
78installer_output="Build/Output/curd-windows-installer.exe"
8779if [ -f "$installer_output" ]; then
88 mv "$installer_output" "$windows_folder/Curd-Windows-Installer.exe"
80 mv "$installer_output" "$windows_folder"
8981else
9082 echo "Installer creation failed. Please check Inno Setup script output."
9183fi
9284
93rm "Build/mpv.exe"
85rm "Build/mpv/mpv.exe"
9486
9587echo "Release build completed in $release_folder."
VERSION.txt +1 −1
@@ -1 +1 @@
11.0.4
\ No newline at end of file
11.0.8
\ No newline at end of file