Skip to content

Commit d39ed62

Browse files
Merge pull request #34 from max-ieremenko/feature/ci-build
github actions ci build
2 parents dbae200 + 47dae5a commit d39ed62

19 files changed

Lines changed: 243 additions & 20 deletions

.github/workflows/ci.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- 'release/**'
8+
paths-ignore:
9+
- '**.md'
10+
pull_request:
11+
branches:
12+
- master
13+
- 'release/**'
14+
paths-ignore:
15+
- '**.md'
16+
17+
jobs:
18+
build:
19+
name: win-build
20+
runs-on: windows-latest
21+
22+
steps:
23+
- uses: actions/checkout@v3
24+
25+
- name: Install dependencies
26+
shell: pwsh
27+
run: ./Build/install-dependencies.ps1
28+
29+
- name: Dotnet info
30+
shell: pwsh
31+
run: dotnet --info
32+
33+
- name: Build
34+
shell: pwsh
35+
run: ./Build/build.ps1 -Mode "github" -GithubToken "${{ secrets.GITHUB_TOKEN }}"
36+
37+
- name: Artifacts
38+
uses: actions/upload-artifact@v3
39+
with:
40+
name: packages
41+
path: |
42+
.\bin\artifacts\*.nupkg
43+
.\bin\artifacts\*.zip
44+
if-no-files-found: error

Build/build.ps1

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
#Requires -Version "7.0"
22
#Requires -Modules @{ ModuleName="InvokeBuild"; ModuleVersion="5.10.4" }
3+
#Requires -Modules @{ ModuleName="ThirdPartyLibraries"; ModuleVersion="3.4.1" }
4+
5+
[CmdletBinding()]
6+
param (
7+
[Parameter()]
8+
[ValidateSet("local", "github")]
9+
[string]
10+
$Mode,
11+
12+
[Parameter()]
13+
[string]
14+
$GithubToken
15+
)
316

417
Set-StrictMode -Version Latest
518
$ErrorActionPreference = "Stop"
619

7-
$file = Join-Path $PSScriptRoot "build-tasks.ps1"
8-
Invoke-Build -File $file
20+
$file = Join-Path $PSScriptRoot "tasks/build-tasks.ps1"
21+
$task = ($Mode -eq "github") ? "GithubBuild" : "LocalBuild"
22+
23+
Invoke-Build -File $file -Task $task -GithubToken $GithubToken

Build/create-images.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
Set-StrictMode -Version Latest
55

6-
$file = Join-Path $PSScriptRoot "create-images-tasks.ps1"
6+
$file = Join-Path $PSScriptRoot "tasks/create-images-tasks.ps1"
77
Invoke-Build -File $file

