Revert "Aligned build with main (#1801)"

This reverts commit 3f6eb5fe17934cc5aa3b227b165e184bf47ade14.
This commit is contained in:
Robbie Davis 2023-02-18 12:29:01 -05:00
parent dcf295c448
commit 1ce4f2b3ab

View File

@ -1,337 +1,336 @@
name: .NET Build Test and Sonar Scan name: .NET Build Test and Sonar Scan
on: on:
push: push:
branches: '**' branches: '**'
pull_request: pull_request:
branches: [ main, develop ] branches: [ main, develop ]
types: [synchronize] types: [synchronize]
workflow_dispatch:
jobs: jobs:
build: build:
name: Build .Net name: Build .Net
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- name: Checkout Repo - name: Checkout Repo
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Setup .NET Core - name: Setup .NET Core
uses: actions/setup-dotnet@v2 uses: actions/setup-dotnet@v2
with: with:
dotnet-version: 6.0.x dotnet-version: 6.0.x
- name: Install Swashbuckle CLI - name: Install Swashbuckle CLI
shell: powershell shell: powershell
run: dotnet tool install -g --version 6.4.0 Swashbuckle.AspNetCore.Cli run: dotnet tool install -g --version 6.4.0 Swashbuckle.AspNetCore.Cli
- name: Install dependencies - name: Install dependencies
run: dotnet restore run: dotnet restore
- name: Set up JDK 11 - name: Set up JDK 11
uses: actions/setup-java@v1 uses: actions/setup-java@v1
with: with:
java-version: 1.11 java-version: 1.11
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
with: with:
name: csproj name: csproj
path: Kavita.Common/Kavita.Common.csproj path: Kavita.Common/Kavita.Common.csproj
- name: Cache SonarCloud packages - name: Cache SonarCloud packages
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ~\sonar\cache path: ~\sonar\cache
key: ${{ runner.os }}-sonar key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner - name: Cache SonarCloud scanner
id: cache-sonar-scanner id: cache-sonar-scanner
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: .\.sonar\scanner path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner - name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell shell: powershell
run: | run: |
New-Item -Path .\.sonar\scanner -ItemType Directory New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: Sonar Scan - name: Sonar Scan
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell shell: powershell
run: | run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"Kareadita_Kavita" /o:"kareadita" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" .\.sonar\scanner\dotnet-sonarscanner begin /k:"Kareadita_Kavita" /o:"kareadita" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
dotnet build --configuration Release dotnet build --configuration Release
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
- name: Test - name: Test
run: dotnet test --no-restore --verbosity normal run: dotnet test --no-restore --verbosity normal
version: version:
name: Bump version on Develop push name: Bump version on Develop push
needs: [ build ] needs: [ build ]
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Setup .NET Core - name: Setup .NET Core
uses: actions/setup-dotnet@v2 uses: actions/setup-dotnet@v2
with: with:
dotnet-version: 6.0.x dotnet-version: 6.0.x
- name: Install Swashbuckle CLI - name: Install Swashbuckle CLI
run: dotnet tool install -g --version 6.4.0 Swashbuckle.AspNetCore.Cli run: dotnet tool install -g --version 6.4.0 Swashbuckle.AspNetCore.Cli
- name: Install dependencies - name: Install dependencies
run: dotnet restore run: dotnet restore
- name: Build - name: Build
run: dotnet build --configuration Release --no-restore run: dotnet build --configuration Release --no-restore
- name: Bump versions - name: Bump versions
uses: SiqiLu/dotnet-bump-version@2.0.0 uses: SiqiLu/dotnet-bump-version@2.0.0
with: with:
version_files: Kavita.Common/Kavita.Common.csproj version_files: Kavita.Common/Kavita.Common.csproj
github_token: ${{ secrets.REPO_GHA_PAT }} github_token: ${{ secrets.REPO_GHA_PAT }}
version_mask: "0.0.0.1" version_mask: "0.0.0.1"
develop: develop:
name: Build Nightly Docker if Develop push name: Build Nightly Docker if Develop push
needs: [ build, version ] needs: [ build, version ]
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }}
steps: steps:
- name: Find Current Pull Request - name: Find Current Pull Request
uses: jwalton/gh-find-current-pr@v1.0.2 uses: jwalton/gh-find-current-pr@v1.0.2
id: findPr id: findPr
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Parse PR body - name: Parse PR body
id: parse-body id: parse-body
run: | run: |
body="${{ steps.findPr.outputs.body }}" body="${{ steps.findPr.outputs.body }}"
if [[ ${#body} -gt 1870 ]] ; then if [[ ${#body} -gt 1870 ]] ; then
body=${body:0:1870} body=${body:0:1870}
body="${body}...and much more. body="${body}...and much more.
Read full changelog: https://github.com/Kareadita/Kavita/pull/${{ steps.findPr.outputs.pr }}" Read full changelog: https://github.com/Kareadita/Kavita/pull/${{ steps.findPr.outputs.pr }}"
fi fi
body=${body//\'/} body=${body//\'/}
body=${body//'%'/'%25'} body=${body//'%'/'%25'}
body=${body//$'\n'/'%0A'} body=${body//$'\n'/'%0A'}
body=${body//$'\r'/'%0D'} body=${body//$'\r'/'%0D'}
body=${body//$'`'/'%60'} body=${body//$'`'/'%60'}
body=${body//$'>'/'%3E'} body=${body//$'>'/'%3E'}
echo $body echo $body
echo "::set-output name=BODY::$body" echo "::set-output name=BODY::$body"
- name: Check Out Repo - name: Check Out Repo
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
ref: develop ref: develop
- name: NodeJS to Compile WebUI - name: NodeJS to Compile WebUI
uses: actions/setup-node@v2.1.5 uses: actions/setup-node@v2.1.5
with: with:
node-version: '14' node-version: '14'
- run: | - run: |
cd UI/Web || exit cd UI/Web || exit
echo 'Installing web dependencies' echo 'Installing web dependencies'
npm ci --legacy-peer-deps npm ci
echo 'Building UI' echo 'Building UI'
npm run prod npm run prod
echo 'Copying back to Kavita wwwroot' echo 'Copying back to Kavita wwwroot'
rsync -a dist/ ../../API/wwwroot/ rsync -a dist/ ../../API/wwwroot/
cd ../ || exit cd ../ || exit
- name: Get csproj Version - name: Get csproj Version
uses: naminodarie/get-net-sdk-project-versions-action@v1 uses: naminodarie/get-net-sdk-project-versions-action@v1
id: get-version id: get-version
with: with:
proj-path: Kavita.Common/Kavita.Common.csproj proj-path: Kavita.Common/Kavita.Common.csproj
- name: Parse Version - name: Parse Version
run: | run: |
version='${{steps.get-version.outputs.assembly-version}}' version='${{steps.get-version.outputs.assembly-version}}'
echo "::set-output name=VERSION::$version" echo "::set-output name=VERSION::$version"
id: parse-version id: parse-version
- name: Echo csproj version - name: Echo csproj version
run: echo "${{steps.get-version.outputs.assembly-version}}" run: echo "${{steps.get-version.outputs.assembly-version}}"
- name: Compile dotnet app - name: Compile dotnet app
uses: actions/setup-dotnet@v2 uses: actions/setup-dotnet@v2
with: with:
dotnet-version: 6.0.x dotnet-version: 6.0.x
- name: Install Swashbuckle CLI - name: Install Swashbuckle CLI
run: dotnet tool install -g --version 6.4.0 Swashbuckle.AspNetCore.Cli run: dotnet tool install -g --version 6.4.0 Swashbuckle.AspNetCore.Cli
- run: ./monorepo-build.sh - run: ./monorepo-build.sh
- name: Login to Docker Hub - name: Login to Docker Hub
uses: docker/login-action@v1 uses: docker/login-action@v1
with: with:
username: ${{ secrets.DOCKER_HUB_USERNAME }} username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v1 uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx - name: Set up Docker Buildx
id: buildx id: buildx
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
- name: Build and push - name: Build and push
id: docker_build id: docker_build
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
context: . context: .
platforms: linux/amd64,linux/arm/v7,linux/arm64 platforms: linux/amd64,linux/arm/v7,linux/arm64
push: true push: true
tags: kizaing/kavita:nightly, kizaing/kavita:nightly-${{ steps.parse-version.outputs.VERSION }} tags: kizaing/kavita:nightly, kizaing/kavita:nightly-${{ steps.parse-version.outputs.VERSION }}
- name: Image digest - name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }} run: echo ${{ steps.docker_build.outputs.digest }}
- name: Notify Discord - name: Notify Discord
uses: rjstone/discord-webhook-notify@v1 uses: rjstone/discord-webhook-notify@v1
with: with:
severity: info severity: info
description: v${{steps.get-version.outputs.assembly-version}} - ${{ steps.findPr.outputs.title }} description: v${{steps.get-version.outputs.assembly-version}} - ${{ steps.findPr.outputs.title }}
details: '${{ steps.parse-body.outputs.BODY }}' details: '${{ steps.parse-body.outputs.BODY }}'
text: <@&939225459156217917> <@&939225350775406643> A new nightly build has been released for docker. text: <@&939225459156217917> <@&939225350775406643> A new nightly build has been released for docker.
webhookUrl: ${{ secrets.DISCORD_DOCKER_UPDATE_URL }} webhookUrl: ${{ secrets.DISCORD_DOCKER_UPDATE_URL }}
stable: stable:
name: Build Stable Docker if Main push name: Build Stable Docker if Main push
needs: [ build ] needs: [ build ]
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
steps: steps:
- name: Find Current Pull Request - name: Find Current Pull Request
uses: jwalton/gh-find-current-pr@v1.0.2 uses: jwalton/gh-find-current-pr@v1.0.2
id: findPr id: findPr
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Parse PR body - name: Parse PR body
id: parse-body id: parse-body
run: | run: |
body="${{ steps.findPr.outputs.body }}" body="${{ steps.findPr.outputs.body }}"
if [[ ${#body} -gt 1870 ]] ; then if [[ ${#body} -gt 1870 ]] ; then
body=${body:0:1870} body=${body:0:1870}
body="${body}...and much more. body="${body}...and much more.
Read full changelog: https://github.com/Kareadita/Kavita/releases/latest" Read full changelog: https://github.com/Kareadita/Kavita/releases/latest"
fi fi
body=${body//\'/} body=${body//\'/}
body=${body//'%'/'%25'} body=${body//'%'/'%25'}
body=${body//$'\n'/'%0A'} body=${body//$'\n'/'%0A'}
body=${body//$'\r'/'%0D'} body=${body//$'\r'/'%0D'}
body=${body//$'`'/'%60'} body=${body//$'`'/'%60'}
body=${body//$'>'/'%3E'} body=${body//$'>'/'%3E'}
echo $body echo $body
echo "::set-output name=BODY::$body" echo "::set-output name=BODY::$body"
- name: Check Out Repo - name: Check Out Repo
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
ref: main ref: main
- name: NodeJS to Compile WebUI - name: NodeJS to Compile WebUI
uses: actions/setup-node@v2.1.5 uses: actions/setup-node@v2.1.5
with: with:
node-version: '14' node-version: '14'
- run: | - run: |
cd UI/Web || exit cd UI/Web || exit
echo 'Installing web dependencies' echo 'Installing web dependencies'
npm ci --legacy-peer-deps npm install
echo 'Building UI' echo 'Building UI'
npm run prod npm run prod
echo 'Copying back to Kavita wwwroot' echo 'Copying back to Kavita wwwroot'
rsync -a dist/ ../../API/wwwroot/ rsync -a dist/ ../../API/wwwroot/
cd ../ || exit cd ../ || exit
- name: Get csproj Version - name: Get csproj Version
uses: naminodarie/get-net-sdk-project-versions-action@v1 uses: naminodarie/get-net-sdk-project-versions-action@v1
id: get-version id: get-version
with: with:
proj-path: Kavita.Common/Kavita.Common.csproj proj-path: Kavita.Common/Kavita.Common.csproj
- name: Echo csproj version - name: Echo csproj version
run: echo "${{steps.get-version.outputs.assembly-version}}" run: echo "${{steps.get-version.outputs.assembly-version}}"
- name: Parse Version - name: Parse Version
run: | run: |
version='${{steps.get-version.outputs.assembly-version}}' version='${{steps.get-version.outputs.assembly-version}}'
newVersion=${version%.*} newVersion=${version%.*}
echo $newVersion echo $newVersion
echo "::set-output name=VERSION::$newVersion" echo "::set-output name=VERSION::$newVersion"
id: parse-version id: parse-version
- name: Compile dotnet app - name: Compile dotnet app
uses: actions/setup-dotnet@v2 uses: actions/setup-dotnet@v2
with: with:
dotnet-version: 6.0.x dotnet-version: 6.0.x
- name: Install Swashbuckle CLI - name: Install Swashbuckle CLI
run: dotnet tool install -g --version 6.4.0 Swashbuckle.AspNetCore.Cli run: dotnet tool install -g --version 6.4.0 Swashbuckle.AspNetCore.Cli
- run: ./monorepo-build.sh - run: ./monorepo-build.sh
- name: Login to Docker Hub - name: Login to Docker Hub
uses: docker/login-action@v1 uses: docker/login-action@v1
with: with:
username: ${{ secrets.DOCKER_HUB_USERNAME }} username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v1 uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx - name: Set up Docker Buildx
id: buildx id: buildx
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
- name: Build and push - name: Build and push
id: docker_build id: docker_build
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
context: . context: .
platforms: linux/amd64,linux/arm/v7,linux/arm64 platforms: linux/amd64,linux/arm/v7,linux/arm64
push: true push: true
tags: kizaing/kavita:latest, kizaing/kavita:${{ steps.parse-version.outputs.VERSION }} tags: kizaing/kavita:latest, kizaing/kavita:${{ steps.parse-version.outputs.VERSION }}
- name: Image digest - name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }} run: echo ${{ steps.docker_build.outputs.digest }}
- name: Notify Discord - name: Notify Discord
uses: rjstone/discord-webhook-notify@v1 uses: rjstone/discord-webhook-notify@v1
with: with:
severity: info severity: info
description: v${{steps.get-version.outputs.assembly-version}} - ${{ steps.findPr.outputs.title }} description: v${{steps.get-version.outputs.assembly-version}} - ${{ steps.findPr.outputs.title }}
details: '${{ steps.parse-body.outputs.BODY }}' details: '${{ steps.parse-body.outputs.BODY }}'
text: <@&939225192553644133> A new stable build has been released. text: <@&939225192553644133> A new stable build has been released.
webhookUrl: ${{ secrets.DISCORD_DOCKER_UPDATE_URL }} webhookUrl: ${{ secrets.DISCORD_DOCKER_UPDATE_URL }}