-
Notifications
You must be signed in to change notification settings - Fork 7
137 lines (117 loc) · 4.55 KB
/
ci-cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: CI/CD Pipeline
on:
push:
branches:
- main # Trigger on pushes to the main branch
pull_request:
branches:
- main # Trigger on pull requests targeting the main branch
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.23.2'
- name: Install Dependencies
run: go mod tidy
- name: Comment go-winio for Linux Build
run: |
echo 'function toggle_winio_import() {
local action="$1"
local file="internal/player.go"
if [ "$action" == "comment" ]; then
sed -i "s|^\\(\\s*\\\"github.com/Microsoft/go-winio\\\"\\)|// \\1|" "$file"
sed -i "s|^\\(.*conn, err = winio.DialPipe.*\\)|// \\1|" "$file"
elif [ "$action" == "uncomment" ]; then
sed -i "s|// \\(\\s*\\\"github.com/Microsoft/go-winio\\\"\\)|\\1|" "$file"
sed -i "s|^// \\(.*conn, err = winio.DialPipe.*\\)|\\1|" "$file"
fi
}
toggle_winio_import comment' > toggle_winio_import.sh
- name: Execute Commenting Function for Linux Build # Comment out lines before Linux build
run: |
bash toggle_winio_import.sh
- name: Build Linux binary
run: |
./Build/buildlinux
- name: Revert Changes in player.go
run: |
git checkout -- internal/player.go
- name: Build Windows binary (cross-compile)
run: |
./Build/buildwindows
- name: Upload Artifacts
uses: actions/upload-artifact@v4 # Updated to version 4
with:
name: curd-binaries
path: |
Build/curd
Build/curd.exe
release:
runs-on: windows-latest # Use Windows runner for creating the installer
needs: build # Ensure the build job is complete before running this job
if: github.ref == 'refs/heads/main' && github.event_name == 'push' # Only run on pushes to main
steps:
- name: Checkout code
uses: actions/checkout@v2
# with:
# lfs: true
- name: Download and extract MPV binary
run: |
# Create directory if it doesn't exist
New-Item -ItemType Directory -Force -Path "Build\mpv"
# Download the compressed MPV binary
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/${{ github.repository }}/main/Build/mpv.exe.gz" -OutFile "Build\mpv\mpv.exe.gz"
# Extract using 7-Zip (built into Windows runners)
7z x "Build\mpv\mpv.exe.gz" -o"Build\mpv"
Remove-Item "Build\mpv\mpv.exe.gz"
shell: pwsh
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: curd-binaries
path: Build
- name: Bump Version
id: bump_version
run: |
$current_version = Get-Content VERSION.txt
$version_parts = $current_version -split '\.'
$major = $version_parts[0]
$minor = $version_parts[1]
$patch = [int]$version_parts[2] + 1
$new_version = "$major.$minor.$patch"
$new_version | Set-Content VERSION.txt
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add VERSION.txt
git commit -m "Bump version to $new_version"
git tag "v$new_version"
echo "::set-output name=new_version::$new_version"
- name: Update Inno Setup Script with New Version
run: |
$new_version = Get-Content VERSION.txt
$iss_path = "Build/curd-windows-build.iss"
(Get-Content $iss_path) -replace "AppVersion=.*", "AppVersion=$new_version" | Set-Content $iss_path
- name: Create Windows Installer
run: |
& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" "Build\curd-windows-build.iss"
shell: pwsh
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: "v${{ steps.bump_version.outputs.new_version }}" # Use the bumped version as tag
name: "Curd v${{ steps.bump_version.outputs.new_version }}" # Use new version in release name
draft: false
prerelease: false
generate_release_notes: true
files: |
Build/curd
Build/curd.exe
Build/Output/CurdInstaller.exe
env:
GITHUB_TOKEN: ${{ secrets.ACTIONS_PAT }}