Skip to content

Commit df7771b

Browse files
authored
Add Github Actions (#6)
1 parent 87720f4 commit df7771b

File tree

4 files changed

+138
-1
lines changed

4 files changed

+138
-1
lines changed

.github/workflows/build.yml

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
release:
9+
types: [published]
10+
11+
env:
12+
DOTNET_NOLOGO: true
13+
DOTNET_CLI_TELEMETRY_OPTOUT: true
14+
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
15+
ContinuousIntegrationBuild: true
16+
CiRunNumber: ${{ github.run_number }}
17+
CiRunPushSuffix: ${{ github.ref_name }}-ci${{ github.run_number }}
18+
CiRunPullSuffix: pull-${{ github.event.number }}-ci${{ github.run_number }}
19+
20+
jobs:
21+
setup:
22+
runs-on: ubuntu-latest
23+
outputs:
24+
build-suffix: ${{ steps.setup-build.outputs.build-suffix }}
25+
steps:
26+
- name: Setup Build
27+
id: setup-build
28+
run: echo "build-suffix=${{ github.event_name == 'push' && env.CiRunPushSuffix || github.event_name == 'pull_request' && env.CiRunPullSuffix || null }}" >> "$GITHUB_OUTPUT"
29+
30+
build:
31+
needs: setup
32+
name: Build Package
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
configuration: [debug, release]
37+
os: [ubuntu-latest, windows-latest]
38+
include:
39+
- os: windows-latest
40+
configuration: release
41+
collect-packages: true
42+
runs-on: ${{ matrix.os }}
43+
env:
44+
CiBuildVersionSuffic: ${{ needs.setup.outputs.build-suffix }}
45+
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v4
49+
50+
- name: Setup .NET
51+
uses: actions/setup-dotnet@v4
52+
with:
53+
dotnet-version: 8.x
54+
55+
- name: Restore NuGet Packages
56+
run: dotnet restore
57+
58+
- name: Build Project
59+
run: dotnet build --no-restore --configuration ${{ matrix.configuration }}
60+
61+
- name: Pack
62+
id: pack
63+
if: matrix.collect-packages
64+
run: dotnet pack --no-build --configuration ${{ matrix.configuration }}
65+
66+
- name: Upload Artifacts
67+
uses: actions/upload-artifact@v4
68+
if: matrix.collect-packages && steps.pack.outcome == 'success' && always()
69+
with:
70+
name: Packages
71+
if-no-files-found: error
72+
path: artifacts/package/${{ matrix.configuration }}/**
73+
74+
publish-github:
75+
runs-on: ubuntu-latest
76+
permissions:
77+
packages: write
78+
needs: [build]
79+
if: github.event_name == 'push' || github.event_name == 'release'
80+
81+
steps:
82+
- name: Setup .NET
83+
uses: actions/setup-dotnet@v4
84+
with:
85+
dotnet-version: 8.x
86+
87+
- name: Download packages
88+
uses: actions/download-artifact@v4
89+
with:
90+
name: Packages
91+
path: Packages
92+
93+
- name: Push to GitHub Packages
94+
run: dotnet nuget push "Packages/*.nupkg" --skip-duplicate --no-symbols --api-key ${{ secrets.GITHUB_TOKEN }} --source https://nuget.pkg.github.com/${{ github.repository_owner }}
95+
env:
96+
# This is a workaround for https://github.com/NuGet/Home/issues/9775
97+
DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER: 0
98+
99+
deploy:
100+
name: Deploy Package
101+
runs-on: windows-latest
102+
needs: [build, publish-github]
103+
if: github.event_name == 'release'
104+
105+
steps:
106+
- name: Download packages
107+
uses: actions/download-artifact@v4
108+
with:
109+
name: Packages
110+
path: Packages
111+
112+
- name: Setup .NET Core
113+
uses: actions/setup-dotnet@v4
114+
115+
- name: Publish NuGet Package
116+
run: dotnet nuget push *nupkg --skip-duplicate --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json

Directory.Build.props

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
<LangVersion>10.0</LangVersion>
1818
<Features>strict</Features>
1919
</PropertyGroup>
20+
21+
<Import Project="build/Version.props" />
2022

2123
<ItemGroup>
2224
<Content Include="..\LICENSE" PackagePath="/" />

OpenEphys.ProbeInterface.NET/OpenEphys.ProbeInterface.NET.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<Title>OpenEphys.ProbeInterface.NET</Title>
44
<Description>API based on Probeinterface specifications for parsing channel configurations</Description>
55
<PackageTags>Bonsai Rx Open Ephys Onix</PackageTags>
6-
<GeneratePackageOnBuild Condition="'$(Configuration)'=='Release'">true</GeneratePackageOnBuild>
76
<TargetFramework>net472</TargetFramework>
87
<Nullable>enable</Nullable>
98
<Platforms>AnyCPU</Platforms>

build/Version.props

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project>
2+
<PropertyGroup Condition="'$(ContinuousIntegrationBuild)' != 'true'">
3+
<!-- When making local builds DevVersion can be overridden to generate multiple local versions -->
4+
<DevVersion Condition="'$(DevVersion)' == ''">0</DevVersion>
5+
6+
<VersionSuffix>dev$(DevVersion)</VersionSuffix>
7+
<_FileVersionRevision>$([MSBuild]::Add(60000, $(DevVersion)))</_FileVersionRevision>
8+
</PropertyGroup>
9+
10+
<PropertyGroup Condition="'$(ContinuousIntegrationBuild)' == 'true'">
11+
<VersionSuffix>$(CiBuildVersionSuffix)</VersionSuffix>
12+
<_FileVersionRevision>0</_FileVersionRevision>
13+
<_FileVersionRevision Condition="'$(CiBuildVersionSuffix)' != '' and '$(CiRunNumber)' != ''">$(CiRunNumber)</_FileVersionRevision>
14+
</PropertyGroup>
15+
16+
<PropertyGroup>
17+
<!-- Force malformed versions to be an error -->
18+
<WarningsAsErrors>$(WarningsAsErrors);CS7035</WarningsAsErrors>
19+
</PropertyGroup>
20+
</Project>

0 commit comments

Comments
 (0)