Skip to content

Commit

Permalink
Build on github actions (#246)
Browse files Browse the repository at this point in the history
* adding format and removing build cmds
* Add info to produce a dotnet tool on dotnet pack (#245)
* fix badges on readme
* fix nuget pack warnings
* delete unnecessary tools
  • Loading branch information
Jérémie Bertrand authored and laedit committed Nov 1, 2020
1 parent df14f7f commit a871dfd
Show file tree
Hide file tree
Showing 22 changed files with 292 additions and 617 deletions.
202 changes: 202 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
name: Build

on:
push:
tags: v[1-9]+.[0-9]+.[0-9]+
branches: [ master ]
pull_request:

jobs:
build:
runs-on: windows-latest

env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true

steps:
- uses: actions/setup-java@v1
with:
java-version: '13' # The JDK version to make available on the path.
java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
architecture: x64 # (x64 or x86) - defaults to x64

- uses: actions/checkout@v2

- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow

- name: Cache nuget packages
uses: actions/cache@v2
with:
path: ~/.nuget/packages
key: nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
nuget-
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v1
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner

- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.4
with:
versionSpec: '5.3.x'

- name: Check GitVersion
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/execute@v0.9.4

- name: Echo version
run: echo ${{ steps.gitversion.outputs.nuGetVersionV2 }}

- name: Test
run: dotnet test src --configuration Release --nologo --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover

- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"laedit_vika" /o:"laedit-github" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths=src/NVika.Tests/coverage.opencover.xml /d:sonar.coverage.exclusions="src/NVika.Tests/*"
dotnet build src --configuration Release --no-restore /p:Version=${{ steps.gitversion.outputs.nuGetVersionV2 }}
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
- name: InspectCodeAnalysis
run: |
nuget install JetBrains.ReSharper.CommandLineTools -ExcludeVersion -OutputDirectory tools
./tools/JetBrains.ReSharper.CommandLineTools/tools/inspectcode -o="inspectcodereport.xml" --project="NVika" "src\Vika.sln" --toolset=14.0
- name: GendarmeAnalysis
run: |
nuget install mono.gendarme -ExcludeVersion -OutputDirectory tools
./tools/Mono.Gendarme/tools/gendarme.exe --xml GendarmeReport.xml --ignore gendarme.ignore .\src\NVika\bin\Release\netcoreapp3.1\NVika.exe
- name: LaunchNVika
run: .\src\NVika\bin\Release\netcoreapp3.1\NVika.exe --debug --includesource inspectcodereport.xml ./src/NVika/bin/Release/netcoreapp3.1/static-analysis.sarif.json GendarmeReport.xml

# - name: Create release notes
# run: |
# dotnet SemanticReleaseNotesParser -g=categories --debug -o="artifacts/ReleaseNotes.html" --pluralizecategoriestitle --includestyle
# dotnet SemanticReleaseNotesParser -g=categories --debug -t=environment -f=markdown --pluralizecategoriestitle

- name: Create MSBuild package
run: |
Copy-Item -Path resources/icon.png -Destination src\NVika.MSBuild\
mkdir src\NVika.MSBuild\tools\
Copy-Item -Path "src/NVika/bin/Release/netcoreapp3.1/publish/*" -Destination src\NVika.MSBuild\tools\
nuget pack src/NVika.MSBuild/NVika.MSBuild.nuspec -Version ${{ steps.gitversion.outputs.nuGetVersionV2 }} -OutputDirectory artifacts/nuget
- name: Create netcore packages
run: |
mkdir ./artifacts/zips
Compress-Archive -Path src/NVika/bin/Release/netcoreapp3.1/publish/* -DestinationPath "artifacts/zips/NVika.netcore.${{ steps.gitversion.outputs.nuGetVersionV2 }}.zip"
Copy-Item -Path "src/NVika/bin/Release/NVika.${{ steps.gitversion.outputs.nuGetVersionV2 }}.nupkg" -Destination artifacts/nuget
- name: Create windows version
run: |
dotnet publish src/NVika --configuration Release --output ./publish --self-contained true --runtime win-x86 -p:PublishSingleFile=true -p:PublishTrimmed=true /p:PackAsTool=false /p:Version=${{ steps.gitversion.outputs.nuGetVersionV2 }}
# Copy-Item -Path "artifacts/ReleaseNotes.html" -Destination publish
Compress-Archive -Path publish/* -DestinationPath "artifacts/zips/NVika.win-x86.$env:GitVersion_NuGetVersionV2.zip"
- name: Create chocolatey version
run: |
mkdir ./artifacts/chocolatey
$installPath = "chocolatey/tools/chocolateyInstall.ps1"
$originalContent = Get-Content $installPath
$originalContent.replace('[version]', "${{ steps.gitversion.outputs.nuGetVersionV2 }}") | Set-Content $installPath
choco pack chocolatey/nvika.nuspec --version ${{ steps.gitversion.outputs.nuGetVersionV2 }} --outdir artifacts/chocolatey
Set-Content $installPath $originalContent
- uses: actions/upload-artifact@v2
with:
path: artifacts/*

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

env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true

steps:
- uses: actions/download-artifact@v2

- name: Display structure of downloaded files
run: ls -R

- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v}

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: ${{ env.SemanticReleaseNotes }}
draft: false
prerelease: false

- name: Upload Zip netcore
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/zips/NVika.netcore.${{ steps.get_version.outputs.version }}.zip
asset_name: NVika.netcore.${{ steps.get_version.outputs.version }}.zip
asset_content_type: application/zip

- name: Upload Zip win-x86
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/zips/NVika.win-x86.${{ steps.get_version.outputs.version }}.zip
asset_name: NVika.win-x86.${{ steps.get_version.outputs.version }}.zip
asset_content_type: application/zip

- name: Chocolatey push
run: choco push artifacts/chocolatey/nvika.${{ steps.get_version.outputs.version }}.nupkg --source=https://push.chocolatey.org/ --api-key=${CHOCO_API_KEY}
env:
CHOCO_API_KEY: ${{ secrets.CHOCO_API_KEY }}

- name: Nuget push Tool
run: dotnet nuget push artifacts/nuget/NVika.${{ steps.get_version.outputs.version }}.nupkg -s https://api.nuget.org/v3/index.json -k ${NUGET_API_KEY}
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}

- name: Nuget push MSBuild
run: dotnet nuget push artifacts/nuget/NVika.MSBuild.${{ steps.get_version.outputs.version }}.nupkg -s https://api.nuget.org/v3/index.json -k ${NUGET_API_KEY}
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
18 changes: 18 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Check format

on: [pull_request]

jobs:
format:
runs-on: ubuntu-latest
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
steps:
- uses: actions/checkout@v2

- uses: xt0rted/dotnet-format-problem-matcher@v1.2.0

- run: dotnet tool install -g dotnet-format

- run: dotnet-format --check src
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,7 @@ src/.vs/

# SonarQube cache
.sonarqube

# opencover
coverage.opencover.xml
GendarmeReport.xml
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ Visual Interpreter of Kooky Analysis.
Also means 'bug' in Finnish.

[![Licence Apache 2](https://img.shields.io/badge/licence-Apache%202-blue.svg)](https://github.com/laedit/vika/blob/master/LICENSE)
[![AppVeyor build status](https://img.shields.io/appveyor/ci/laedit/vika.svg?label=build+windows)](https://ci.appveyor.com/project/laedit/vika)
[![Travis CI build Status](https://img.shields.io/travis/laedit/vika.svg?label=build+linux)](https://travis-ci.org/laedit/vika)
[![Coverage Status](https://coveralls.io/repos/laedit/vika/badge.svg)](https://coveralls.io/r/laedit/vika)
[![Chocolatey](https://img.shields.io/chocolatey/v/nvika.svg)](https://chocolatey.org/packages/nvika)
[![Nuget](https://img.shields.io/nuget/v/nvika.msbuild.svg)](https://www.nuget.org/packages/nvika.msbuild)
[![Join the chat at https://gitter.im/laedit/vika](https://badges.gitter.im/laedit/vika.svg)](https://gitter.im/laedit/vika?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
![Build](https://github.com/laedit/vika/workflows/Build/badge.svg)
[![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=laedit_vika&metric=alert_status)](https://sonarcloud.io/dashboard?id=laedit_vika)
[![SonarCloud Coverage](https://sonarcloud.io/api/project_badges/measure?project=laedit_vika&metric=coverage)](https://sonarcloud.io/component_measures/metric/coverage/list?id=laedit_vika)
[![SonarCloud Bugs](https://sonarcloud.io/api/project_badges/measure?project=laedit_vika&metric=bugs)](https://sonarcloud.io/component_measures/metric/reliability_rating/list?id=laedit_vika)
[![SonarCloud Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=laedit_vika&metric=vulnerabilities)](https://sonarcloud.io/component_measures/metric/security_rating/list?id=laedit_vika)

## What it is
Right now it's just a tiny tool which parse analysis reports and send messages to the build server, or in console if it's not executed on a build server.
Expand Down
6 changes: 0 additions & 6 deletions build.bat

This file was deleted.

4 changes: 0 additions & 4 deletions build.sh

This file was deleted.

125 changes: 0 additions & 125 deletions build/NVikaHelper.fsx

This file was deleted.

Loading

0 comments on commit a871dfd

Please sign in to comment.