From e3cfbadd9d454d76bb3840a4dae8c8f13ac30858 Mon Sep 17 00:00:00 2001 From: Robbie Davis Date: Mon, 2 Aug 2021 08:22:33 -0400 Subject: [PATCH] Feature/version bump test (#449) ## Changes - Reconfigured Github workflow for better visibility - Added automated version bump on merge push to Develop branch --- .github/workflows/nightly-docker.yml | 6 +- .github/workflows/sonar-scan.yml | 150 ++++++++++++++++++++++++++- .github/workflows/stable-docker.yml | 8 +- .github/workflows/version-bump.yml | 42 -------- 4 files changed, 155 insertions(+), 51 deletions(-) delete mode 100644 .github/workflows/version-bump.yml diff --git a/.github/workflows/nightly-docker.yml b/.github/workflows/nightly-docker.yml index 9df2375cb..45621456a 100644 --- a/.github/workflows/nightly-docker.yml +++ b/.github/workflows/nightly-docker.yml @@ -1,9 +1,7 @@ name: Build Nightly Docker on: - push: - branches: - - 'develop' + workflow_dispatch: jobs: docker: @@ -13,6 +11,8 @@ jobs: - name: Check Out Repo uses: actions/checkout@v2 + with: + ref: develop - name: NodeJS to Compile WebUI uses: actions/setup-node@v2.1.5 diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index b6dfdf351..3955b7cb4 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -9,7 +9,35 @@ on: jobs: build: - name: Build and Scan + name: Build .Net + runs-on: windows-latest + steps: + - 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/upload-artifact@v2 + with: + name: csproj + path: Kavita.Common/Kavita.Common.csproj + + test: + name: Install Sonar & Test + needs: build runs-on: windows-latest steps: - name: Checkout Repo @@ -52,7 +80,7 @@ jobs: New-Item -Path .\.sonar\scanner -ItemType Directory dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner - - name: Build and analyze + - name: Sonar Scan env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} @@ -64,3 +92,121 @@ jobs: - name: Test run: dotnet test --no-restore --verbosity normal + + bump: + name: Create branch for bump if Develop push + runs-on: ubuntu-latest + needs: [ build, test ] + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} + steps: + - uses: actions/checkout@v2 + - uses: actions/download-artifact@v2 + + - 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: Get branch name + id: branch-name + uses: tj-actions/branch-names@v4.5 + + - name: Echo branch name + run: echo "${{ steps.branch-name.outputs.current_branch }}" + + - name: Echo csproj version + run: echo "${{steps.get-version.outputs.assembly-version}}" + + - name: Create Branch + uses: peterjgrainger/action-create-branch@v2.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + branch: "version-bump" + + version: + name: Bump version if Develop push + needs: [ bump ] + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} + steps: + + - name: Download a single artifact + uses: actions/download-artifact@v2 + with: + name: csproj + + - name: Get csproj Version + uses: naminodarie/get-net-sdk-project-versions-action@v1 + id: get-version + with: + proj-path: Kavita.Common.csproj + + - name: Get branch name + id: branch-name + uses: tj-actions/branch-names@v4.5 + + - uses: actions/checkout@v2 + with: + ref: version-bump + fetch-depth: 0 + + - name: Create local changes for reference + run: | + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git pull origin version-bump-${{steps.get-version.outputs.assembly-version}} + git commit --allow-empty -m "Trigger Build" + + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: version-bump-${{steps.get-version.outputs.assembly-version}} + + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.100 + + - name: Install dependencies + run: dotnet restore + + - name: Build + run: dotnet build --configuration Release --no-restore + + - name: Bump versions + uses: SiqiLu/dotnet-bump-version@master + with: + version_files: Kavita.Common/Kavita.Common.csproj + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Merge bump branch -> pr branch + uses: devmasx/merge-branch@v1.3.1 + with: + type: now + from_branch: version-bump-${{ github.event.inputs.version }} + target_branch: develop + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Trigger Docker Nightly + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} + uses: benc-uk/workflow-dispatch@v1 + with: + workflow: Build Nightly Docker + token: ${{ secrets.REPO_GHA_PAT }} + + stable: + name: Trigger Stable Docker if Main push + needs: [ build, test ] + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} + steps: + + - name: If Push to Main, Trigger Docker Stable + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + uses: benc-uk/workflow-dispatch@v1 + with: + workflow: Build Stable Docker + token: ${{ secrets.REPO_GHA_PAT }} \ No newline at end of file diff --git a/.github/workflows/stable-docker.yml b/.github/workflows/stable-docker.yml index cbf5c14c6..9f4dc8363 100644 --- a/.github/workflows/stable-docker.yml +++ b/.github/workflows/stable-docker.yml @@ -1,9 +1,7 @@ name: Build Stable Docker on: - push: - branches: - - 'main' + workflow_dispatch: jobs: docker: @@ -12,6 +10,8 @@ jobs: - name: Check Out Repo uses: actions/checkout@v2 + with: + ref: main - name: NodeJS to Compile WebUI uses: actions/setup-node@v2.1.5 @@ -99,7 +99,7 @@ jobs: uses: rjstone/discord-webhook-notify@v1 with: severity: info - description: + description: ${{ github.event.body }} details: 'https://hub.docker.com/r/kizaing/kavita/tags?page=1&ordering=last_updated' text: A new stable build has been released for docker. webhookUrl: ${{ secrets.DISCORD_DOCKER_UPDATE_URL }} \ No newline at end of file diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml deleted file mode 100644 index f7c02f11c..000000000 --- a/.github/workflows/version-bump.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Bump .Net Version - -on: - push: - branches: - - 'version-bump' - -jobs: - bump: - name: Version bump - runs-on: windows-latest - steps: - - name: Checkout Repo - uses: actions/checkout@v2 - with: - fetch-depth: 0 - ref: version-bump - - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 5.0.100 - - - name: Install dependencies - run: dotnet restore - - - name: Build - run: dotnet build --configuration Release --no-restore - - - name: Bump versions - uses: SiqiLu/dotnet-bump-version@master - with: - version_files: Kavita.Common/Kavita.Common.csproj - github_token: ${{ secrets.GITHUB_TOKEN }} - - - name: Merge bump branch -> pr branch - uses: devmasx/merge-branch@v1.3.1 - with: - type: now - from_branch: version-bump - target_branch: ${{ github.event.inputs.branch }} - github_token: ${{ secrets.GITHUB_TOKEN }}