-
Notifications
You must be signed in to change notification settings - Fork 0
Add multi-platform MiniExcelRust NuGet preview #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bda181b
feat: add multi-platform MiniExcelRust NuGet
shps951023 6b9e54f
fix: use cdylib-capable Rust for musl builds
shps951023 36b1149
fix: select the musl Rust toolchain explicitly
shps951023 2a60423
fix: build musl cdylibs with dynamic CRT
shps951023 65703da
ci: assemble the complete preview package
shps951023 cc1c2c7
ci: use NuGet trusted publishing
shps951023 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,138 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| validate: | ||
| name: Validate source | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: dtolnay/rust-toolchain@1.85.0 | ||
| with: | ||
| components: clippy, rustfmt | ||
| - uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: 8.0.x | ||
| - uses: Swatinem/rust-cache@v2 | ||
| - name: Check Rust formatting | ||
| run: cargo fmt --all -- --check | ||
| - name: Run Clippy | ||
| run: cargo clippy --workspace --all-targets --locked -- -D warnings | ||
| - name: Run Rust tests | ||
| run: cargo test --workspace --all-targets --locked | ||
| - name: Build managed package | ||
| run: dotnet build src/MiniExcelRust/MiniExcelRust.csproj -c Release | ||
|
|
||
| native-package-test: | ||
| name: Test ${{ matrix.rid }} package | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - runner: windows-latest | ||
| rid: win-x64 | ||
| - runner: windows-11-arm | ||
| rid: win-arm64 | ||
| - runner: ubuntu-latest | ||
| rid: linux-x64 | ||
| - runner: ubuntu-24.04-arm | ||
| rid: linux-arm64 | ||
| - runner: macos-15-intel | ||
| rid: osx-x64 | ||
| - runner: macos-latest | ||
| rid: osx-arm64 | ||
| runs-on: ${{ matrix.runner }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: dtolnay/rust-toolchain@1.85.0 | ||
| - uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: 8.0.x | ||
| - uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| key: ${{ matrix.rid }} | ||
| - name: Build, pack, and test | ||
| shell: pwsh | ||
| run: ./build/Test-Package.ps1 -Rid '${{ matrix.rid }}' | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ matrix.rid }} | ||
| path: artifacts/native/${{ matrix.rid }}/* | ||
| if-no-files-found: error | ||
|
|
||
| musl-package-test: | ||
| name: Test ${{ matrix.rid }} package | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - runner: ubuntu-latest | ||
| rid: linux-musl-x64 | ||
| - runner: ubuntu-24.04-arm | ||
| rid: linux-musl-arm64 | ||
| runs-on: ${{ matrix.runner }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: dtolnay/rust-toolchain@1.85.0 | ||
| with: | ||
| targets: ${{ matrix.rid == 'linux-musl-x64' && 'x86_64-unknown-linux-musl' || 'aarch64-unknown-linux-musl' }} | ||
| - uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: 8.0.x | ||
| - uses: mlugg/setup-zig@v2 | ||
| - uses: taiki-e/install-action@v2 | ||
| with: | ||
| tool: cargo-zigbuild | ||
| - uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| key: ${{ matrix.rid }} | ||
| - name: Build native asset | ||
| shell: pwsh | ||
| run: ./build/Build-Native.ps1 -Rid '${{ matrix.rid }}' -UseZig -Toolchain 1.85.0 | ||
| - name: Pack | ||
| run: dotnet pack src/MiniExcelRust/MiniExcelRust.csproj -c Release -o artifacts/packages -p:MiniExcelRustRequireAllNativeAssets=false | ||
| - name: Test package in Alpine | ||
| shell: bash | ||
| run: | | ||
| docker run --rm \ | ||
| -v "$GITHUB_WORKSPACE:/work" \ | ||
| -w /work \ | ||
| mcr.microsoft.com/dotnet/sdk:8.0-alpine \ | ||
| sh -lc 'dotnet restore tests/MiniExcelRust.PackageTests/MiniExcelRust.PackageTests.csproj --source artifacts/packages && dotnet run --project tests/MiniExcelRust.PackageTests/MiniExcelRust.PackageTests.csproj -c Release --no-restore' | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ matrix.rid }} | ||
| path: artifacts/native/${{ matrix.rid }}/* | ||
| if-no-files-found: error | ||
|
|
||
| assemble-package: | ||
| name: Assemble eight-RID NuGet | ||
| needs: [validate, native-package-test, musl-package-test] | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: 8.0.x | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| pattern: '*' | ||
| path: artifacts/native | ||
| - name: Pack complete NuGet | ||
| run: dotnet pack src/MiniExcelRust/MiniExcelRust.csproj -c Release -o artifacts/packages | ||
| - name: Verify package contents | ||
| shell: pwsh | ||
| run: ./build/Verify-Package.ps1 -PackagePath artifacts/packages/MiniExcelRust.0.1.0-preview.1.nupkg | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: nuget-preview | ||
| path: artifacts/packages/MiniExcelRust.0.1.0-preview.1.*nupkg | ||
| if-no-files-found: error |
This file contains hidden or 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,226 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'v*.*.*-preview.*' | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: NuGet version, for example 0.1.0-preview.1 | ||
| required: true | ||
| default: 0.1.0-preview.1 | ||
| type: string | ||
| publish: | ||
| description: Publish to NuGet.org after all tests pass | ||
| required: true | ||
| default: false | ||
| type: boolean | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| prepare: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| version: ${{ steps.version.outputs.value }} | ||
| steps: | ||
| - id: version | ||
| name: Validate version | ||
| shell: bash | ||
| env: | ||
| REQUESTED_VERSION: ${{ github.event_name == 'push' && github.ref_name || inputs.version }} | ||
| run: | | ||
| version="${REQUESTED_VERSION#v}" | ||
| if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+-preview\.[0-9]+$ ]]; then | ||
| echo "::error::Version '$version' must match N.N.N-preview.N." | ||
| exit 1 | ||
| fi | ||
| echo "value=$version" >> "$GITHUB_OUTPUT" | ||
|
|
||
| build-native: | ||
| needs: prepare | ||
| name: Build ${{ matrix.rid }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - runner: windows-latest | ||
| rid: win-x64 | ||
| target: x86_64-pc-windows-msvc | ||
| rust: 1.85.0 | ||
| zig: false | ||
| - runner: windows-11-arm | ||
| rid: win-arm64 | ||
| target: aarch64-pc-windows-msvc | ||
| rust: 1.85.0 | ||
| zig: false | ||
| - runner: ubuntu-latest | ||
| rid: linux-x64 | ||
| target: x86_64-unknown-linux-gnu | ||
| rust: 1.85.0 | ||
| zig: false | ||
| - runner: ubuntu-24.04-arm | ||
| rid: linux-arm64 | ||
| target: aarch64-unknown-linux-gnu | ||
| rust: 1.85.0 | ||
| zig: false | ||
| - runner: ubuntu-latest | ||
| rid: linux-musl-x64 | ||
| target: x86_64-unknown-linux-musl | ||
| rust: 1.85.0 | ||
| zig: true | ||
| - runner: ubuntu-24.04-arm | ||
| rid: linux-musl-arm64 | ||
| target: aarch64-unknown-linux-musl | ||
| rust: 1.85.0 | ||
| zig: true | ||
| - runner: macos-15-intel | ||
| rid: osx-x64 | ||
| target: x86_64-apple-darwin | ||
| rust: 1.85.0 | ||
| zig: false | ||
| - runner: macos-latest | ||
| rid: osx-arm64 | ||
| target: aarch64-apple-darwin | ||
| rust: 1.85.0 | ||
| zig: false | ||
| runs-on: ${{ matrix.runner }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: dtolnay/rust-toolchain@master | ||
| with: | ||
| toolchain: ${{ matrix.rust }} | ||
| targets: ${{ matrix.target }} | ||
| - uses: mlugg/setup-zig@v2 | ||
| if: matrix.zig | ||
| - uses: taiki-e/install-action@v2 | ||
| if: matrix.zig | ||
| with: | ||
| tool: cargo-zigbuild | ||
| - uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| key: release-${{ matrix.rid }} | ||
| - name: Build native asset | ||
| shell: pwsh | ||
| run: | | ||
| $arguments = @{ | ||
| Rid = '${{ matrix.rid }}' | ||
| Toolchain = '${{ matrix.rust }}' | ||
| } | ||
| if ('${{ matrix.zig }}' -eq 'true') { | ||
| $arguments.UseZig = $true | ||
| } | ||
| ./build/Build-Native.ps1 @arguments | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ matrix.rid }} | ||
| path: artifacts/native/${{ matrix.rid }}/* | ||
| if-no-files-found: error | ||
|
|
||
| pack: | ||
| needs: [prepare, build-native] | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: 8.0.x | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| pattern: '*' | ||
| path: artifacts/native | ||
| - name: Pack complete NuGet | ||
| run: dotnet pack src/MiniExcelRust/MiniExcelRust.csproj -c Release -o artifacts/packages -p:PackageVersion=${{ needs.prepare.outputs.version }} | ||
| - name: Verify package contents | ||
| shell: pwsh | ||
| run: ./build/Verify-Package.ps1 -PackagePath 'artifacts/packages/MiniExcelRust.${{ needs.prepare.outputs.version }}.nupkg' | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: nuget-package | ||
| path: artifacts/packages/MiniExcelRust.${{ needs.prepare.outputs.version }}.*nupkg | ||
| if-no-files-found: error | ||
|
|
||
| test-package: | ||
| needs: [prepare, pack] | ||
| name: Consume ${{ matrix.rid }} package | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - runner: windows-latest | ||
| rid: win-x64 | ||
| musl: false | ||
| - runner: windows-11-arm | ||
| rid: win-arm64 | ||
| musl: false | ||
| - runner: ubuntu-latest | ||
| rid: linux-x64 | ||
| musl: false | ||
| - runner: ubuntu-24.04-arm | ||
| rid: linux-arm64 | ||
| musl: false | ||
| - runner: ubuntu-latest | ||
| rid: linux-musl-x64 | ||
| musl: true | ||
| - runner: ubuntu-24.04-arm | ||
| rid: linux-musl-arm64 | ||
| musl: true | ||
| - runner: macos-15-intel | ||
| rid: osx-x64 | ||
| musl: false | ||
| - runner: macos-latest | ||
| rid: osx-arm64 | ||
| musl: false | ||
| runs-on: ${{ matrix.runner }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: 8.0.x | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| name: nuget-package | ||
| path: artifacts/packages | ||
| - name: Consume package | ||
| if: ${{ !matrix.musl }} | ||
| shell: pwsh | ||
| run: | | ||
| dotnet restore tests/MiniExcelRust.PackageTests/MiniExcelRust.PackageTests.csproj --source artifacts/packages -p:MiniExcelRustPackageVersion=${{ needs.prepare.outputs.version }} | ||
| dotnet run --project tests/MiniExcelRust.PackageTests/MiniExcelRust.PackageTests.csproj -c Release --no-restore -p:MiniExcelRustPackageVersion=${{ needs.prepare.outputs.version }} | ||
| - name: Consume package in Alpine | ||
| if: matrix.musl | ||
| shell: bash | ||
| run: | | ||
| docker run --rm \ | ||
| -v "$GITHUB_WORKSPACE:/work" \ | ||
| -w /work \ | ||
| mcr.microsoft.com/dotnet/sdk:8.0-alpine \ | ||
| sh -lc 'dotnet restore tests/MiniExcelRust.PackageTests/MiniExcelRust.PackageTests.csproj --source artifacts/packages -p:MiniExcelRustPackageVersion=${{ needs.prepare.outputs.version }} && dotnet run --project tests/MiniExcelRust.PackageTests/MiniExcelRust.PackageTests.csproj -c Release --no-restore -p:MiniExcelRustPackageVersion=${{ needs.prepare.outputs.version }}' | ||
|
|
||
| publish: | ||
| needs: [prepare, test-package] | ||
| if: github.event_name == 'push' || inputs.publish == true | ||
| runs-on: ubuntu-latest | ||
| environment: release | ||
| permissions: | ||
| contents: write | ||
| id-token: write | ||
| steps: | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| name: nuget-package | ||
| path: artifacts/packages | ||
| - name: NuGet login | ||
| id: nuget-login | ||
| uses: NuGet/login@v1 | ||
| with: | ||
| user: minisoftware | ||
| - name: Publish NuGet package | ||
| run: dotnet nuget push artifacts/packages/MiniExcelRust.${{ needs.prepare.outputs.version }}.nupkg --api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate | ||
| - name: Create GitHub release | ||
| if: github.event_name == 'push' | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: gh release create '${{ github.ref_name }}' artifacts/packages/* --verify-tag --generate-notes --title 'MiniExcelRust ${{ needs.prepare.outputs.version }}' | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: mini-software/MiniExcelRust
Length of output: 3567
Pin the two release-path actions to audited full commit SHAs.
dtolnay/rust-toolchain@mastercan alter the native assets consumed by publishing.NuGet/login@v1runs in the publish job withid-token: writeandcontents: write, so a changed reference can affect package publishing..github/workflows/release.yml:92: pindtolnay/rust-toolchain@master..github/workflows/release.yml:217: pinNuGet/login@v1.📍 Affects 1 file
.github/workflows/release.yml#L217-L217(this comment).github/workflows/release.yml#L92-L92🤖 Prompt for AI Agents