Skip to content

Merge pull request #33 from MolotovCherry/new-app #141

Merge pull request #33 from MolotovCherry/new-app

Merge pull request #33 from MolotovCherry/new-app #141

Workflow file for this run

name: Build
on:
workflow_dispatch:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
release:
types: [created]
env:
CARGO_TERM_COLOR: always
jobs:
build:
permissions: write-all
runs-on: windows-2022
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ github.event_name == 'release' && 'prod' || 'dev' }}
- name: Install cargo-make
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-make
- name: Install cargo-target-dir
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-target-dir
git: https://github.com/MolotovCherry/cargo-target-dir
- name: Install cargo-wix
if: github.event_name == 'release'
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-wix
- name: Export Private Certificate
if: github.event_name != 'pull_request'
env:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
run: |
$env:PRIVATE_KEY | Out-File -FilePath private.txt
certutil -decode private.txt private.pfx
- name: Export PR Private Certificate
if: github.event_name == 'pull_request'
run: cp .github/workflows/build_res/pr.pfx private.pfx
- name: Export Public Certificate
env:
PRIVATE_KEY_PASSWORD: ${{ github.event_name == 'pull_request' && '1234' || secrets.PRIVATE_KEY_PASSWORD }}
run: |
Get-PfxCertificate -FilePath private.pfx -Password (ConvertTo-SecureString -String "${{ env.PRIVATE_KEY_PASSWORD }}" -AsPlainText -Force) | Export-Certificate -FilePath DriverCertificate.cer -type CERT
- name: Build
env:
PRIVATE_KEY_PASSWORD: ${{ github.event_name == 'pull_request' && '1234' || secrets.PRIVATE_KEY_PASSWORD }}
RELEASE: ${{ github.event_name == 'release' && 'prod' || 'dev' }}
run: cargo make -p $env:RELEASE build
- name: Upload Artifacts
if: github.event_name != 'release'
uses: actions/upload-artifact@v3
with:
name: driver
path: |
target/output/*.exe
target/output/*.cat
target/output/*.dll
target/output/*.inf
# this is split from the top in order to allow the files to all be at the top level of the archive
- name: Upload Artifacts
if: github.event_name != 'release'
uses: actions/upload-artifact@v3
with:
name: driver
path: |
DriverCertificate.cer
# this is split from the top in order to allow the files to all be at the top level of the archive
- name: Upload Artifacts
if: github.event_name != 'release'
uses: actions/upload-artifact@v3
with:
name: driver
path: |
installer/install-cert.bat
- name: Set release version
if: github.event_name == 'release'
run: |
$tagName = "${{ github.event.release.tag_name }}"
$version = $tagName.TrimStart('v')
echo "RELEASE_VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Append
# package with wix
- name: Create installer
if: github.event_name == 'release'
run: |
cargo wix -p virtual-display-driver -i ${{ env.RELEASE_VERSION }} --nocapture -I installer/main.wxs -o target\output -C -ext -C WixDifxAppExtension -L -ext -L WixDifxAppExtension -L "C:\Program Files (x86)\WiX Toolset v3.11\bin\difxapp_x64.wixlib"
- name: Sign installer
if: github.event_name == 'release'
shell: cmd
env:
PRIVATE_KEY_PASSWORD: ${{ github.event_name == 'pull_request' && '1234' || secrets.PRIVATE_KEY_PASSWORD }}
run: |
call "%ProgramFiles%\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat"
signtool sign /a /fd SHA256 /v /f private.pfx /p ${{ env.PRIVATE_KEY_PASSWORD }} /t http://timestamp.digicert.com target/output/*.msi
- name: Zip up install package
if: github.event_name == 'release'
run: |
Get-ChildItem -Path DriverCertificate.cer, installer/install-cert.bat, target/output/*.msi | Compress-Archive -CompressionLevel Optimal -DestinationPath "virtual-desktop-driver-installer-x64.zip"
- name: Zip up portable package
if: github.event_name == 'release'
run: |
Get-ChildItem -Path DriverCertificate.cer, installer/install-cert.bat, target/output/*.inf, target/output/*.dll, target/output/*.cat, target/output/*.exe, installer/files/*.reg | Compress-Archive -CompressionLevel Optimal -DestinationPath "virtual-desktop-driver-portable-x64.zip"
- name: Attach assets to release
if: github.event_name == 'release'
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
file: "*.zip"
draft: false
release_id: ${{ github.event.release.id }}