Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add release workflow #58

Merged
merged 13 commits into from
Oct 3, 2020
133 changes: 116 additions & 17 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,131 @@ name: dotnet

on:
push:
branches: [ master ]
branches: [master]
tags: ["*"]
pull_request:
branches: [ master ]
branches: [master]

jobs:
build:
runs-on: ubuntu-latest

outputs:
fullSemVer: ${{ steps.gitversion.outputs.fullSemVer }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: gittools/actions/gitversion/setup@v0.9.4
with:
versionSpec: "5.x"

- id: gitversion
uses: gittools/actions/gitversion/execute@v0.9.4

- uses: actions/setup-dotnet@v1
with:
dotnet-version: 2.1.401

- uses: actions/cache@v2
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: ${{ runner.os }}-nuget-

- run: dotnet restore

- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 2.1.401
- run: dotnet build --configuration Release --no-restore

- name: Install dependencies
run: dotnet restore
- run: |
dotnet test \
--configuration Release \
--no-build \
--no-restore \
-p:CollectCoverage=true \
-p:CoverletOutputFormat=opencover \
-p:Exclude="[JsonLD.Test*]*"

- name: Build
run: dotnet build --configuration Release --no-restore
- name: Codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: bash <(curl -s https://codecov.io/bash)

- run: |
dotnet pack \
--include-source \
--configuration Release \
--no-build \
--no-restore \
-p:PackageVersion="${{ steps.gitversion.outputs.fullSemVer }}" \
src/json-ld.net/json-ld.net.csproj \
--output ${{ github.workspace }}/nugets/

- uses: actions/upload-artifact@v2
with:
name: nugets
path: nugets

nuget-push-dev:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
needs: build

steps:
- name: download artifact
uses: actions/download-artifact@v2
with:
name: nugets

- name: Test
run: dotnet test -c Release /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[JsonLD.Test*]*"
- name: setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1
source-url: https://nuget.pkg.github.com/linked-data-dotnet/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: nuget push
run: dotnet nuget push "*.nupkg" --skip-duplicate --api-key ${{ secrets.GITHUB_TOKEN }}

nuget-push-prod:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: build

steps:
- uses: actions/download-artifact@v2
with:
name: nugets

- uses: actions/setup-dotnet@v1
with:
dotnet-version: 2.1.401
source-url: https://api.nuget.org/v3/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_API_KEY }}

- run: dotnet nuget push nugets/*.nupkg --skip-duplicate

release-artifacts:
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/')

steps:
- uses: actions/download-artifact@v1
with:
name: nugets

- name: Codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: bash <(curl -s https://codecov.io/bash)
- name: Upload to stable release
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: nugets
asset_name: json-ld.net
tag: ${{ github.ref }}
overwrite: true
3 changes: 2 additions & 1 deletion src/json-ld.net/json-ld.net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Implements the W3C JSON-LD 1.0 standard.</Description>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<RepositoryUrl>https://github.com/linked-data-dotnet/json-ld.net</RepositoryUrl>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
Expand All @@ -36,4 +37,4 @@ Implements the W3C JSON-LD 1.0 standard.</Description>
<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.3.1" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>
</Project>
</Project>