Skip to content

CI/CD Pipeline

CI/CD Pipeline #111

Workflow file for this run

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
workflow_dispatch:
inputs:
pr_number:
description: 'Pull Request Number'
required: false
type: string
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history and tags
ref: ${{ github.event.pull_request.head.sha || (github.event.inputs.pr_number && format('refs/pull/{0}/head', github.event.inputs.pr_number)) || github.sha }}
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.24.0'
- name: Install Dependencies
run: go mod tidy
- name: Build Linux binary
run: |
./Build/buildlinux
mkdir -p release/linux
mv curd-linux-x86_64 release/linux/
- name: Build macOS x86_64 binary
run: |
./Build/buildmac-x86_64
- name: Build macOS ARM64 binary
run: |
./Build/buildmac-arm64
- name: Install LLVM
run: |
sudo apt-get update && sudo apt-get install -y llvm
# Find the llvm-lipo command
LIPO_CMD=$(find /usr/bin -name "llvm-lipo*" | head -n 1)
echo "Found lipo command: $LIPO_CMD"
echo "LIPO_CMD=$LIPO_CMD" >> $GITHUB_ENV
- name: Create Universal macOS binary
run: |
${{ env.LIPO_CMD }} -create "curd-macos-x86_64" "curd-macos-arm64" -output "curd-macos-universal"
mkdir -p release/macos
mv curd-macos-x86_64 release/macos
mv curd-macos-arm64 release/macos
mv curd-macos-universal release/macos
- name: Build Windows binary (cross-compile)
run: |
./Build/buildwindows
mkdir -p release/windows
mv curd-windows.exe release/windows
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: curd-binaries
path: |
release/linux/curd-linux-x86_64
release/macos/curd-macos-x86_64
release/macos/curd-macos-arm64
release/macos/curd-macos-universal
release/windows/curd-windows.exe
retention-days: 1
if-no-files-found: error
release:
runs-on: windows-latest
needs: build
permissions:
contents: write
actions: read
if: |
github.ref == 'refs/heads/main' &&
github.event_name == 'push' &&
(contains(github.event.head_commit.message, 'release:'))
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- 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: Organize Release Files
run: |
$version = Get-Content VERSION.txt
echo "CURD_VERSION=$version" >> $env:GITHUB_ENV
$release_dir = "releases/curd-$version"
# Create directory structure
New-Item -ItemType Directory -Force -Path "$release_dir/windows"
New-Item -ItemType Directory -Force -Path "$release_dir/macos"
New-Item -ItemType Directory -Force -Path "$release_dir/linux"
# List contents of Build directory to debug
Write-Host "Contents of Build directory:"
Get-ChildItem -Path "Build" -Recurse
# Move files to their respective directories
Move-Item "Build/windows/curd-windows.exe" "$release_dir/windows/"
Move-Item "Build/macos/curd-macos-universal" "$release_dir/macos/"
Move-Item "Build/macos/curd-macos-x86_64" "$release_dir/macos/"
Move-Item "Build/macos/curd-macos-arm64" "$release_dir/macos/"
Move-Item "Build/linux/curd-linux-x86_64" "$release_dir/linux/"
Copy-Item "Build/mpv/mpv.exe" "$release_dir/windows/"
shell: pwsh
- name: Update Inno Setup Script with New Version
run: |
$iss_path = "Build/curd-windows-build.iss"
$content = Get-Content $iss_path
$content = $content -replace '^AppVersion=.*', "AppVersion=$env:CURD_VERSION"
Set-Content $iss_path $content
shell: pwsh
- 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${{ env.CURD_VERSION }}"
name: "Curd v${{ env.CURD_VERSION }}"
draft: false
prerelease: false
generate_release_notes: true
files: |
releases/curd-${{ env.CURD_VERSION }}/linux/curd-linux-x86_64
releases/curd-${{ env.CURD_VERSION }}/macos/curd-macos-x86_64
releases/curd-${{ env.CURD_VERSION }}/macos/curd-macos-arm64
releases/curd-${{ env.CURD_VERSION }}/macos/curd-macos-universal
releases/curd-${{ env.CURD_VERSION }}/windows/curd-windows.exe
Build/Output/curd-windows-installer.exe
env:
GITHUB_TOKEN: ${{ secrets.ACTIONS_PAT }}