Skip to content

release: v2.0.0

release: v2.0.0 #281

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@v4
with:
go-version: '1.21'
- 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/
mv curd-linux-arm64 release/linux/
env:
GITHUB_EVENT_NAME: ${{ github.event_name }}
GITHUB_REF: ${{ github.ref }}
GITHUB_EVENT_HEAD_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
COMPRESS: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'release:') }}
- 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-x86_64.exe release/windows/curd-windows-x86_64.exe
env:
GITHUB_EVENT_NAME: ${{ github.event_name }}
GITHUB_REF: ${{ github.ref }}
GITHUB_EVENT_HEAD_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
COMPRESS: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'release:') }}
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: curd-binaries
path: |
release/linux/curd-linux-x86_64
release/linux/curd-linux-arm64
release/macos/curd-macos-x86_64
release/macos/curd-macos-arm64
release/macos/curd-macos-universal
release/windows/curd-windows-x86_64.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: Checkout MPV binaries
uses: actions/checkout@v4
with:
ref: mpv-binaries
path: mpv-temp
sparse-checkout: |
Build/mpv.exe.gz
Build/mpv.zip
- name: Setup MPV binary
run: |
New-Item -ItemType Directory -Force -Path "Build\mpv"
if (Test-Path "mpv-temp/Build/mpv.exe.gz") {
Copy-Item "mpv-temp/Build/mpv.exe.gz" "Build\mpv\mpv.exe.gz"
7z x "Build\mpv\mpv.exe.gz" -o"Build\mpv"
Remove-Item "Build\mpv\mpv.exe.gz"
} else {
Write-Host "Warning: MPV binary not found in mpv-binaries branch, downloading from URL..."
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/${{ github.repository }}/main/Build/mpv.exe.gz" -OutFile "Build\mpv\mpv.exe.gz"
7z x "Build\mpv\mpv.exe.gz" -o"Build\mpv"
Remove-Item "Build\mpv\mpv.exe.gz"
}
Remove-Item -Recurse -Force "mpv-temp" -ErrorAction SilentlyContinue
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-x86_64.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/"
Move-Item "Build/linux/curd-linux-arm64" "$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: Build direct commit release notes
run: |
$ErrorActionPreference = 'Stop'
$repo = "${{ github.repository }}"
$token = "${{ secrets.ACTIONS_PAT }}"
$headers = @{
Authorization = "Bearer $token"
Accept = "application/vnd.github+json"
"X-GitHub-Api-Version" = "2022-11-28"
}
$currentTag = "v$env:CURD_VERSION"
$tags = @(git tag --sort=-version:refname "v*")
$previousTag = $null
foreach ($tag in $tags) {
if ($tag -ne $currentTag) {
$previousTag = $tag
break
}
}
if ($previousTag) {
$range = "$previousTag..HEAD"
} else {
$rootCommit = (git rev-list --max-parents=0 HEAD | Select-Object -First 1)
if ([string]::IsNullOrWhiteSpace($rootCommit)) {
$range = "HEAD"
} else {
$range = "$rootCommit..HEAD"
}
}
$rawCommits = @(git log --no-merges --pretty=format:'%H%x09%s%x09%an' $range)
if ($rawCommits.Count -eq 1 -and [string]::IsNullOrWhiteSpace($rawCommits[0])) {
$rawCommits = @()
}
$directCommitLines = @()
$contributorSet = @{}
foreach ($entry in $rawCommits) {
$parts = $entry -split "`t", 3
if ($parts.Count -lt 3) {
continue
}
$sha = $parts[0].Trim()
$subject = $parts[1].Trim()
$authorName = $parts[2].Trim()
if ([string]::IsNullOrWhiteSpace($sha) -or [string]::IsNullOrWhiteSpace($subject)) {
continue
}
if ($subject -match '^\s*release:') {
continue
}
$pullsUri = "https://api.github.com/repos/$repo/commits/$sha/pulls"
$pulls = @()
try {
$pulls = @(Invoke-RestMethod -Uri $pullsUri -Headers $headers -Method Get)
} catch {
$pulls = @()
}
# Skip commits that are already represented by pull requests in generated notes.
if ($pulls.Count -gt 0) {
continue
}
$commitUri = "https://api.github.com/repos/$repo/commits/$sha"
$login = $null
try {
$commitData = Invoke-RestMethod -Uri $commitUri -Headers $headers -Method Get
if ($null -ne $commitData.author -and $null -ne $commitData.author.login) {
$login = $commitData.author.login
}
} catch {
$login = $null
}
$shortSha = $sha.Substring(0, 7)
if (-not [string]::IsNullOrWhiteSpace($login)) {
$authorDisplay = "[@$login](https://github.com/$login)"
} else {
$authorDisplay = $authorName
}
$contributorSet[$authorDisplay] = $true
$directCommitLines += "- $subject ([$shortSha](https://github.com/$repo/commit/$sha)) by $authorDisplay"
}
$notesPath = "Build/release-notes-extra.md"
$body = @()
$body += "## Direct Commits"
if ($directCommitLines.Count -eq 0) {
$body += "- No direct commits in this release range."
} else {
$body += $directCommitLines
}
$body += ""
$body += "## Direct Commit Contributors"
$contributors = @($contributorSet.Keys | Sort-Object)
if ($contributors.Count -eq 0) {
$body += "- None"
} else {
foreach ($contributor in $contributors) {
$body += "- $contributor"
}
}
if ($previousTag) {
$body += ""
$body += "_Range: $previousTag..HEAD_"
}
$body | Set-Content -Path $notesPath -Encoding utf8
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
body_path: Build/release-notes-extra.md
files: |
releases/curd-${{ env.CURD_VERSION }}/linux/curd-linux-x86_64
releases/curd-${{ env.CURD_VERSION }}/linux/curd-linux-arm64
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-x86_64.exe
Build/Output/curd-windows-installer.exe
env:
GITHUB_TOKEN: ${{ secrets.ACTIONS_PAT }}