Skip to content

Bump the all-dependencies group with 21 updates #1030

Bump the all-dependencies group with 21 updates

Bump the all-dependencies group with 21 updates #1030

name: Continuous Delivery
on:
push: {}
pull_request: {}
workflow_dispatch:
inputs:
force-release:
type: boolean
description: Force tag & release even when the source branch is not main or no production source files have changed
jobs:
check-release-requirement:
runs-on: ubuntu-latest
outputs:
needs-release: ${{ steps.release-check.outputs.needs-release }}
semantic-version: ${{ steps.get-semver.outputs.semantic-version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: GetSemVer
id: get-semver
run: |
$semver = build/api/get-semver.ps1 | Select-Object -Last 1
Write-Output "Semantic version: $semver"
Write-Output "semantic-version=$semver" >> $env:GITHUB_OUTPUT
shell: pwsh
- name: Check for Release Requirement
id: release-check
run: |
productionFilesChangedCount=$(git diff --name-only HEAD^ HEAD | grep -E 'src/' | wc -l)
echo "$productionFilesChangedCount production source code files have changed"
productionFilesChanged=$((productionFilesChangedCount > 0))
echo "Git ref: ${{ github.ref_name }}"
branchIsMain=$([[ "${{ github.ref_name }}" == "main" ]] && echo true || echo false)
forceReleaseRequested=$([[ "${{ github.event.inputs.force-release }}" == "true" ]] && echo true || echo false)
echo "Forced release requested: $forceReleaseRequested"
needsRelease=$([[ "$forceReleaseRequested" == "true" || ( "$productionFilesChanged" == "1" && "$branchIsMain" == "true" ) ]] && echo true || echo false)
echo "Release will be generated: $needsRelease"
echo "needs-release=$needsRelease" >> $GITHUB_OUTPUT
display-job-outputs:
needs: check-release-requirement
runs-on: ubuntu-latest
steps:
- name: Display Job Outputs
run: |
echo "needs-release = ${{ needs.check-release-requirement.outputs.needs-release }}"
echo "semantic-version = ${{ needs.check-release-requirement.outputs.semantic-version }}"
build-ubuntu:
permissions:
contents: read
actions: read
checks: write
runs-on: ubuntu-latest
needs: check-release-requirement
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x.x
- name: Restore dependencies
run: build/api/restore.ps1
shell: pwsh
- name: Build
run: build/api/build.ps1 -Version "${{ needs.check-release-requirement.outputs.semantic-version }}"
shell: pwsh
- name: Build Docker image
run: build/api/build-docker.ps1 -Version "${{ needs.check-release-requirement.outputs.semantic-version }}"
shell: pwsh
- name: Run tests
run: |
export breef_BreefApi__ApiKey="${{ secrets.BREEF_BREEFAPI__APIKEY }}"
export breef_Wallabag__BaseUrl="${{ secrets.BREEF_WALLABAG__BASEURL }}"
export breef_Wallabag__ClientId="${{ secrets.BREEF_WALLABAG__CLIENTID }}"
export breef_Wallabag__ClientSecret="${{ secrets.BREEF_WALLABAG__CLIENTSECRET }}"
export breef_Wallabag__Username="${{ secrets.BREEF_WALLABAG__USERNAME }}"
export breef_Wallabag__Password="${{ secrets.BREEF_WALLABAG__PASSWORD }}"
export breef_AiService__Provider="${{ secrets.BREEF_AISERVICE__PROVIDER }}"
export breef_AiService__ModelId="${{ secrets.BREEF_AISERVICE__MODELID }}"
export breef_AiService__EndpointUrl="${{ secrets.BREEF_AISERVICE__ENDPOINTURL }}"
export breef_AiService__ApiKey="${{ secrets.BREEF_AISERVICE__APIKEY }}"
pwsh build/api/test.ps1
- name: Save Docker Image
run: |
docker save `
ghcr.io/elzik/elzik-breef-api:${{ needs.check-release-requirement.outputs.semantic-version }} `
-o breef-api.tar
shell: pwsh
- name: Upload Docker Image Artifact
uses: actions/upload-artifact@v4
with:
name: breef-api-image
path: breef-api.tar
- name: Generate Test Report
uses: dorny/test-reporter@v1
with:
name: Test report
path: '**/test-results.trx'
reporter: dotnet-trx
- name: Upload Coverage Badge
if: github.ref_name == 'main'
uses: exuanbo/actions-deploy-gist@v1
with:
token: "${{ secrets.CODE_COVERAGE_AUTH_TOKEN }}"
gist_id: 527882e89a938dc78f61a08c300edec4
gist_description: "code-coverage-${{ github.ref_name }}"
gist_file_name: breef-code-coverage-${{ github.ref_name }}.svg
file_path: tests/TestResults/badge_shieldsio_linecoverage_green.svg
- name: Install SonarQube Cloud Scanner
shell: pwsh
run: |
New-Item -Path .sonar/scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .sonar/scanner
- name: Perform SonarQube Analysis
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: pwsh
run: |
.sonar/scanner/dotnet-sonarscanner begin `
-k:"elzik_breef" `
-o:"elzik" `
-d:sonar.token="${{ secrets.SONAR_TOKEN }}" `
-d:sonar.host.url="https://sonarcloud.io" `
-d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml"
dotnet build
.sonar/scanner/dotnet-sonarscanner end `
-d:sonar.token="${{ secrets.SONAR_TOKEN }}"
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
needs: [check-release-requirement, build-ubuntu]
if: needs.check-release-requirement.outputs.needs-release == 'true'
steps:
- uses: actions/checkout@v4
- name: Download Docker Image Artifact
uses: actions/download-artifact@v4
with:
name: breef-api-image
- name: Load Docker Image
run: docker load -i breef-api.tar
shell: pwsh
- name: Tag With SemVer
run: |
git tag "v${{ needs.check-release-requirement.outputs.semantic-version }}"
git push --tags
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Tag With Latest
run: |
if ($env:GITHUB_REF -eq "refs/heads/main")
{
docker tag `
ghcr.io/elzik/elzik-breef-api:${{ needs.check-release-requirement.outputs.semantic-version }} `
ghcr.io/elzik/elzik-breef-api:latest
}
shell: pwsh
- name: Push Docker image
run: |
docker push --all-tags ghcr.io/elzik/elzik-breef-api
shell: pwsh