Skip to content

Commit eca79f2

Browse files
authored
Github actions (#6)
* Add gh-actions stubs * Update CI * Update solution * Add benchmark stub (fixes build) * Update CI * Update release * Fix using the wrong context for run_id https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
1 parent ea5021d commit eca79f2

File tree

4 files changed

+76
-0
lines changed

4 files changed

+76
-0
lines changed

.github/workflows/ci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: CI build-test-pack
2+
on: [push]
3+
jobs:
4+
build:
5+
name: Build and test (${{ matrix.os }})
6+
strategy:
7+
matrix:
8+
os: [ubuntu-latest,windows-latest,macos-latest]
9+
runs-on: ${{ matrix.os }}
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Setup .NET SDK - 6.0.x
13+
uses: actions/setup-dotnet@v1
14+
with:
15+
dotnet-version: '6.0.x'
16+
- name: Setup .NET SDK - 5.0.x
17+
uses: actions/setup-dotnet@v1
18+
with:
19+
dotnet-version: '5.0.x'
20+
- name: Setup .NET SDK - 3.1.x
21+
uses: actions/setup-dotnet@v1
22+
with:
23+
dotnet-version: '3.1.x'
24+
- name: Install dependencies
25+
run: dotnet restore
26+
- name: Build
27+
run: dotnet build --no-restore --configuration Release
28+
- name: Test
29+
run: dotnet test --no-restore --no-build --configuration Release --logger trx --results-directory "TestResults"
30+
- name: Upload test results
31+
uses: actions/upload-artifact@v2
32+
with:
33+
name: TestResults
34+
path: TestResults
35+
# Use always() to always run this step to publish test results when there are test failures
36+
if: ${{ always() }}
37+
- name: Pack
38+
run: dotnet pack --no-restore --no-build --configuration Release --version-suffix CI-${{ github.run_id }} --output pkg
39+
- name: Upload package
40+
uses: actions/upload-artifact@v2
41+
with:
42+
name: LibDeflate-${{ matrix.os }}
43+
path: pkg/*

.github/workflows/release.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Upload packages to feeds
2+
on:
3+
release:
4+
types: [created]
5+
workflow_dispatch:
6+
jobs:
7+
deploy:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: actions/setup-dotnet@v1
12+
with:
13+
dotnet-version: '6.0.x' # SDK Version to use.
14+
- name: Pack
15+
run: dotnet pack -c Release -o pkg
16+
- name: Publish the package to GPR
17+
run: dotnet nuget push pkg/*.nupkg -k ${{ secrets.GITHUB_TOKEN }} -s https://nuget.pkg.github.com/jzebedee/index.json --skip-duplicate
18+
- name: Publish the package to NuGet
19+
run: dotnet nuget push pkg/*.nupkg -k ${{ secrets.LIBDEFLATE_NUGET_TOKEN }} -s https://api.nuget.org/v3/index.json --skip-duplicate

LibDeflate.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1616
.editorconfig = .editorconfig
1717
EndProjectSection
1818
EndProject
19+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{A36D1CD3-44C1-4790-9AE6-708D6253394B}"
20+
ProjectSection(SolutionItems) = preProject
21+
.github\workflows\ci.yml = .github\workflows\ci.yml
22+
.github\workflows\release.yml = .github\workflows\release.yml
23+
EndProjectSection
24+
EndProject
1925
Global
2026
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2127
Debug|Any CPU = Debug|Any CPU
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using BenchmarkDotNet.Running;
2+
3+
namespace LibDeflate.Benchmarks;
4+
5+
public class Program
6+
{
7+
public static void Main(string[] args) => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
8+
}

0 commit comments

Comments
 (0)