Skip to content

Bump actions/setup-java from 3 to 4 #243

Bump actions/setup-java from 3 to 4

Bump actions/setup-java from 3 to 4 #243

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}}
windows_runfileoptimizertests_coverage_sonarqube:
needs: generate_version_number
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core @ Latest
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- uses: actions/setup-java@v4
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: Run download-fileoptimizer2.ps1 script
run: .\Scripts\download-fileoptimizer2.ps1
shell: powershell
- name: dotnet restore
run: dotnet restore DeveImageOptimizer.sln
- name: SonarQube begin
if: github.actor != 'dependabot[bot]'
run: dotnet-sonarscanner begin /k:"DeveImageOptimizer" /o:"devedse-github" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.login=${{secrets.SONARQUBETOKEN}} /d:sonar.cs.opencover.reportsPaths=".\DeveImageOptimizer.Tests\TestResults\Coverage\coverage.opencover.xml" /d:sonar.coverage.exclusions="DeveImageOptimizer.ConsoleApp/**/*.cs,DeveImageOptimizer.Tests/**/*.cs"
- name: dotnet build
run: dotnet build DeveImageOptimizer.sln -c Release --no-restore /p:Version=1.0.${{needs.generate_version_number.outputs.build_number}}
- name: dotnet test and coverage
run: dotnet test DeveImageOptimizer.sln -c Release --filter "CallsFileOptimizer!=True&FailingTest!=True" --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=\`"cobertura,opencover\`" /p:CoverletOutput=./TestResults/Coverage/
- name: SonarQube end
if: github.actor != 'dependabot[bot]'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: dotnet-sonarscanner end /d:sonar.login=${{secrets.SONARQUBETOKEN}}
- 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: .\DeveImageOptimizer.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)
intellicode:
needs: generate_version_number
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
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 DeveImageOptimizer.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_linux:
needs: generate_version_number
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: dotnet restore
run: dotnet restore DeveImageOptimizer.sln
- name: dotnet build
run: dotnet build DeveImageOptimizer.sln -c Release --no-restore /p:Version=1.0.${{needs.generate_version_number.outputs.build_number}}
- name: dotnet test
run: dotnet test DeveImageOptimizer.sln -c Release --no-build --verbosity normal
build_windows:
needs: generate_version_number
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core @ Latest
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: dotnet restore
run: dotnet restore DeveImageOptimizer.sln
- name: dotnet build
run: dotnet build DeveImageOptimizer.sln -c Release --no-restore /p:Version=1.0.${{needs.generate_version_number.outputs.build_number}}
- name: dotnet test
run: dotnet test DeveImageOptimizer.sln -c Release --no-build --verbosity normal
- 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 GoPackage.ps1 script
run: .\Scripts\GoPackage.ps1
shell: powershell
- uses: actions/upload-artifact@v3
with:
name: DeveImageOptimizer7z
path: ./Scripts/Output/DeveImageOptimizer.7z
- uses: actions/upload-artifact@v3
with:
name: DeveImageOptimizerZip
path: ./Scripts/Output/DeveImageOptimizer.zip
- uses: actions/upload-artifact@v3
with:
name: DeveImageOptimizerNuGet
path: |
./DeveImageOptimizer/bin/Release/*.nupkg
./DeveImageOptimizer/bin/Release/*.snupkg
release_github:
needs: [generate_version_number, intellicode, build_windows, build_linux]
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/DeveImageOptimizer7z/DeveImageOptimizer.7z
./artifacts/DeveImageOptimizerZip/DeveImageOptimizer.zip
./artifacts/DeveImageOptimizerNuGet/*.nupkg
./artifacts/DeveImageOptimizerNuGet/*.snupkg
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release_nuget:
needs: [generate_version_number, intellicode, build_windows, build_linux, release_github]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
name: DeveImageOptimizerNuGet
path: ./artifacts/DeveImageOptimizerNuGet/
- name: Push NuGet
run: dotnet nuget push ./artifacts/DeveImageOptimizerNuGet/DeveImageOptimizer.1.0.${{needs.generate_version_number.outputs.build_number}}.nupkg -k ${{ secrets.NUGETTOKEN }} -s https://api.nuget.org/v3/index.json
codeqlanalyze:
runs-on: windows-latest
needs: generate_version_number
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'csharp', 'javascript' ]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: Run tree
run: tree /A
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
output: './artifacts'
- name: Run tree2
run: |
tree /A
cd
- uses: actions/upload-artifact@v3
with:
name: CodeQLAnalysis_${{ matrix.language }}
path: ./artifacts/${{ matrix.language }}.zip