Skip to content
name: Build and Upload Artifacts on Release
on:
release:
types: [created]
defaults:
run:
shell: powershell
jobs:
build:
runs-on: windows-latest
permissions: write-all
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Convert tag to version
id: convert_tag
run: |
$version = "${{ github.ref }}"
$version = $version.Replace('refs/tags/', '')
echo "version=$version" >> "$env:GITHUB_ENV"
echo "version=$version"
- name: Configure PowerShell
run: |
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force
- name: Install ps2exe module to compile PowerShell scripts
run: |
Install-Module -Name ps2exe -Scope CurrentUser -Force
- name: Install Scoop, Nim and Nim dependencies
run: |
iex "& {$(irm get.scoop.sh)} -RunAsAdmin"
echo "$env:USERPROFILE\scoop\shims" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
scoop install 7zip git nim
nimble update -y
nimble install -y puppy
- name: Compile Nim applications
run: |
nim c --cc:vcc -d:release -d:static -o:wsl-perf.exe wslperf.nim
- name: Compile PowerShell scripts
run: |
echo "Compile version ${{ env.version }}"
Get-ChildItem -Path . -Filter '*.ps1' -Recurse -Exclude build-wslinternals.ps1,sched-wsl-dist-update.ps1 | ForEach-Object {
Invoke-ps2exe -inputFile $_.Name -verbose
}
- name: Create archive
run: |
Compress-Archive -Path .\*.exe, .\sched-wsl-dist-update.ps1 -DestinationPath "${{ env.version }}.zip"
- name: Upload executable files
run: |
Get-ChildItem -Path . -Filter *.exe -Recurse | ForEach-Object {
$fileName = $_.Name
$hash = Get-FileHash -Path $_.Name -Algorithm SHA256
$hashLine = "$($hash.Hash.ToLower()) $fileName"
Add-Content -Path "SHA2-256SUMS" -Value $hashLine
gh release upload ${{ env.version }} $fileName --clobber
}
gh release upload ${{ env.version }} SHA2-256SUMS --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload zip file
run: |
Get-ChildItem -Path . -Filter *.zip -Recurse | ForEach-Object {
$fileName = $_.Name
$hash = Get-FileHash -Path $_.Name -Algorithm SHA256
$hashLine = "$($hash.Hash.ToLower()) $fileName"
Add-Content -Path "SHA2-256SUMS" -Value $hashLine
gh release upload ${{ env.version }} $fileName --clobber
}
gh release upload ${{ env.version }} SHA2-256SUMS --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}