File tree Expand file tree Collapse file tree 3 files changed +83
-1
lines changed
Expand file tree Collapse file tree 3 files changed +83
-1
lines changed Original file line number Diff line number Diff line change 1+ # https://docs.github.com/en/actions/tutorials/create-actions/create-a-composite-action
2+ name : Build .NET package
3+ description : Build a .NET package to be published to nuget.org
4+
5+ inputs :
6+ project :
7+ description : The project's name (also the folder name)
8+ required : true
9+
10+ runs :
11+ using : " composite"
12+ steps :
13+ - name : Restore dependencies
14+ shell : bash
15+ run : dotnet restore ${{ inputs.project }}/${{ inputs.project }}.csproj --no-dependencies
16+
17+ - name : Build ${{ inputs.project }}
18+ shell : bash
19+ run : dotnet build ${{ inputs.project }}/${{ inputs.project }}.csproj -c Release --no-restore
20+
21+ - name : Pack ${{ inputs.project }} to local feed
22+ shell : bash
23+ run : dotnet pack ${{ inputs.project }}/${{ inputs.project }}.csproj -c Release -o ~/localfeed
24+
25+ - name : Check package version conflict
26+ shell : bash
27+ run : |
28+ PKG=${{ inputs.project }}
29+ # Get all package search results (local + NuGet)
30+ SEARCH_RESULTS=$(dotnet package search $PKG --exact-match --verbosity minimal | grep -E "^\|\s*$PKG\s*\|")
31+ # Extract all versions into an array
32+ VERSIONS=($(echo "$SEARCH_RESULTS" | awk -F'|' '{gsub(/ /,"",$3); print $3}'))
33+ LOCAL_VERSION="${VERSIONS[0]}"
34+ # Check if LOCAL_VERSION appears in any of the following versions
35+ for ((i=1; i<${#VERSIONS[@]}; i++)); do
36+ if [[ "${VERSIONS[$i]}" == "$LOCAL_VERSION" ]]; then
37+ echo "Package $PKG version $LOCAL_VERSION already exists on nuget.org. Please increment the version."
38+ exit 1
39+ fi
40+ done
41+ echo "No version conflict for $PKG version $LOCAL_VERSION."
Original file line number Diff line number Diff line change 1+ name : .NET build
2+
3+ on :
4+ push :
5+ branches : [ "main", "develop" ]
6+ pull_request :
7+ branches : [ "main", "develop" ]
8+
9+ jobs :
10+ build :
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - name : Checkout
15+ uses : actions/checkout@v4
16+
17+ - name : Setup .NET
18+ uses : actions/setup-dotnet@v4
19+ with :
20+ dotnet-version : 8.0.x
21+
22+ - name : Add local NuGet feed
23+ run : |
24+ mkdir -p ~/localfeed
25+ dotnet nuget add source ~/localfeed --name LocalFeed
26+
27+ - name : Build DeviceProgramming
28+ uses : ./.github/template/build-package
29+ with :
30+ project : DeviceProgramming
31+
32+ - name : Build LibUsbDfu
33+ uses : ./.github/template/build-package
34+ with :
35+ project : LibUsbDfu
36+
37+ - name : Restore dependencies
38+ run : dotnet restore
39+
40+ - name : Build LibUsbDfu.Cli
41+ run : dotnet build LibUsbDfu.Cli/LibUsbDfu.Cli.csproj -c Release --no-restore
Original file line number Diff line number Diff line change 1919 </ItemGroup >
2020
2121 <ItemGroup >
22- <ProjectReference Include =" ..\ LibUsbDfu\LibUsbDfu.csproj " />
22+ <PackageReference Include =" LibUsbDfu" Version = " 1.1.1 " />
2323 <PackageReference Include =" Mono.Options" Version =" 6.6.0.161" />
2424 </ItemGroup >
2525
You can’t perform that action at this time.
0 commit comments