From b5f92d46a949c427490f5d065573e783c0a94aff Mon Sep 17 00:00:00 2001 From: Robbie Davis Date: Sat, 17 Jul 2021 16:05:40 -0400 Subject: [PATCH] Adding Additional Workflows and Actions (#397) * Cleaning and adding to workflows - Renamed some workflows to better describe it's purpose. - Added steps for autobump - Added steps for sentry maps - Manually pushing sentry map workflow to git initially so it exists already for the workflow-dispatch trigger. Will need to add another commit to revert workflow back to only trigger on dispatch. * Fixing and cleaning workflow - Removed unused discord workflow - Changed sentry map workflow to differentiate between another workflow. - Changed name of new renamed sentry workflow in dispatches. * Updating sentry workflow with dispatch trigger * fixing webui path issue for docker builds --- .github/workflows/discord-release-msg.yml | 17 ----- .github/workflows/monorepo-test.yml | 38 ----------- .github/workflows/nightly-docker.yml | 24 ++++++- .github/workflows/sentry-map.yml | 63 +++++++++++++++++++ .github/workflows/sentry-release.yml | 42 ------------- .../workflows/{build.yml => sonar-scan.yml} | 18 ++++-- .github/workflows/stable-docker.yml | 16 +++++ Dockerfile | 2 +- 8 files changed, 115 insertions(+), 105 deletions(-) delete mode 100644 .github/workflows/discord-release-msg.yml delete mode 100644 .github/workflows/monorepo-test.yml create mode 100644 .github/workflows/sentry-map.yml delete mode 100644 .github/workflows/sentry-release.yml rename .github/workflows/{build.yml => sonar-scan.yml} (89%) diff --git a/.github/workflows/discord-release-msg.yml b/.github/workflows/discord-release-msg.yml deleted file mode 100644 index f3acd153e..000000000 --- a/.github/workflows/discord-release-msg.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Release messages to discord announcement channel - -on: - release: - types: - - created - -jobs: - run_main: - runs-on: ubuntu-18.04 - name: Sends custom message - steps: - - name: Sending message - uses: nhevia/discord-styled-releases@main - with: - webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }} - webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/monorepo-test.yml b/.github/workflows/monorepo-test.yml deleted file mode 100644 index 0408c0956..000000000 --- a/.github/workflows/monorepo-test.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Monorepo Build Test - -on: - push: - branches: - - 'feature/monorepo' - -jobs: - docker: - runs-on: ubuntu-latest - steps: - - - name: Check Out Repo - uses: actions/checkout@v2 - - - name: NodeJS to Compile WebUI - uses: actions/setup-node@v2.1.5 - with: - node-version: '14' - - run: | - - cd UI/Web || exit - echo 'Installing web dependencies' - npm install - - echo 'Building UI' - npm run prod - - echo 'Copying back to Kavita wwwroot' - rsync -a dist/ ../../API/wwwroot/ - - cd ../ || exit - - - name: Compile dotnet app - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '5.0.x' - - run: ./monorepo-build.sh diff --git a/.github/workflows/nightly-docker.yml b/.github/workflows/nightly-docker.yml index 8f36afd82..c034492fe 100644 --- a/.github/workflows/nightly-docker.yml +++ b/.github/workflows/nightly-docker.yml @@ -7,6 +7,7 @@ on: jobs: docker: + name: Building Nightly Docker runs-on: ubuntu-latest steps: @@ -18,7 +19,6 @@ jobs: with: node-version: '14' - run: | - cd UI/Web || exit echo 'Installing web dependencies' npm install @@ -31,12 +31,34 @@ jobs: cd ../ || exit + - name: Bump versions + uses: SiqiLu/dotnet-bump-version@master + with: + version_files: "Kavita.Common/Kavita.Common.csproj" + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Get csproj Version + uses: naminodarie/get-net-sdk-project-versions-action@v1 + id: get-version + with: + proj-path: Kavita.Common/Kavita.Common.csproj + + - name: Echo csproj version + run: echo "${{steps.get-version.outputs.assembly-version}}" + - name: Compile dotnet app uses: actions/setup-dotnet@v1 with: dotnet-version: '5.0.x' - run: ./monorepo-build.sh + - name: Trigger Sentry workflow + uses: benc-uk/workflow-dispatch@v1 + with: + workflow: Sentry Map Release + token: ${{ secrets.REPO_GHA_PAT }} + inputs: '{ "version": "${{steps.get-version.outputs.assembly-version}}" }' + - name: Login to Docker Hub uses: docker/login-action@v1 with: diff --git a/.github/workflows/sentry-map.yml b/.github/workflows/sentry-map.yml new file mode 100644 index 000000000..3f53232bc --- /dev/null +++ b/.github/workflows/sentry-map.yml @@ -0,0 +1,63 @@ +name: Sentry Map Release +on: + workflow_dispatch: + inputs: + version: + description: "version to update package.json" + required: true + # No default + +jobs: + build: + name: Setup Sentry CLI + runs-on: ubuntu-latest + steps: + - uses: mathieu-bour/setup-sentry-cli@1.2.0 + with: + version: latest + token: ${{ secrets.SENTRY_TOKEN }} + organization: kavita-7n + project: angular + + - name: Check out repository + uses: actions/checkout@v2 + + - name: Parse Version + run: | + version='${{ github.event.inputs.version }}' + newVersion=${version%.*} + echo $newVersion + echo "::set-output name=VERSION::$newVersion" + id: parse-version + + - name: NodeJS to Compile WebUI + uses: actions/setup-node@v2.1.5 + with: + node-version: '14' + + - run: | + cd UI/Web || exit + echo 'Installing web dependencies' + npm install + + npm version --allow-same-version "${{ steps.parse-version.outputs.VERSION }}" + + echo 'Building UI' + npm run prod + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Create Release + run: sentry-cli releases new ${{ steps.parse-version.outputs.VERSION }} + + - name: Upload Source Maps + run: sentry-cli releases files ${{ steps.parse-version.outputs.VERSION }} upload-sourcemaps UI/Web/dist + + - name: Finalize Release + run: sentry-cli releases finalize ${{ steps.parse-version.outputs.VERSION }} diff --git a/.github/workflows/sentry-release.yml b/.github/workflows/sentry-release.yml deleted file mode 100644 index 990dbc444..000000000 --- a/.github/workflows/sentry-release.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Sentry Release -on: - push: - branches: [ main, develop, feature/sentry-release ] - -jobs: - build: - name: Setup Sentry CLI - runs-on: ubuntu-latest - steps: - - uses: mathieu-bour/setup-sentry-cli@1.2.0 - with: - version: latest - token: ${{ SECRETS.SENTRY_TOKEN }} - organization: kavita-7n - project: angular - - name: Checkout - uses: actions/checkout@v2 - - name: Install NodeJS - uses: actions/setup-node@v2 - with: - node-version: '12' - - name: Cache dependencies - uses: actions/cache@v2 - with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node- - - name: Install Dependencies - run: npm install - - name: Build Angular - run: npm run prod - - name: get-npm-version - id: package-version - uses: martinbeentjes/npm-get-version-action@master - - name: Create Release - run: sentry-cli releases new ${{ steps.package-version.outputs.current-version }} - - name: Upload Source Maps - run: sentry-cli releases files ${{ steps.package-version.outputs.current-version }} upload-sourcemaps ./dist - - name: Finalize Release - run: sentry-cli releases finalize ${{ steps.package-version.outputs.current-version }} diff --git a/.github/workflows/build.yml b/.github/workflows/sonar-scan.yml similarity index 89% rename from .github/workflows/build.yml rename to .github/workflows/sonar-scan.yml index 231622b99..b6dfdf351 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/sonar-scan.yml @@ -1,4 +1,4 @@ -name: .NET Core Build +name: .NET Build Test and Sonar Scan on: push: @@ -9,31 +9,34 @@ on: jobs: build: - name: Build + name: Build and Scan runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - name: Checkout Repo + uses: actions/checkout@v2 with: fetch-depth: 0 + - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: dotnet-version: 5.0.100 + - name: Install dependencies run: dotnet restore + - name: Set up JDK 11 uses: actions/setup-java@v1 with: java-version: 1.11 - - uses: actions/checkout@v2 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - 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 @@ -41,12 +44,14 @@ jobs: path: .\.sonar\scanner key: ${{ runner.os }}-sonar-scanner restore-keys: ${{ runner.os }}-sonar-scanner + - 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 }} # Needed to get PR information, if any @@ -56,5 +61,6 @@ jobs: .\.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 .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" + - name: Test run: dotnet test --no-restore --verbosity normal diff --git a/.github/workflows/stable-docker.yml b/.github/workflows/stable-docker.yml index daeae851d..6dfed1b30 100644 --- a/.github/workflows/stable-docker.yml +++ b/.github/workflows/stable-docker.yml @@ -31,12 +31,28 @@ jobs: cd ../ || exit + - name: Get csproj Version + uses: naminodarie/get-net-sdk-project-versions-action@v1 + id: get-version + with: + proj-path: Kavita.Common/Kavita.Common.csproj + + - name: Echo csproj version + run: echo "${{steps.get-version.outputs.assembly-version}}" + - name: Compile dotnet app uses: actions/setup-dotnet@v1 with: dotnet-version: '5.0.x' - run: ./monorepo-build.sh + - name: Trigger Sentry workflow + uses: benc-uk/workflow-dispatch@v1 + with: + workflow: Sentry Map Release + token: ${{ secrets.REPO_GHA_PAT }} + inputs: '{ "version": "${{steps.get-version.outputs.assembly-version}}" }' + - name: Login to Docker Hub uses: docker/login-action@v1 with: diff --git a/Dockerfile b/Dockerfile index 4b1fb47b7..adead7274 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ ARG TARGETPLATFORM #Move the output files to where they need to be RUN mkdir /files COPY _output/*.tar.gz /files/ -COPY Kavita-webui/dist /files/wwwroot +COPY UI/Web/dist /files/wwwroot COPY copy_runtime.sh /copy_runtime.sh RUN /copy_runtime.sh