Build/install-dependencies.ps1

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#Requires -Version "7.0"
2+
3+
[CmdletBinding()]
4+
param (
5+
[Parameter()]
6+
[ValidateSet(".net", "InvokeBuild", "ThirdPartyLibraries")]
7+
[string[]]
8+
$List = (".net", "InvokeBuild", "ThirdPartyLibraries")
9+
)
10+
11+
Set-StrictMode -Version Latest
12+
$ErrorActionPreference = "Stop"
13+
14+
. (Join-Path $PSScriptRoot "scripts/Get-ModuleVersion.ps1")
15+
. (Join-Path $PSScriptRoot "scripts/Invoke-InstallDotNet.ps1")
16+
. (Join-Path $PSScriptRoot "scripts/Invoke-InstallModule.ps1")
17+
18+
if (".net" -in $List) {
19+
Invoke-InstallDotNet -Version "6.0.319"
20+
21+
$version = (Get-Content -Raw (Join-Path $PSScriptRoot "../Sources/global.json") | ConvertFrom-Json).sdk.version
22+
Invoke-InstallDotNet -Version $version
23+
}
24+
25+
if ("InvokeBuild" -in $List) {
26+
$version = Get-ModuleVersion "InvokeBuild"
27+
Invoke-InstallModule -Name "InvokeBuild" -Version $version
28+
}
29+
30+
if ("ThirdPartyLibraries" -in $List) {
31+
$version = Get-ModuleVersion "ThirdPartyLibraries"
32+
Invoke-InstallModule -Name "ThirdPartyLibraries" -Version $version
33+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function Get-ModuleVersion {
2+
param (
3+
[Parameter(Mandatory)]
4+
[string]
5+
$Name
6+
)
7+
8+
$sources = Get-Content (Join-Path $PSScriptRoot "../build.ps1") -Raw
9+
$tokens = $null
10+
$errors = $null
11+
$modules = [Management.Automation.Language.Parser]::ParseInput($sources, [ref]$tokens, [ref]$errors).ScriptRequirements.RequiredModules
12+
foreach ($module in $modules) {
13+
if ($module.Name -eq $Name) {
14+
return $module.Version
15+
}
16+
}
17+
18+
throw "Module $Name not found."
19+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function Get-Version {
1+
function Get-ReleaseVersion {
22
param (
33
[Parameter(Mandatory)]
44
[ValidateScript({ Test-Path $_ })]
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
function Invoke-InstallDotNet {
2+
[CmdletBinding()]
3+
param (
4+
[Parameter(Mandatory)]
5+
[string]
6+
$Version
7+
)
8+
9+
function Test-Version {
10+
param (
11+
[Parameter(Mandatory)]
12+
[System.Management.Automation.SemanticVersion]
13+
$Target,
14+
15+
[Parameter(Mandatory)]
16+
[System.Management.Automation.SemanticVersion]
17+
$Test
18+
)
19+
20+
# 6.0 vs 7.0
21+
if ($Target.Major -ne $Test.Major -or $Target.Minor -ne $Test.Minor) {
22+
$false
23+
}
24+
else {
25+
# 6.0.0 vs 6.0.1
26+
# 7.0.100 vs 7.0.100-rc.2.22477.23
27+
$Target.CompareTo($Test) -le 0
28+
}
29+
}
30+
31+
if (Get-Command -Name dotnet -ErrorAction SilentlyContinue) {
32+
$versions = dotnet --list-sdks
33+
foreach ($installedVersion in $versions) {
34+
# 6.0.401 [C:\Program Files\dotnet\sdk]
35+
$test = ($installedVersion -split " ")[0]
36+
37+
if (Test-Version -Target $Version -Test $test) {
38+
Write-Output ".net sdk $test is alredy installed"
39+
return
40+
}
41+
}
42+
}
43+
44+
$installDir = "C:\Program Files\dotnet"
45+
$installScript = "dotnet-install.ps1"
46+
47+
if ($IsLinux) {
48+
$installDir = "/usr/share/dotnet"
49+
$installScript = "dotnet-install.sh"
50+
}
51+
52+
$downloadDir = Join-Path ([System.IO.Path]::GetTempPath()) "install-dotnet"
53+
if (Test-Path $downloadDir) {
54+
Remove-Item -Path $downloadDir -Recurse -Force
55+
}
56+
57+
New-Item -Path $downloadDir -ItemType Directory | Out-Null
58+
59+
$dotnetInstall = Join-Path $downloadDir $installScript
60+
Invoke-WebRequest -Uri "https://dot.net/v1/$installScript" -OutFile $dotnetInstall
61+
62+
if ($IsLinux) {
63+
chmod +x $dotnetInstall
64+
}
65+
66+
"$dotnetInstall -Version $Version -InstallDir $installDir"
67+
& $dotnetInstall -Version $Version -InstallDir $installDir
68+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
function Invoke-InstallModule {
2+
[CmdletBinding()]
3+
param (
4+
[Parameter(Mandatory)]
5+
[string]
6+
$Name,
7+
8+
[Parameter(Mandatory)]
9+
[string]
10+
$Version
11+
)
12+
13+
$test = Get-InstalledModule -Name $Name -MinimumVersion $Version -ErrorAction "SilentlyContinue"
14+
if ($test) {
15+
Write-Output "$Name $($test.Version) is alredy installed"
16+
return
17+
}
18+
19+
Write-Output "Install $Name $version"
20+
Install-Module -Name $Name -RequiredVersion $Version -Force
21+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ param(
77

88
task Default StartDatabase, UnZip, RunTest
99

10-
Get-ChildItem -Path (Join-Path $PSScriptRoot 'scripts') -Filter *.ps1 | ForEach-Object { . $_.FullName }
10+
Get-ChildItem -Path (Join-Path $PSScriptRoot '../scripts') -Filter *.ps1 | ForEach-Object { . $_.FullName }
1111

1212
$containerId = ""
1313
$connectionString = ""
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ param(
66

77
task Default StartDatabase, RunTest
88

9-
Get-ChildItem -Path (Join-Path $PSScriptRoot 'scripts') -Filter *.ps1 | ForEach-Object { . $_.FullName }
9+
Get-ChildItem -Path (Join-Path $PSScriptRoot '../scripts') -Filter *.ps1 | ForEach-Object { . $_.FullName }
1010

1111
$containerId = ""
1212
$connectionString = ""

0 commit comments

Comments
 (0)