Commit ba5e84440b

ba5e84440bcbab7115dcdcec0040d7ce41d705ad

parent: ad20702078

Unsigned

Wraient <wraient.911@gmail.com> · 2024-10-26 20:06 UTC

How good even is chatgpt

Layout: unified · split

.github/workflows/ci-cd.yml +111 −130
@@ -13,140 +13,121 @@ jobs:
13 runs-on: ubuntu-latest 13 runs-on: ubuntu-latest
14 14
15 steps: 15 steps:
16 - name: Checkout code 16 - name: Checkout code
17 uses: actions/checkout@v2 17 uses: actions/checkout@v2
18 18
19 - name: Set up Go 19 - name: Set up Go
20 uses: actions/setup-go@v2 20 uses: actions/setup-go@v2
21 with: 21 with:
22 go-version: '1.23.2' 22 go-version: '1.23.2'
23 23
24 - name: Install Dependencies 24 - name: Install Dependencies
25 run: go mod tidy # Install Go dependencies 25 run: go mod tidy # Install Go dependencies
26 26
27 # - name: Comment go-winio for Linux Build 27 - name: Comment go-winio for Linux Build
28 # run: | 28 run: |
29 # echo 'function toggle_winio_import() { 29 echo 'function toggle_winio_import() {
30 # local action="$1" 30 local action="$1"
31 # local file="internal/player.go" 31 local file="internal/player.go"
32 32
33 # if [ "$action" == "comment" ]; then 33 if [ "$action" == "comment" ]; then
34 # sed -i "s|^\\(\\s*\\\"github.com/Microsoft/go-winio\\\"\\)|// \\1|" "$file" 34 sed -i "s|^\\(\\s*\\\"github.com/Microsoft/go-winio\\\"\\)|// \\1|" "$file"
35 # sed -i "s|^\\(.*conn, err = winio.DialPipe.*\\)|// \\1|" "$file" 35 sed -i "s|^\\(.*conn, err = winio.DialPipe.*\\)|// \\1|" "$file"
36 # elif [ "$action" == "uncomment" ]; then 36 elif [ "$action" == "uncomment" ]; then
37 # sed -i "s|// \\(\\s*\\\"github.com/Microsoft/go-winio\\\"\\)|\\1|" "$file" 37 sed -i "s|// \\(\\s*\\\"github.com/Microsoft/go-winio\\\"\\)|\\1|" "$file"
38 # sed -i "s|^// \\(.*conn, err = winio.DialPipe.*\\)|\\1|" "$file" 38 sed -i "s|^// \\(.*conn, err = winio.DialPipe.*\\)|\\1|" "$file"
39 # fi 39 fi
40 # } 40 }
41 # toggle_winio_import comment' > toggle_winio_import.sh 41 toggle_winio_import comment' > toggle_winio_import.sh
42 42
43 # - name: Execute Commenting Function for Linux Build # Comment out lines before Linux build 43 - name: Execute Commenting Function for Linux Build # Comment out lines before Linux build
44 # run: | 44 run: |
45 # bash toggle_winio_import.sh 45 bash toggle_winio_import.sh
46 46
47 # - name: Build Linux binary 47 - name: Build Linux binary
48 # run: | 48 run: |
49 # chmod +x Build/buildlinux 49 outputDir="Build" # Set the output directory for Linux builds
50 # ./Build/buildlinux 50 mkdir -p "$outputDir" # Create the directory if it doesn't exist
51 51 go build -o "$outputDir/curd-linux" ./cmd/curd/main.go
52 # - name: Revert Changes in player.go 52
53 # run: | 53 - name: Revert Changes in player.go
54 # git checkout -- internal/player.go 54 run: |
55 55 git checkout -- internal/player.go
56 # - name: Run Tests 56
57 # run: go test ./... # Run tests for your Go code 57 - name: Build Windows binary (cross-compile)
58 run: |
59 outputDir="Build" # Use the same name for consistency
60 mkdir -p "$outputDir" # Create the directory if it doesn't exist
61 set GOOS=windows
62 set GOARCH=amd64
63 go build -o "$outputDir\curd.exe" .\cmd\curd\main.go
64
65 - name: Upload Artifacts
66 uses: actions/upload-artifact@v2
67 with:
68 name: curd-binaries
69 path: |
70 Build/curd-linux
71 Build/curd.exe # Include the Windows binary
58 72
59 release: 73 release:
60 runs-on: windows-latest # Use Windows runner for creating the installer 74 runs-on: windows-latest # Use Windows runner for creating the installer
61 needs: build 75 needs: build # Ensure the build job is complete before running this job
62 if: github.ref == 'refs/heads/main' && github.event_name == 'push' # Only run on pushes to main 76 if: github.ref == 'refs/heads/main' && github.event_name == 'push' # Only run on pushes to main
63 77
64 steps: 78 steps:
65 - name: Checkout code 79 - name: Checkout code
66 uses: actions/checkout@v2 80 uses: actions/checkout@v2
67 81
68 - name: Set up Go 82 - name: Download Artifacts
69 uses: actions/setup-go@v2 83 uses: actions/download-artifact@v2
70 with: 84 with:
71 go-version: '1.23.2' 85 name: curd-binaries
72 86 path: Build # Specify where to download the artifacts
73 - name: Install Dependencies 87
74 run: go mod tidy # Install Go dependencies 88 - name: Set up Go
75 89 uses: actions/setup-go@v2
76 - name: Verify Go Version 90 with:
77 run: go version 91 go-version: '1.23.2'
78 92
79 - name: Build Windows binary 93 - name: Install Dependencies
80 run: | 94 run: go mod tidy # Install Go dependencies
81 echo "Current directory: $(Get-Location)" 95
82 echo "Directory contents:" 96 - name: Bump Version
83 dir 97 id: bump_version
84 echo "Building the Windows binary..." 98 run: |
85 99 $current_version = Get-Content VERSION.txt
86 $outputDir = "D:\a\curd\curd\Build\" 100 $version_parts = $current_version -split '\.'
87 101 $major = $version_parts[0]
88 if (-Not (Test-Path $outputDir)) { 102 $minor = $version_parts[1]
89 New-Item -ItemType Directory -Path $outputDir 103 $patch = [int]$version_parts[2] + 1
90 echo "Created directory: $outputDir" 104 $new_version = "$major.$minor.$patch"
91 } else { 105 $new_version | Set-Content VERSION.txt
92 echo "Directory already exists: $outputDir" 106 Write-Host "New version: $new_version"
93 } 107 git config user.name "GitHub Actions"
94 108 git config user.email "actions@github.com"
95 echo "Building the Windows binary..." 109 git add VERSION.txt
96 set GOOS=windows 110 git commit -m "Bump version to $new_version"
97 set GOARCH=amd64 111 git tag "v$new_version"
98 go build -o "$outputDir\curd.exe" .\cmd\curd\main.go 112
99 113 - name: Update Inno Setup Script with New Version
100 if ($LASTEXITCODE -ne 0) { 114 run: |
101 echo "Build failed" 115 $new_version = Get-Content VERSION.txt
102 exit 1 116 $iss_path = "Build/curd-windows-build.iss"
103 } 117 (Get-Content $iss_path) -replace "AppVersion=.*", "AppVersion=$new_version" | Set-Content $iss_path
104 echo "Build completed successfully!"
105
106 - name: Download Inno Setup # Clean up
107 run: |
108 Invoke-WebRequest -Uri "https://jrsoftware.org/download.php/is.exe" -OutFile "is.exe" # Download Inno Setup installer
109 Start-Process -FilePath "is.exe" -ArgumentList "/SILENT" -Wait # Run installer silently
110 Remove-Item "is.exe"
111
112 - name: List Build Directory
113 run: tree /F
114
115 - name: Bump Version
116 id: bump_version
117 run: |
118 $current_version = Get-Content VERSION.txt
119 $version_parts = $current_version -split '\.'
120 $major = $version_parts[0]
121 $minor = $version_parts[1]
122 $patch = [int]$version_parts[2] + 1
123 $new_version = "$major.$minor.$patch"
124 $new_version | Set-Content VERSION.txt
125 Write-Host "New version: $new_version"
126 git config user.name "GitHub Actions"
127 git config user.email "actions@github.com"
128 git add VERSION.txt
129 git commit -m "Bump version to $new_version"
130 git tag "v$new_version"
131
132 - name: Update Inno Setup Script with New Version
133 run: |
134 $new_version = Get-Content VERSION.txt
135 $iss_path = "Build/curd-windows-build.iss"
136 (Get-Content $iss_path) -replace "AppVersion=.*", "AppVersion=$new_version" | Set-Content $iss_path
137 118
138 - name: Create Windows Installer 119 - name: Create Windows Installer
139 run: | 120 run: |
140 & "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" "D:\a\curd\curd\Build\curd-windows-build.iss" 121 & "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" "Build\curd-windows-build.iss"
141 shell: pwsh 122 shell: pwsh
142 123
143 - name: Create Release 124 - name: Create Release
144 id: create_release 125 id: create_release
145 uses: softprops/action-gh-release@v1 126 uses: softprops/action-gh-release@v1
146 with: 127 with:
147 tag_name: ${{ steps.bump_version.outputs.new_version }} # Use the bumped version as tag 128 tag_name: "v${{ steps.bump_version.outputs.new_version }}" # Use the bumped version as tag
148 release_name: "Curd v${{ steps.bump_version.outputs.new_version }}" # Use new version in release name 129 release_name: "Curd v${{ steps.bump_version.outputs.new_version }}" # Use new version in release name
149 draft: false 130 draft: false
150 prerelease: false 131 prerelease: false
151 env: 132 env:
152 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Automatically provided token 133 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Automatically provided token