Skip to content

Commit 851315e

Browse files
committed
Update build process
1 parent c88edae commit 851315e

File tree

4 files changed

+76
-14
lines changed

4 files changed

+76
-14
lines changed

appveyor.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: "{build}-{branch}"
2+
image: Visual Studio 2017
3+
4+
init:
5+
- ps: '(Get-ChildItem -Path "Env:").Where({ $_.Name -match "^(?:BH|CI(?:_|$)|APPVEYOR)" })'
6+
install:
7+
- ps: .\install.ps1
8+
build_script:
9+
- ps: .\build.ps1
10+
after_build:
11+
- ps: .\release.ps1
12+
- on:
13+
APPVEYOR_REPO_TAG: true
14+
15+
artifacts:
16+
- path: 'build\*'
17+
name: release
18+
19+
deploy:
20+
description: '$(GITHUB_RELEASE_NOTES)'
21+
provider: GitHub
22+
auth_token:
23+
secure: TpQW7XTUsFihAjHMpMhMSKNyxF/6WVuEloQxniIajPtQSfBd8X91jUJAR4TZxn8o
24+
artifact: 'release'
25+
draft: false
26+
prerelease: false
27+
on:
28+
APPVEYOR_REPO_TAG: true

build.ps1

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
Param([Switch]$Fast)
21
Push-Location $psscriptroot
3-
. "$psscriptroot\..\..\lib\install.ps1"
42

5-
if(!$Fast) {
6-
Write-Host "Install dependencies ..."
7-
Invoke-Expression "$psscriptroot\install.ps1"
8-
}
3+
# Prepare
4+
$build = "$PSScriptRoot\build"
5+
$src = "$PSScriptRoot\src"
6+
New-Item -ItemType Directory -Path $build -ErrorAction SilentlyContinue | Out-Null
7+
Remove-Item "$build\*" -Recurse -Force | Out-Null
98

10-
$output = "$psscriptroot\bin"
9+
# Build
1110
Write-Output 'Compiling shim.cs ...'
12-
& "$psscriptroot\packages\Microsoft.Net.Compilers\tools\csc.exe" /deterministic /platform:anycpu /nologo /optimize /target:exe /out:"$output\shim.exe" shim.cs
11+
& "$PSScriptRoot\packages\Microsoft.Net.Compilers\tools\csc.exe" /deterministic /platform:anycpu /nologo /optimize /target:exe /out:"$build\shim.exe" "$src\shim.cs"
1312

13+
# Checksums
1414
Write-Output 'Computing checksums ...'
15-
Remove-Item "$psscriptroot\bin\checksum.sha256" -ErrorAction Ignore
16-
Remove-Item "$psscriptroot\bin\checksum.sha512" -ErrorAction Ignore
17-
Get-ChildItem "$psscriptroot\bin\*" -Include *.exe,*.dll | ForEach-Object {
18-
"$(compute_hash $_ 'sha256') *$($_.Name)" | Out-File "$psscriptroot\bin\checksum.sha256" -Append -Encoding oem
19-
"$(compute_hash $_ 'sha512') *$($_.Name)" | Out-File "$psscriptroot\bin\checksum.sha512" -Append -Encoding oem
15+
Get-ChildItem "$build\*" -Include *.exe,*.dll -Recurse | ForEach-Object {
16+
$checksum = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash.ToLower()
17+
"$checksum *$($_.Name)" | Tee-Object -FilePath "$build\$($_.Name).sha256" -Append
2018
}
19+
2120
Pop-Location

packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Microsoft.Net.Compilers" version="2.10.0" targetFramework="net45" developmentDependency="true" />
3+
<package id="Microsoft.Net.Compilers" version="3.0.0" targetFramework="net45" developmentDependency="true" />
44
</packages>

release.ps1

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
if(!$env:APPVEYOR_REPO_TAG) {
2+
return
3+
}
4+
5+
Write-Output 'Generating release notes ...'
6+
#region GitHub release notes
7+
$previousRelease = (Invoke-RestMethod -Uri "https://api.github.com/repos/$env:APPVEYOR_REPO_NAME/releases/latest?access_token=$env:GITHUB_ACCESS_TOKEN" -Verbose)
8+
Write-Host "Previous Release: $($previousRelease.name) ($($previousRelease.target_commitish))"
9+
$compare = (Invoke-RestMethod -Uri "https://api.github.com/repos/$env:APPVEYOR_REPO_NAME/compare/$($previousRelease.target_commitish)...$env:APPVEYOR_REPO_COMMIT`?access_token=$env:GITHUB_ACCESS_TOKEN" -Verbose)
10+
$releaseNotes = "## Release Notes`n#### Version [$env:APPVEYOR_REPO_TAG_NAME](https://github.com/$env:APPVEYOR_REPO_NAME/tree/$env:APPVEYOR_REPO_TAG_NAME)`n"
11+
12+
if($null -ne $compare.commits -and $compare.commits.Length -gt 0) {
13+
$releaseNotes += "`nCommit | Description`n--- | ---`n"
14+
$contributions = @{}
15+
$compare.commits | Sort-Object -Property @{Expression={$_.commit.author.date};} -Descending | ForEach-Object {
16+
$commitMessage = $_.commit.message.Replace("`r`n"," ").Replace("`n"," ");
17+
if ($commitMessage.ToLower().StartsWith('merge') -or
18+
$commitMessage.ToLower().StartsWith('merging') -or
19+
$commitMessage.ToLower().StartsWith('private')) {
20+
continue
21+
}
22+
$releaseNotes += "[``$($_.sha.Substring(0, 7))``](https://github.com/$env:APPVEYOR_REPO_NAME/tree/$($_.sha)) | $commitMessage`n"
23+
$contributions.$($_.author.login)++
24+
}
25+
$releaseNotes += "`nContributor | Commits`n--- | ---`n"
26+
$contributions.GetEnumerator() | Sort-Object -Property @{Expression={$_.Value}} -Descending | ForEach-Object {
27+
$releaseNotes += "@$($_.Name) | $($_.Value)`n"
28+
}
29+
} else {
30+
$releaseNotes += "There are no new items for this release."
31+
}
32+
33+
$env:GITHUB_RELEASE_NOTES = $releaseNotes
34+
Write-Output $releaseNotes
35+
#endregion

0 commit comments

Comments
 (0)