Skip to content

Commit

Permalink
refactor: Switch to Github Actions
Browse files Browse the repository at this point in the history
Change license
  • Loading branch information
Ash258 committed Dec 21, 2020
1 parent fc42983 commit 2e24ce8
Show file tree
Hide file tree
Showing 8 changed files with 754 additions and 111 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
on:
push:
workflow_dispatch:
pull_request:
name: CI
jobs:
CI:
name: CI
runs-on: windows-latest
steps:
- uses: actions/checkout@main
- name: Build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}'
run: |
& '.\install.ps1'
& '.\build.ps1'
- name: Upload Release Asset
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$tag = ($env:GITHUB_REF -split '/')[-1]
$hubArgs = @()
Get-ChildItem 'dist/*' | ForEach-Object {
$hubArgs += '-a'
$hubArgs += "$($_.FullName)"
}
$hubArgs = $hubArgs + @('--draft', "-m ""$tag""", """$tag""")
hub release create @hubArgs
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
packages/
build/
dist/
/packages/
/build/
/dist/
698 changes: 674 additions & 24 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A small program that validates JSON files against a JSON Schema. It's mainly use

This is a helper program for [Scoop](https://scoop.sh), the Windows command-line installer.

# Usage
## Usage

```pwsh
validator.exe <schema> <manifest> [<manifest>...]
Expand Down
28 changes: 0 additions & 28 deletions appveyor.yml

This file was deleted.

51 changes: 35 additions & 16 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,33 +1,52 @@
Push-Location $PSScriptRoot

# Prepare
$csc = "$PSScriptRoot\packages\Microsoft.Net.Compilers\tools\csc.exe"
$build = "$PSScriptRoot\build"
$dist = "$PSScriptRoot\dist"
$src = "$PSScriptRoot\src"
New-Item -ItemType Directory -Path $build -ErrorAction SilentlyContinue | Out-Null
New-Item -ItemType Directory -Path $dist -ErrorAction SilentlyContinue | Out-Null
Remove-Item "$build\*" -Recurse -Force | Out-Null
Remove-Item "$dist\*" -Recurse -Force | Out-Null
New-Item -Path $build, $dist -ItemType 'Directory' -ErrorAction 'SilentlyContinue' | Out-Null
Remove-Item "$build\*", "$dist\*" -Recurse -Force

if ((Get-ChildItem "$PSScriptRoot\packages" -Recurse).Count -eq 0) {
Write-Host 'Dependencies are missing. Run ''install.ps1''' -ForegroundColor 'DarkRed'
exit 258
}

# Build
Copy-Item "$PSScriptRoot\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll" $build
Copy-Item "$PSScriptRoot\packages\Newtonsoft.Json.Schema\lib\net45\Newtonsoft.Json.Schema.dll" $build
Copy-Item "$PSScriptRoot\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll", "$PSScriptRoot\packages\Newtonsoft.Json.Schema\lib\net45\Newtonsoft.Json.Schema.dll" $build

Write-Output 'Compiling Scoop.Validator.cs ...'
& "$PSScriptRoot\packages\Microsoft.Net.Compilers\tools\csc.exe" /deterministic /platform:anycpu /nologo /optimize /target:library /reference:"$build\Newtonsoft.Json.dll","$build\Newtonsoft.Json.Schema.dll" /out:"$build\Scoop.Validator.dll" "$src\Scoop.Validator.cs"
Write-Output 'Compiling validator.cs ...'
& "$PSScriptRoot\packages\Microsoft.Net.Compilers\tools\csc.exe" /deterministic /platform:anycpu /nologo /optimize /target:exe /reference:"$build\Scoop.Validator.dll","$build\Newtonsoft.Json.dll","$build\Newtonsoft.Json.Schema.dll" /out:"$build\validator.exe" "$src\validator.cs"
$ScoopValidatorCs = @(
'/deterministic'
'/nologo'
'/optimize'
'/platform:anycpu'
'/target:library'
"/reference:""$build\Newtonsoft.Json.dll"",""$build\Newtonsoft.Json.Schema.dll"""
"/out:""$build\Scoop.Validator.dll"""
"$src\Scoop.Validator.cs"
)
& $csc @ScoopValidatorCs

# Checksums
Write-Output 'Computing checksums ...'
Get-ChildItem "$build\*" -Include *.exe,*.dll -Recurse | ForEach-Object {
$checksum = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash.ToLower()
"$checksum *$($_.FullName.Replace($build, '').TrimStart('\'))" | Tee-Object -FilePath "$build\checksums.sha256" -Append
}
Write-Output 'Compiling validator.cs ...'
$ValidatorCs = @(
'/deterministic'
'/nologo'
'/optimize'
'/platform:anycpu'
'/target:exe'
"/reference:""$build\Scoop.Validator.dll"",""$build\Newtonsoft.Json.dll"",""$build\Newtonsoft.Json.Schema.dll"""
"/out:""$build\validator.exe"""
"$src\validator.cs"
)
& $csc @ValidatorCs

# Package
7z a "$dist\validator.zip" "$build\*"
Get-ChildItem "$dist\*" | ForEach-Object {
$checksum = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash.ToLower()
$checksum = (Get-FileHash -Path $_.FullName -Algorithm 'SHA256').Hash.ToLower()
"$checksum *$($_.Name)" | Tee-Object -FilePath "$dist\$($_.Name).sha256" -Append
}

Pop-Location
14 changes: 10 additions & 4 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# https://github.com/edymtt/nugetstandalone
$destinationFolder = "$psscriptroot\packages"
if ((Test-Path -path $destinationFolder)) {
Remove-Item -Path $destinationFolder -Recurse | Out-Null

try {
Get-Command -Name 'nuget' -Type 'Application' -ErrorAction 'Stop' | Out-Null
} catch {
Write-Host '''nuget'' not installed.' -ForegoundColor DarkRed
exit 258
}

New-Item $destinationFolder -Type Directory | Out-Null
$destinationFolder = "$PSScriptRoot\packages"
if (Test-Path $destinationFolder) { Remove-Item $destinationFolder -Recurse }
New-Item $destinationFolder -Type 'Directory' | Out-Null

nuget install packages.config -o $destinationFolder -ExcludeVersion
35 changes: 0 additions & 35 deletions release.ps1

This file was deleted.

0 comments on commit 2e24ce8

Please sign in to comment.