-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from s2quake/ci/improve
Improve CI to make sure minimal checks are done before merge
- Loading branch information
Showing
14 changed files
with
155 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/local/bin/pwsh | ||
param ( | ||
[ValidateScript({ ($_ -eq "") -or !(Test-Path $_ -PathType Leaf) })] | ||
[string]$OutputPath = "", | ||
[ValidateScript({ $_ -ge 0 })] | ||
[int]$PullRequestNumber = 0, | ||
[ValidateScript({ ($_ -eq "") -or (Test-Path $_) })] | ||
[string]$KeyPath = "" | ||
) | ||
|
||
$namespaces = @{ | ||
ns = "http://schemas.microsoft.com/developer/msbuild/2003" | ||
} | ||
$propsPath = "Directory.Build.props" | ||
$fileVersionPath = "/ns:Project/ns:PropertyGroup/ns:FileVersion" | ||
$result = Select-Xml -Path $propsPath -Namespace $namespaces -XPath $fileVersionPath | ||
if ($null -eq $result) { | ||
Write-Host "File version not found" | ||
exit 1 | ||
} | ||
|
||
$fileVersion = $result.Node.InnerText | ||
$KeyPath = $KeyPath ? $(Resolve-Path -Path $KeyPath) : "" | ||
$OutputPath = $OutputPath ? [System.IO.Path]::GetFullPath($OutputPath) : "" | ||
$keyPathExits = Test-Path -Path $KeyPath | ||
|
||
$options = @( | ||
$OutputPath ? "-o '$OutputPath'" : "" | ||
"-p:FileVersion='$fileVersion'" | ||
$PullRequestNumber ? "--version-suffix pr.$PullRequestNumber" : "" | ||
$keyPathExits ? "-p:TreatWarningsAsErrors=true" : "" | ||
$keyPathExits ? "-p:AssemblyOriginatorKeyFile='$KeyPath'" : "" | ||
) | Where-Object { $_ } | ||
|
||
Invoke-Expression -Command "dotnet pack $($options -join " ")" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Check Changelog | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
check-changelog: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: tarides/changelog-check-action@v2 | ||
with: | ||
changelog: CHANGES.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Pack | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- "*" | ||
|
||
jobs: | ||
pack: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4.1.7 | ||
- uses: actions/setup-dotnet@v4.0.0 | ||
with: | ||
dotnet-version: 8.0.100 | ||
- run: echo "${{ secrets.SNK_FILE }}" | base64 --decode > private.snk | ||
- if: ${{ github.event_name == 'pull_request' }} | ||
run: | | ||
.github/scripts/pack.ps1 ` | ||
-OutputPath "pack" ` | ||
-PullRequestNumber ${{ github.event.pull_request.number }} ` | ||
-KeyPath "$pwd/private.snk" | ||
shell: pwsh | ||
- if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | ||
run: | | ||
$commitMessage = "$(git log -1 --pretty=%B)" | ||
$pattern = "(?<=Merge pull request #)(\d+)" | ||
if (!($commitMessage -match $pattern)) { | ||
Write-Error "Commit message does not contain a pull request number." | ||
} | ||
|
||
Remove-Item -Force -Recurse pack -ErrorAction SilentlyContinue | ||
|
||
.github/scripts/pack.ps1 ` | ||
-OutputPath "pack" ` | ||
-PullRequestNumber $matches[1] ` | ||
-KeyPath "$pwd/private.snk" | ||
|
||
Get-ChildItem -Path pack -Filter "*.nupkg" | ForEach-Object { | ||
dotnet nuget push ` | ||
$_ ` | ||
--skip-duplicate ` | ||
--api-key ${{ secrets.NUGET_API_KEY }} ` | ||
--source https://api.nuget.org/v3/index.json | ||
} | ||
shell: pwsh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: Check Typos | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
typos: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: crate-ci/typos@v1.22.9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters