Skip to content

Commit

Permalink
Github actions (#6)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jzebedee committed Jan 19, 2022
1 parent ea5021d commit eca79f2
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI build-test-pack
on: [push]
jobs:
build:
name: Build and test (${{ matrix.os }})
strategy:
matrix:
os: [ubuntu-latest,windows-latest,macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Setup .NET SDK - 6.0.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Setup .NET SDK - 5.0.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.x'
- name: Setup .NET SDK - 3.1.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Test
run: dotnet test --no-restore --no-build --configuration Release --logger trx --results-directory "TestResults"
- name: Upload test results
uses: actions/upload-artifact@v2
with:
name: TestResults
path: TestResults
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
- name: Pack
run: dotnet pack --no-restore --no-build --configuration Release --version-suffix CI-${{ github.run_id }} --output pkg
- name: Upload package
uses: actions/upload-artifact@v2
with:
name: LibDeflate-${{ matrix.os }}
path: pkg/*
19 changes: 19 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Upload packages to feeds
on:
release:
types: [created]
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x' # SDK Version to use.
- name: Pack
run: dotnet pack -c Release -o pkg
- name: Publish the package to GPR
run: dotnet nuget push pkg/*.nupkg -k ${{ secrets.GITHUB_TOKEN }} -s https://nuget.pkg.github.com/jzebedee/index.json --skip-duplicate
- name: Publish the package to NuGet
run: dotnet nuget push pkg/*.nupkg -k ${{ secrets.LIBDEFLATE_NUGET_TOKEN }} -s https://api.nuget.org/v3/index.json --skip-duplicate
6 changes: 6 additions & 0 deletions LibDeflate.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{A36D1CD3-44C1-4790-9AE6-708D6253394B}"
ProjectSection(SolutionItems) = preProject
.github\workflows\ci.yml = .github\workflows\ci.yml
.github\workflows\release.yml = .github\workflows\release.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
8 changes: 8 additions & 0 deletions bench/LibDeflate.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using BenchmarkDotNet.Running;

namespace LibDeflate.Benchmarks;

public class Program
{
public static void Main(string[] args) => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
}

0 comments on commit eca79f2

Please sign in to comment.