From cb30557b88776a7ad4707ecba839772fb6eda710 Mon Sep 17 00:00:00 2001 From: bparks13 Date: Thu, 8 Aug 2024 19:00:14 -0400 Subject: [PATCH 1/3] Add Github Actions --- .github/workflows/build.yml | 115 ++++++++++++++++++ Directory.Build.props | 2 + .../OpenEphys.ProbeInterface.NET.csproj | 1 - build/Version.props | 20 +++ 4 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build.yml create mode 100644 build/Version.props diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..ab68ee5 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,115 @@ +name: Build + +on: + push: + branches: [main] + pull_request: + branches: [main] + release: + types: [published] + +env: + DOTNET_NOLOGO: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + DOTNET_GENERATE_ASPNET_CERTIFICATE: false + ContinuousIntegrationBuild: true + CiRunNumber: ${{ github.run_number }} + CiRunPushSuffix: ${{ github.ref_name }}-ci${{ github.run_number }} + CiRunPullSuffix: pull-${{ github.event.number }}-ci${{ github.run_number }} + +jobs: + setup: + runs-on: ubuntu-latest + outputs: + build-suffix: ${{ steps.setup-build.outputs.build-suffix }} + steps: + - name: Setup Build + id: setup-build + run: echo "build-suffix=${{ github.event_name == 'push' && env.CiRunPushSuffix || github.event_name == 'pull_request' && env.CiRunPullSuffix || null }}" >> "$GITHUB_OUTPUT" + + build: + needs: setup + name: Build Package + strategy: + fail-fast: false + matrix: + configuration: [debug, release] + os: [ubuntu-latest, windows-latest] + include: + - os: windows-latest + configuration: release + collect-packages: true + runs-on: ${{ matrix.os }} + env: + CiBuildVersionSuffic: ${{ needs.setup.outputs.build-suffix }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.x + + - name: Restore NuGet Packages + run: dotnet restore + + - name: Build Project + run: dotnet build --no-restore --configuration ${{ matrix.configuration }} + + - name: Pack + id: pack + if: matrix.collect-packages + run: dotnet pack --no-build --configuration ${{ matrix.configuration }} + + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: Packages + if-no-files-found: error + path: artifacts/package/${{ matrix.configuration }}/** + + publish-github: + runs-on: ubuntu-latest + permissions: + packages: write + needs: [build] + if: github.event_name == 'push' || github.event_name == 'release' + + steps: + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.x + + - name: Download packages + uses: actions/download-artifact@v4 + with: + name: Packages + path: Packages + + - name: Push to GitHub Packages + run: dotnet nuget push "Packages/*.nupkg" --skip-duplicate --no-symbols --api-key ${{ secrets.GITHUB_TOKEN }} --source https://nuget.pkg.github.com/${{ github.repository_owner }} + env: + # This is a workaround for https://github.com/NuGet/Home/issues/9775 + DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER: 0 + + deploy: + name: Deploy Package + runs-on: windows-latest + needs: [build, publish-github] + if: github.event_name == 'release' + + steps: + - name: Download packages + uses: actions/download-artifact@v4 + with: + name: Packages + path: Packages + + - name: Setup .NET Core + uses: actions/setup-dotnet@v4 + + - name: Publish NuGet Package + run: dotnet nuget push *nupkg --skip-duplicate --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props index c139f4b..1c1e1d4 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -17,6 +17,8 @@ 10.0 strict + + diff --git a/OpenEphys.ProbeInterface.NET/OpenEphys.ProbeInterface.NET.csproj b/OpenEphys.ProbeInterface.NET/OpenEphys.ProbeInterface.NET.csproj index f747d3c..d677d3d 100644 --- a/OpenEphys.ProbeInterface.NET/OpenEphys.ProbeInterface.NET.csproj +++ b/OpenEphys.ProbeInterface.NET/OpenEphys.ProbeInterface.NET.csproj @@ -3,7 +3,6 @@ OpenEphys.ProbeInterface.NET API based on Probeinterface specifications for parsing channel configurations Bonsai Rx Open Ephys Onix - true net472 enable AnyCPU diff --git a/build/Version.props b/build/Version.props new file mode 100644 index 0000000..d7d1fa2 --- /dev/null +++ b/build/Version.props @@ -0,0 +1,20 @@ + + + + 0 + + dev$(DevVersion) + <_FileVersionRevision>$([MSBuild]::Add(60000, $(DevVersion))) + + + + $(CiBuildVersionSuffix) + <_FileVersionRevision>0 + <_FileVersionRevision Condition="'$(CiBuildVersionSuffix)' != '' and '$(CiRunNumber)' != ''">$(CiRunNumber) + + + + + $(WarningsAsErrors);CS7035 + + \ No newline at end of file From a6094e4a2c2ffe17c774fac44b5f63b192af0a2d Mon Sep 17 00:00:00 2001 From: bparks13 Date: Thu, 8 Aug 2024 19:06:56 -0400 Subject: [PATCH 2/3] Add correct logic for uploading artifacts --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ab68ee5..92cadc1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -65,6 +65,7 @@ jobs: - name: Upload Artifacts uses: actions/upload-artifact@v4 + if: matrix.collect-packages && steps.pack.outcome == 'success' && always() with: name: Packages if-no-files-found: error From bf95db61595327dc5842dbcac930e53cddba93fa Mon Sep 17 00:00:00 2001 From: bparks13 Date: Thu, 8 Aug 2024 19:20:52 -0400 Subject: [PATCH 3/3] Fix spelling in actions --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 92cadc1..559326e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,7 +41,7 @@ jobs: collect-packages: true runs-on: ${{ matrix.os }} env: - CiBuildVersionSuffic: ${{ needs.setup.outputs.build-suffix }} + CiBuildVersionSuffix: ${{ needs.setup.outputs.build-suffix }} steps: - name: Checkout