Skip to content

testje

testje #101

name: GitHubActionsBuilds
on: push
jobs:
generate_version_number:
runs-on: ubuntu-latest
outputs:
build_number: ${{ github.ref == 'refs/heads/master' && steps.buildnumber.outputs.build_number || 1 }}
steps:
- name: Generate build number
if: github.ref == 'refs/heads/master'
id: buildnumber
uses: einaregilsson/build-number@v3
with:
token: ${{secrets.github_token}}
intellicode:
needs: generate_version_number
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # We need to fetch the entire Git history in order to verify the authenticity.
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: Build with dotnet
run: dotnet build DeveImageOptimizerWPF.sln -c Release /p:Version=1.0.${{needs.generate_version_number.outputs.build_number}} # Project needs to build before training a model.
- name: Train Intellicode Model
uses: microsoft/vs-intellicode@v1
build_windows:
needs: generate_version_number
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core @ Latest
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '19' # 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
- name: Install tools
run: |
dotnet tool install --global dotnet-sonarscanner
dotnet tool install --global dotnet-reportgenerator-globaltool
- name: Install dependencies
run: dotnet restore DeveImageOptimizerWPF.sln
- name: SonarQube begin
if: github.actor != 'dependabot[bot]'
run: dotnet-sonarscanner begin /k:"DeveImageOptimizerWPF" /o:"devedse-github" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.login=${{secrets.SONARQUBETOKEN}} /d:sonar.cs.opencover.reportsPaths=".\DeveImageOptimizerWPF.Tests\TestResults\Coverage\coverage.opencover.xml" /d:sonar.coverage.exclusions="DeveImageOptimizerWPF.Tests/**/*.cs"
- name: Build
run: dotnet build DeveImageOptimizerWPF.sln -c Release --no-restore /p:Version=1.0.${{needs.generate_version_number.outputs.build_number}}
- name: Test
run: dotnet test DeveImageOptimizerWPF.sln --verbosity normal --no-build -c Release /p:CollectCoverage=true /p:CoverletOutputFormat=\`"cobertura,opencover\`" /p:CoverletOutput=./TestResults/Coverage/
- name: SonarQube end
if: github.actor != 'dependabot[bot]'
run: dotnet-sonarscanner end /d:sonar.login=${{secrets.SONARQUBETOKEN}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish
run: dotnet publish .\DeveImageOptimizerWPF\DeveImageOptimizerWPF.csproj -r win-x64 -c Release /p:PublishSingleFile=true /p:SelfContained=true /p:IncludeNativeLibrariesForSelfExtract=true /p:PublishTrimmed=true /p:TrimMode=partial /p:Version=1.0.${{needs.generate_version_number.outputs.build_number}}
- name: Publish (Without Trim)
run: dotnet publish .\DeveImageOptimizerWPF\DeveImageOptimizerWPF.csproj -r win-x64 -c Release -o "DeveImageOptimizerWPF\bin\Release\net7.0-windows\win-x64\publishuntrimmed\" /p:PublishSingleFile=true /p:SelfContained=true /p:IncludeNativeLibrariesForSelfExtract=true /p:Version=1.0.${{needs.generate_version_number.outputs.build_number}}
- name: Publish
run: dotnet publish .\DeveImageOptimizerWPF\DeveImageOptimizerWPF.csproj -r win-x64 -c Release -o "DeveImageOptimizerWPF\bin\Release\net7.0-windows\win-x64\publishtrimmedlink\" /p:PublishSingleFile=true /p:SelfContained=true /p:IncludeNativeLibrariesForSelfExtract=true /p:PublishTrimmed=true /p:TrimMode=Link /p:Version=1.0.${{needs.generate_version_number.outputs.build_number}}
- name: Publish
run: dotnet publish .\DeveImageOptimizerWPF\DeveImageOptimizerWPF.csproj -r win-x64 -c Release -o "DeveImageOptimizerWPF\bin\Release\net7.0-windows\win-x64\publishtrimmedcopyused\" /p:PublishSingleFile=true /p:SelfContained=true /p:IncludeNativeLibrariesForSelfExtract=true /p:PublishTrimmed=true /p:TrimMode=CopyUsed /p:Version=1.0.${{needs.generate_version_number.outputs.build_number}}
# - name: Pack
# run: dotnet pack DeveImageOptimizer\DeveImageOptimizer.csproj --verbosity normal --no-build -c Release /p:Version=1.0.${{needs.generate_version_number.outputs.build_number}}
- name: Run CodeCov #codecov -f ".\DeveImageOptimizer.Tests\TestResults\Coverage\coverage.opencover.xml"
uses: codecov/codecov-action@v3
with:
#token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
files: .\DeveImageOptimizerWPF.Tests\TestResults\Coverage\coverage.opencover.xml # optional
#flags: unittests # optional
#name: codecov-umbrella # optional
#fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)
- uses: actions/upload-artifact@v3
with:
name: DeveImageOptimizerWPF_win-x64
path: DeveImageOptimizerWPF\bin\Release\net7.0-windows\win-x64\publish\DeveImageOptimizerWPF.exe
- uses: actions/upload-artifact@v3
with:
name: DeveImageOptimizerWPF_win-x64_untrimmed
path: DeveImageOptimizerWPF\bin\Release\net7.0-windows\win-x64\publishuntrimmed\DeveImageOptimizerWPF.exe
- uses: actions/upload-artifact@v3
with:
name: DeveImageOptimizerWPF_win-x64_trimlink
path: DeveImageOptimizerWPF\bin\Release\net7.0-windows\win-x64\publishtrimmedlink\DeveImageOptimizerWPF.exe
- uses: actions/upload-artifact@v3
with:
name: DeveImageOptimizerWPF_win-x64_trimcopyused
path: DeveImageOptimizerWPF\bin\Release\net7.0-windows\win-x64\publishtrimmedcopyused\DeveImageOptimizerWPF.exe
release_github:
needs: [generate_version_number, intellicode, build_windows]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: ./artifacts/
- name: Display structure of downloaded files
run: |
cd ./artifacts/
ls -R
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: 1.0.${{needs.generate_version_number.outputs.build_number}}
release_name: 1.0.${{needs.generate_version_number.outputs.build_number}}
body: |
${{ github.event.head_commit.message }}
draft: false
prerelease: false
- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: 1.0.${{needs.generate_version_number.outputs.build_number}}
files: |
./artifacts/DeveImageOptimizerWPF_win-x64/DeveImageOptimizerWPF.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release_chocolatey:
needs: [intellicode, build_windows, release_github]
runs-on: windows-latest
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: ./artifacts/
- name: Run CreatePackage.ps1 script
run: .\CreateChocoPackage\CreatePackage.ps1
shell: powershell
- name: Run PushPackage.ps1 script
run: .\CreateChocoPackage\PushPackage.ps1 -chocolateykey ${{secrets.CHOCOLATEYTOKEN}}
shell: powershell