Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 58 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,57 @@ jobs:
path: native-assets/${{ matrix.rid }}/${{ matrix.library }}
if-no-files-found: error

managed:
name: Build .NET managed bindings
needs: version
runs-on: ubuntu-latest
env:
NUGET_PACKAGES: ${{ github.workspace }}/nuget-packages

steps:
- name: Check out repository
uses: actions/checkout@v7
with:
persist-credentials: false

- name: Set up .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x

- name: Restore managed bindings
shell: pwsh
run: >-
dotnet restore bindings/csharp/Expressif.Syntax/Expressif.Syntax.csproj
-p:Version='${{ needs.version.outputs.semver }}'
-p:PackageVersion='${{ needs.version.outputs.semver }}'

- name: Build managed bindings
shell: pwsh
run: >-
dotnet build bindings/csharp/Expressif.Syntax/Expressif.Syntax.csproj
--configuration Release
--no-restore
-p:Version='${{ needs.version.outputs.semver }}'
-p:PackageVersion='${{ needs.version.outputs.semver }}'
-p:BuildNativeGrammar=false

- name: Upload managed bindings
uses: actions/upload-artifact@v7
with:
name: managed-${{ needs.version.outputs.semver }}
path: |
bindings/csharp/Expressif.Syntax/bin/Release
bindings/csharp/Expressif.Syntax/obj
nuget-packages
if-no-files-found: error

package:
name: Build C# package
needs: [version, native]
name: Pack NuGet package
needs: [version, native, managed]
runs-on: ubuntu-latest
env:
NUGET_PACKAGES: ${{ github.workspace }}/nuget-packages

steps:
- name: Check out repository
Expand All @@ -123,6 +170,12 @@ jobs:
with:
dotnet-version: 10.0.x

- name: Download managed bindings
uses: actions/download-artifact@v8
with:
name: managed-${{ needs.version.outputs.semver }}
path: .

- name: Download Windows native grammar library
uses: actions/download-artifact@v8
with:
Expand Down Expand Up @@ -159,10 +212,10 @@ jobs:
name: native-osx-arm64
path: native-assets/osx-arm64

- name: Build NuGet package
- name: Pack NuGet package
shell: pwsh
run: >-
./scripts/Build-NuGetPackage.ps1
./scripts/Pack-NuGetPackage.ps1
-Version '${{ needs.version.outputs.semver }}'
-NativeAssetsDirectory 'native-assets'

Expand Down Expand Up @@ -273,36 +326,10 @@ jobs:
path: artifacts/*
if-no-files-found: error

gate:
name: CI gate
if: always()
needs: [version, parser, native, package, consume, native-archive, collect]
runs-on: ubuntu-latest

steps:
- name: Require every validation job to succeed
shell: pwsh
run: |
$results = @{
version = '${{ needs.version.result }}'
parser = '${{ needs.parser.result }}'
native = '${{ needs.native.result }}'
package = '${{ needs.package.result }}'
consume = '${{ needs.consume.result }}'
nativeArchive = '${{ needs.native-archive.result }}'
collect = '${{ needs.collect.result }}'
}
$failed = @($results.GetEnumerator() | Where-Object Value -ne 'success')
if ($failed.Count -gt 0) {
$failed | ForEach-Object { Write-Error "$($_.Key) finished with result '$($_.Value)'." }
exit 1
}
Write-Output 'All required CI validations succeeded.'

publish:
name: Publish patch-zero release
if: github.ref == 'refs/heads/main' && needs.version.outputs.patch == '0'
needs: [version, gate]
needs: [version, collect]
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down
3 changes: 2 additions & 1 deletion bindings/csharp/Expressif.Syntax/Expressif.Syntax.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<ExpressifGrammarLibrary Condition="$([MSBuild]::IsOSPlatform('Linux'))">libtree-sitter-expressif.so</ExpressifGrammarLibrary>
<ExpressifGrammarLibrary Condition="$([MSBuild]::IsOSPlatform('OSX'))">libtree-sitter-expressif.dylib</ExpressifGrammarLibrary>
<TreeSitterCli>tree-sitter</TreeSitterCli>
<BuildNativeGrammar Condition="'$(BuildNativeGrammar)' == ''">true</BuildNativeGrammar>
<TreeSitterCli Condition="$([MSBuild]::IsOSPlatform('Windows')) And Exists('$(MSBuildThisFileDirectory)..\..\..\node_modules\.bin\tree-sitter.cmd')">$(MSBuildThisFileDirectory)..\..\..\node_modules\.bin\tree-sitter.cmd</TreeSitterCli>
<TreeSitterCli Condition="!$([MSBuild]::IsOSPlatform('Windows')) And Exists('$(MSBuildThisFileDirectory)../../../node_modules/.bin/tree-sitter')">$(MSBuildThisFileDirectory)../../../node_modules/.bin/tree-sitter</TreeSitterCli>
</PropertyGroup>
Expand Down Expand Up @@ -56,7 +57,7 @@
Text="The macOS ARM64 native grammar library was not found in '$(NativeAssetsDirectory)/osx-arm64'." />
</Target>

<Target Name="BuildExpressifGrammar" BeforeTargets="Build" Condition="'$(NativeAssetsDirectory)' == ''" Inputs="$(MSBuildThisFileDirectory)..\..\..\src\parser.c" Outputs="$(TargetDir)$(ExpressifGrammarLibrary)">
<Target Name="BuildExpressifGrammar" BeforeTargets="Build" Condition="'$(NativeAssetsDirectory)' == '' And '$(BuildNativeGrammar)' == 'true'" Inputs="$(MSBuildThisFileDirectory)..\..\..\src\parser.c" Outputs="$(TargetDir)$(ExpressifGrammarLibrary)">
<Exec WorkingDirectory="$(MSBuildThisFileDirectory)..\..\.." Command="&quot;$(TreeSitterCli)&quot; build -o &quot;$(TargetDir)$(ExpressifGrammarLibrary)&quot; ." />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,12 @@ $properties = @(
"/p:NativeAssetsDirectory=$nativeAssetsPath"
)

dotnet restore $projectPath @properties
if ($LASTEXITCODE -ne 0) { throw 'NuGet restore failed.' }

dotnet build $projectPath --configuration Release --no-restore @properties
if ($LASTEXITCODE -ne 0) { throw 'Managed assembly build failed.' }

dotnet pack $projectPath `
--configuration Release `
--output $outputPath `
--no-build `
--no-restore `
--disable-build-servers `
-m:1 `
@properties
if ($LASTEXITCODE -ne 0) { throw 'NuGet packaging failed.' }
Loading