Skip to content

Manual Build

Manual Build #133

Workflow file for this run

# This is a basic workflow that is manually triggered
name: Manual Build
# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
run_windows:
description: 'Run Windows build'
type: boolean
default: true
run_linux:
description: 'Run Linux build'
type: boolean
default: false
run_macos:
description: 'Run macOS build'
type: boolean
default: false
run_freebsd:
description: 'Run FreeBSD build'
type: boolean
default: false
name:
# Friendly description to be shown in the UI instead of 'name'
description: 'DSvC Build workflow'
# Default value if no value is explicitly provided
default: 'World'
# Input has to be provided for the workflow to run
required: false
# The data type of the input
type: string
jobs:
build-windows:
if: ${{ github.event.inputs.run_windows == 'true' }}
runs-on: windows-latest
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
VCPKG_ROOT: C:\vcpkg
OPENSSL_DIR: C:/vcpkg/installed/x64-windows-static
OPENSSL_STATIC: 1
OPENSSL_LIB_DIR: C:/vcpkg/installed/x64-windows-static/lib
OPENSSL_INCLUDE_DIR: C:/vcpkg/installed/x64-windows-static/include
CMAKE_TOOLCHAIN_FILE: C:/vcpkg/scripts/buildsystems/vcpkg.cmake
steps:
- uses: actions/checkout@v3
- name: Cache Cargo Dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
# Windows specific paths
C:/Users/runneradmin/.cargo/registry
C:/Users/runneradmin/.cargo/git
# Cache build artifacts
target
target/x86_64-pc-windows-msvc
target/x86_64-pc-windows-msvc/release
target/release
key: ${{ runner.os }}-msvc-cargo-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', '**/rust-toolchain.toml', '.cargo/config*') }}
restore-keys: |
${{ runner.os }}-msvc-cargo-${{ hashFiles('**/Cargo.lock') }}
${{ runner.os }}-msvc-cargo-
- name: Cache custom tools (Windows)
uses: actions/cache@v3
id: custom-tools-cache
with:
path: |
C:/tools
C:/tools/psutils
C:/ProgramData/chocolatey/lib/dos2unix
C:/ProgramData/chocolatey/lib/7zip.install
~/.cargo/bin/sccache
C:/Users/runneradmin/.cargo/bin/sccache
C:/Users/runneradmin/.cargo/config.toml
key: windows-custom-tools-v4-${{ hashFiles('**/Cargo.lock') }}
- name: Cache vcpkg (Windows)
uses: actions/cache@v3
with:
path: C:/vcpkg/installed
key: windows-vcpkg-${{ hashFiles('**/Cargo.lock') }}
restore-keys: windows-vcpkg-
- name: Add tools to PATH (Windows)
shell: pwsh
run: |
echo "C:/tools" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "C:/tools/psutils" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Cache Rust toolchain
uses: actions/cache@v3
with:
path: C:/Users/runneradmin/.rustup
key: windows-rustup-${{ hashFiles('**/Cargo.lock') }}
restore-keys: windows-rustup-
- name: Cache Release Artifacts
id: cache-release
uses: actions/cache@v3
with:
path: |
target/x86_64-pc-windows-msvc/release
target/release
Changes.md
key: windows-release-${{ hashFiles('target/x86_64-pc-windows-msvc/release/**', 'target/release/**') }}
restore-keys: |
windows-release-
- name: Install Dependencies (Windows)
shell: pwsh
run: |
vcpkg integrate install
vcpkg install openssl:x64-windows-static
# Set OpenSSL environment variables for Windows
echo "OPENSSL_DIR=C:/vcpkg/installed/x64-windows-static" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "OPENSSL_STATIC=1" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "OPENSSL_LIB_DIR=C:/vcpkg/installed/x64-windows-static/lib" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "OPENSSL_INCLUDE_DIR=C:/vcpkg/installed/x64-windows-static/include" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "CMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-pc-windows-msvc
profile: minimal
override: true
- name: Create Changes.md
if: steps.cache-release.outputs.cache-hit != 'true'
run: |
echo "# Changelog" > Changes.md
echo "## v0.1.0" >> Changes.md
echo "* Initial release" >> Changes.md
shell: bash
- name: Download custom tools (Windows)
if: steps.custom-tools-cache.outputs.cache-hit != 'true'
shell: pwsh
run: |
# Create tools directory first
if (-not (Test-Path "C:/tools")){
New-Item -Path "C:/tools" -ItemType Directory -Force
New-Item -Path "C:/tools/psutils" -ItemType Directory -Force
}
# Install tools first so they're available in PATH
choco install 7zip.install --version=24.9.0 -y --no-progress
choco install dos2unix -y
# Download and install psutils after other tools
$psutilsPath = "C:/tools/psutils"
$tempZip = "C:/tools/psutils.zip"
Invoke-WebRequest -Uri "https://github.com/lukesampson/psutils/archive/master.zip" -OutFile $tempZip
Expand-Archive -Path $tempZip -DestinationPath $psutilsPath -Force
Remove-Item $tempZip
Get-ChildItem -Path "$psutilsPath/psutils-master" -Filter "*.ps1" |
ForEach-Object { Copy-Item $_.FullName -Destination $psutilsPath }
Remove-Item "$psutilsPath/psutils-master" -Recurse -Force
- name: Configure Cargo
if: steps.custom-tools-cache.outputs.cache-hit != 'true'
shell: pwsh
run: |
cargo install sccache
# Add cache configuration
$cargoConfig = @"
[build]
target-dir = "./target"
[net]
retry = 10
"@
New-Item -Path "$env:USERPROFILE\.cargo" -ItemType Directory -Force
Set-Content -Path "$env:USERPROFILE\.cargo\config.toml" -Value $cargoConfig
- name: Build Release
#if: steps.cache-release.outputs.cache-hit != 'true'
shell: pwsh
run: |
Write-Host "Current directory: $(Get-Location)"
Write-Host "Environment variables:"
Get-ChildItem env:
# Create target directory if it doesn't exist
New-Item -Path "target" -ItemType Directory -Force
# Build with explicit target directory
$env:CARGO_TARGET_DIR = Join-Path (Get-Location) "target"
cargo build --release --target x86_64-pc-windows-msvc --verbose
Write-Host "`nSearching for binary..."
Get-ChildItem -Path "." -Recurse -Filter "DSvClient*" | ForEach-Object {
Write-Host "Found: $($_.FullName)"
}
# Look in both possible locations
$possiblePaths = @(
"target/x86_64-pc-windows-msvc/release/DSvClient.exe",
"./target/x86_64-pc-windows-msvc/release/DSvClient.exe",
"target/release/DSvClient.exe",
"./target/release/DSvClient.exe"
)
$binPath = $null
foreach ($path in $possiblePaths) {
if (Test-Path $path) {
$binPath = $path
break
}
}
if ($binPath) {
Write-Host "`nBinary found at: $binPath"
Get-Item $binPath | Select-Object FullName, Length, LastWriteTime
# Ensure binary is in the expected location
$targetPath = "target/x86_64-pc-windows-msvc/release/DSvClient.exe"
if ($binPath -ne $targetPath) {
New-Item -Path (Split-Path $targetPath) -ItemType Directory -Force
Copy-Item $binPath $targetPath -Force
}
} else {
Write-Host "`nChecking directory structure:"
Get-ChildItem -Path "." -Recurse | Select-Object FullName
Write-Error "Binary not found in any expected location"
exit 1
}
# Removed strip binary (windows) - does nothing for size and uses a lot of time
- name: Verify Binary
shell: pwsh
run: |
$paths = @(
"target/x86_64-pc-windows-msvc/release/DSvClient.exe",
"target/release/DSvClient.exe"
)
foreach ($path in $paths) {
if (Test-Path $path) {
Write-Host "Found binary at: $path"
Get-Item $path | Select-Object FullName, Length, LastWriteTime
}
}
- name: Upload Windows Artifact
uses: actions/upload-artifact@v4
with:
name: DSvClient-windows
path: target/x86_64-pc-windows-msvc/release/DSvClient.exe
retention-days: 7
if-no-files-found: error
- name: Publish Release
#if: steps.cache-release.outputs.cache-hit != 'true'
uses: houseabsolute/actions-rust-release@v0
with:
executable-name: DSvClient
target: x86_64-pc-windows-msvc
changes-file: Changes.md
build-ubuntu:
if: ${{ github.event.inputs.run_linux == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache Cargo Dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
target/x86_64-unknown-linux-gnu
target/x86_64-unknown-linux-gnu/release
target/release
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', '**/rust-toolchain.toml') }}
restore-keys: |
${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
${{ runner.os }}-cargo-
- name: Cache Build Release
uses: actions/cache@v3
with:
path: |
target/x86_64-unknown-linux-gnu/release
target/release
key: ubuntu-release-${{ hashFiles('target/x86_64-unknown-linux-gnu/release/**', 'target/release/**') }}
restore-keys: |
ubuntu-release-
- name: Cache Rust toolchain
uses: actions/cache@v3
with:
path: ~/.rustup
key: linux-rustup-${{ hashFiles('**/Cargo.lock') }}
restore-keys: linux-rustup-
- name: Install Dependencies (Linux)
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libssl-dev
# Set OpenSSL paths for Linux
echo "OPENSSL_LIB_DIR=/usr/lib/x86_64-linux-gnu" >> $GITHUB_ENV
echo "OPENSSL_INCLUDE_DIR=/usr/include/openssl" >> $GITHUB_ENV
echo "OPENSSL_DIR=/usr" >> $GITHUB_ENV
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-unknown-linux-gnu
profile: minimal
override: true
- name: Create Changes.md
run: |
echo "# Changelog" > Changes.md
echo "## v0.1.0" >> Changes.md
echo "* Initial release" >> Changes.md
shell: bash
- name: Build Release
uses: houseabsolute/actions-rust-cross@v0
with:
target: x86_64-unknown-linux-gnu
args: "--release"
strip: true
- name: Upload Linux Artifact
uses: actions/upload-artifact@v4
with:
name: DSvClient-linux
path: target/x86_64-unknown-linux-gnu/release/DSvClient
retention-days: 7
if-no-files-found: error
- name: Publish Release
uses: houseabsolute/actions-rust-release@v0
with:
executable-name: DSvClient
target: x86_64-unknown-linux-gnu
changes-file: Changes.md
build-macos:
if: ${{ github.event.inputs.run_macos == 'true' }}
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Cache Cargo Dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: macos-cargo-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', 'rust-toolchain.toml') }}
restore-keys: |
macos-cargo-
- name: Cache Rust toolchain
uses: actions/cache@v3
with:
path: ~/.rustup
key: macos-rustup-${{ hashFiles('**/Cargo.lock') }}
restore-keys: macos-rustup-
- name: Install Dependencies (macOS)
shell: bash
run: |
echo "OPENSSL_ROOT_DIR=$(brew --prefix openssl@3)" >> $GITHUB_ENV
echo "OPENSSL_LIB_DIR=$(brew --prefix openssl@3)/lib" >> $GITHUB_ENV
echo "OPENSSL_INCLUDE_DIR=$(brew --prefix openssl@3)/include" >> $GITHUB_ENV
- name: Create Changes.md
run: |
echo "# Changelog" > Changes.md
echo "## v0.1.0" >> Changes.md
echo "* Initial release" >> Changes.md
shell: bash
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-apple-darwin
profile: minimal
override: true
- name: Build Release
uses: houseabsolute/actions-rust-cross@v0
with:
target: x86_64-apple-darwin
args: "--release"
strip: true
- name: Upload macOS Artifact
uses: actions/upload-artifact@v4
with:
name: DSvClient-macos
path: target/x86_64-apple-darwin/release/DSvClient
retention-days: 7
if-no-files-found: error
- name: Publish Release
uses: houseabsolute/actions-rust-release@v0
with:
executable-name: DSvClient
target: x86_64-apple-darwin
changes-file: Changes.md
build-freebsd:
if: ${{ github.event.inputs.run_freebsd == 'true' }}
runs-on: ubuntu-20.04
env:
CARGO_HOME: /home/runner/.cargo
CROSS_CARGO_HOME: /home/runner/.cargo
steps:
- uses: actions/checkout@v3
- name: Cache FreeBSD Dependencies
uses: actions/cache@v3
id: freebsd-deps-cache
with:
path: |
/home/runner/.cargo/registry
/home/runner/.cargo/git
/home/runner/.cargo/bin
/home/runner/.cargo/config*
target
target/x86_64-unknown-freebsd
target/x86_64-unknown-freebsd/release
target/release
target/debug
target/.rustc_info.json
target/CACHEDIR.TAG
key: freebsd-cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', '**/rust-toolchain.toml', '.cargo/config*') }}
restore-keys: |
freebsd-cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
freebsd-cargo-${{ runner.os }}-
- name: Setup System Dependencies
run: |
# Create backup of system SSL files with proper permissions
sudo mkdir -p /opt/ssl_backup
cd /opt/ssl_backup
sudo tar czf ssl_libs.tar.gz \
/usr/lib/x86_64-linux-gnu/libssl* \
/usr/lib/x86_64-linux-gnu/libcrypto* \
/usr/include/openssl
sudo chown $(id -u):$(id -g) ssl_libs.tar.gz
shell: bash
- name: Cache System Libraries
uses: actions/cache@v3
id: system-libs-cache
with:
path: /opt/ssl_backup/ssl_libs.tar.gz
key: freebsd-ssl-${{ hashFiles('/usr/lib/x86_64-linux-gnu/libssl*', '/usr/lib/x86_64-linux-gnu/libcrypto*') }}
- name: Restore System Libraries
if: steps.system-libs-cache.outputs.cache-hit == 'true'
run: |
cd /
sudo tar xzf /opt/ssl_backup/ssl_libs.tar.gz
shell: bash
- name: Pre-cache cleanup
run: |
# Remove lock files and partial directories before caching
sudo rm -f /var/lib/apt/lists/lock
sudo rm -f /var/cache/apt/archives/lock
sudo rm -rf /var/lib/apt/lists/partial/
sudo rm -rf /var/cache/apt/archives/partial/
# Set permissions for caching
sudo chown -R $(id -u):$(id -g) /var/lib/apt/lists/
sudo chown -R $(id -u):$(id -g) /var/cache/apt/archives/
# Other cleanup
sudo rm -rf /tmp/*
sudo rm -rf /var/tmp/*
sudo rm -rf ~/.cache/cross-rs/*
shell: bash
- name: Cache apt packages
uses: actions/cache@v3
id: apt-cache
with:
path: |
/var/lib/apt/lists
/var/cache/apt/archives
key: ${{ runner.os }}-apt-${{ hashFiles('/var/lib/apt/lists/*', '/var/cache/apt/archives/*.deb') }}
restore-keys: |
${{ runner.os }}-apt-${{ github.ref_name }}-
${{ runner.os }}-apt-
- name: Cache Build Release
uses: actions/cache@v3
with:
path: |
target/x86_64-unknown-freebsd/release
target/release
key: freebsd-release-${{ hashFiles('target/x86_64-unknown-freebsd/release/**', 'target/release/**') }}
restore-keys: |
freebsd-release-
- name: Cache Rust toolchain
uses: actions/cache@v3
with:
path: ~/.rustup
key: freebsd-rustup-${{ hashFiles('**/Cargo.lock') }}
restore-keys: freebsd-rustup-
- name: Cache cross compiled artifacts (FreeBSD)
uses: actions/cache@v3
with:
path: target/x86_64-unknown-freebsd
key: freebsd-cargo-compiled-${{ hashFiles('**/Cargo.lock') }}
restore-keys: freebsd-cargo-compiled-
- name: Cache cross Docker image
uses: actions/cache@v3
id: cached-image
with:
path: ${{ runner.temp }}/freebsd-cross.tar
key: freebsd-cross-${{ hashFiles('**/Cargo.lock') }}
- name: Load cross Docker image
if: steps.cached-image.outputs.cache-hit == 'true'
run: docker load -i $RUNNER_TEMP/freebsd-cross.tar
- name: Pull and Save cross Docker image
if: steps.cached-image.outputs.cache-hit != 'true'
run: |
docker pull ghcr.io/cross-rs/x86_64-unknown-freebsd:0.2.5
docker save ghcr.io/cross-rs/x86_64-unknown-freebsd:0.2.5 -o $RUNNER_TEMP/freebsd-cross.tar
- name: Setup Build Environment
run: |
# Remove old references
echo "Skipping manual FreeBSD libraries..."
sudo rm -rf /usr/local/freebsd
sudo rm -rf /usr/cross/freebsd
# Create cache directory if it doesn't exist
mkdir -p ~/.cache/cross-rs
# Only install the Rust target
rustup target add x86_64-unknown-freebsd
shell: bash
- name: Install Dependencies (FreeBSD)
run: |
# Only update apt if cache was not found
if [ "${{ steps.apt-cache.outputs.cache-hit }}" != 'true' ]; then
sudo apt-get update
fi
sudo apt-get install -y pkg-config libssl-dev
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-unknown-freebsd
profile: minimal
override: true
- name: Cache Build Outputs
uses: actions/cache@v3
id: cache-build
with:
path: |
target/x86_64-unknown-freebsd/release/
target/release/
target/x86_64-unknown-freebsd/release/deps/
target/x86_64-unknown-freebsd/release/build/
target/release/deps/
target/release/build/
Changes.md
key: freebsd-build-${{ hashFiles('Cargo.toml', 'Cargo.lock', 'src/**/*.rs') }}
restore-keys: |
freebsd-build-
- name: Build Release
# if: steps.cache-build.outputs.cache-hit != 'true'
uses: houseabsolute/actions-rust-cross@v0
with:
target: x86_64-unknown-freebsd
args: "--release"
strip: true
- name: Verify Build Artifacts
run: |
ls -la target/x86_64-unknown-freebsd/release/ || true
ls -la target/release/ || true
shell: bash
- name: Upload FreeBSD Artifact
uses: actions/upload-artifact@v4
with:
name: DSvClient-freebsd
path: target/x86_64-unknown-freebsd/release/DSvClient
retention-days: 7
if-no-files-found: error
- name: Create Changes.md
if: steps.cache-build.outputs.cache-hit != 'true'
run: |
echo "# Changelog" > Changes.md
echo "## v0.1.0" >> Changes.md
echo "* Initial release" >> Changes.md
shell: bash
- name: Post-build cleanup
if: always()
run: |
# Remove lock files and partial directories
sudo rm -f /var/lib/apt/lists/lock
sudo rm -f /var/cache/apt/archives/lock
sudo rm -rf /var/lib/apt/lists/partial/
sudo rm -rf /var/cache/apt/archives/partial/
# Clean up other directories
sudo rm -rf /tmp/*
sudo rm -rf /var/tmp/*
sudo rm -rf ~/.cargo/.git
sudo rm -rf target/debug
sudo rm -rf target/release/deps
sudo rm -rf target/release/build
# Reset permissions
sudo chown -R root:root /var/lib/apt/lists/
sudo chown -R root:root /var/cache/apt/archives/
shell: bash
- name: Publish Release
#if: steps.cache-build.outputs.cache-hit != 'true'
uses: houseabsolute/actions-rust-release@v0
with:
executable-name: DSvClient
target: x86_64-unknown-freebsd
changes-file: Changes.md