-
Notifications
You must be signed in to change notification settings - Fork 731
feat(bindings/dotnet):Bindings dotnet publish to nuget #7323
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| name: Release Dotnet Binding | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'dotnet-v[0-9]+.[0-9]+.[0-9]+*' | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - ".github/workflows/release_dotnet.yml" | ||
| - "bindings/dotnet/build.py" | ||
| - "bindings/dotnet/DotOpenDAL/DotOpenDAL.csproj" | ||
| workflow_dispatch: | ||
| inputs: | ||
| dotnet_publish: | ||
| description: "Publish DotOpenDAL to nuget.org" | ||
| required: true | ||
| type: boolean | ||
| default: false | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build-native: | ||
| name: Build Native - ${{ matrix.classifier }} | ||
| runs-on: ${{ matrix.os }} | ||
| defaults: | ||
| run: | ||
| working-directory: "bindings/dotnet" | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - os: ubuntu-latest | ||
| classifier: linux-x86_64 | ||
| artifact: libopendal_dotnet.so | ||
| - os: windows-latest | ||
| classifier: windows-x86_64 | ||
| artifact: opendal_dotnet.dll | ||
| - os: macos-latest | ||
| classifier: osx-aarch_64 | ||
| artifact: libopendal_dotnet.dylib | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Setup Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: "3.11" | ||
| - name: Setup Rust toolchain | ||
| uses: ./.github/actions/setup | ||
| with: | ||
| need-protoc: true | ||
| need-rocksdb: true | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Build native library | ||
| run: python build.py --classifier ${{ matrix.classifier }} | ||
|
|
||
| - name: Upload native artifact | ||
| uses: actions/upload-artifact@v6 | ||
| with: | ||
| name: native-${{ matrix.classifier }} | ||
| path: bindings/dotnet/target/native/${{ matrix.classifier }}/${{ matrix.artifact }} | ||
| if-no-files-found: error | ||
|
|
||
| package: | ||
| name: Pack NuGet package | ||
| runs-on: ubuntu-latest | ||
| needs: | ||
| - build-native | ||
| defaults: | ||
| run: | ||
| working-directory: "bindings/dotnet" | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Setup dotnet toolchain | ||
| uses: actions/setup-dotnet@v5 | ||
| with: | ||
| dotnet-version: "10.0.x" | ||
|
|
||
| - name: Download native artifacts | ||
| uses: actions/download-artifact@v7 | ||
| with: | ||
| pattern: native-* | ||
| merge-multiple: true | ||
| path: bindings/dotnet/target/release-assets | ||
|
|
||
| - name: Prepare runtime assets | ||
| shell: bash | ||
| run: | | ||
| mkdir -p DotOpenDAL/runtimes/win-x64/native | ||
| mkdir -p DotOpenDAL/runtimes/linux-x64/native | ||
| mkdir -p DotOpenDAL/runtimes/osx-arm64/native | ||
|
|
||
| cp target/release-assets/opendal_dotnet.dll DotOpenDAL/runtimes/win-x64/native/ | ||
| cp target/release-assets/libopendal_dotnet.so DotOpenDAL/runtimes/linux-x64/native/ | ||
| cp target/release-assets/libopendal_dotnet.dylib DotOpenDAL/runtimes/osx-arm64/native/ | ||
|
|
||
| - name: Pack DotOpenDAL | ||
| run: dotnet pack DotOpenDAL/DotOpenDAL.csproj -c Release -o artifacts/package | ||
|
|
||
| - name: Upload NuGet package | ||
| uses: actions/upload-artifact@v6 | ||
| with: | ||
| name: dotnet-package | ||
| path: bindings/dotnet/artifacts/package/*.nupkg | ||
| if-no-files-found: error | ||
|
|
||
| publish: | ||
| name: Publish | ||
| if: ${{ startsWith(github.ref, 'refs/tags/dotnet-v') || (github.event_name == 'workflow_dispatch' && inputs.dotnet_publish) }} | ||
| runs-on: ubuntu-latest | ||
| needs: | ||
| - package | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
| environment: production | ||
|
|
||
| steps: | ||
| - name: Setup dotnet toolchain | ||
| uses: actions/setup-dotnet@v5 | ||
| with: | ||
| dotnet-version: "10.0.x" | ||
|
|
||
| - name: Download NuGet package | ||
| uses: actions/download-artifact@v7 | ||
| with: | ||
| name: dotnet-package | ||
| path: bindings/dotnet/artifacts/package | ||
|
|
||
| - name: NuGet login | ||
| uses: NuGet/login@v1 | ||
| id: login | ||
| with: | ||
| user: Apache.OpenDAL | ||
|
|
||
| - name: Publish package | ||
| run: dotnet nuget push bindings/dotnet/artifacts/package/*.nupkg --api-key "${{ steps.login.outputs.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,8 +27,6 @@ | |
| def classifier_to_target(classifier: str) -> str: | ||
| if classifier == "osx-aarch_64": | ||
| return "aarch64-apple-darwin" | ||
| if classifier == "osx-x86_64": | ||
| return "x86_64-apple-darwin" | ||
|
Comment on lines
-30
to
-31
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Fatorin Is this something .NET cannot support, or we do not support it due to its outdated?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a limitation of .NET. |
||
| if classifier == "linux-x86_64": | ||
| return "x86_64-unknown-linux-gnu" | ||
| if classifier == "windows-x86_64": | ||
|
|
@@ -39,8 +37,6 @@ def classifier_to_target(classifier: str) -> str: | |
| def get_cargo_artifact_name(classifier: str) -> str: | ||
| if classifier == "osx-aarch_64": | ||
| return "libopendal_dotnet.dylib" | ||
| if classifier == "osx-x86_64": | ||
| return "libopendal_dotnet.dylib" | ||
| if classifier == "linux-x86_64": | ||
| return "libopendal_dotnet.so" | ||
| if classifier == "windows-x86_64": | ||
|
|
||
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.
Maybe change to
v[0-9]+.[0-9]+.[0-9]+orv[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+depending on how the .NET release workflow would actually trigger.I think we don't push tags like
dotnet-v[0-9]+.[0-9]+.[0-9]+*so far.But I'm OK to leave it as is for now since this workflow is untested anyway.