sonarr-repo-only/.github/workflows/build.yml

258 lines
8.1 KiB
YAML
Raw Permalink Normal View History

2023-11-26 04:23:10 +00:00
name: Build
on:
push:
branches:
- develop
- main
paths-ignore:
2024-07-14 21:36:17 +00:00
- "src/Sonarr.Api.*/openapi.json"
2023-11-26 04:23:10 +00:00
pull_request:
branches:
- develop
paths-ignore:
2024-07-14 21:36:17 +00:00
- "src/NzbDrone.Core/Localization/Core/**"
- "src/Sonarr.Api.*/openapi.json"
2023-11-26 04:23:10 +00:00
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
FRAMEWORK: net6.0
2024-02-21 04:31:08 +00:00
RAW_BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
2023-11-26 04:23:10 +00:00
SONARR_MAJOR_VERSION: 4
2024-07-16 04:34:37 +00:00
VERSION: 4.0.8
2023-11-26 04:23:10 +00:00
jobs:
backend:
runs-on: windows-latest
outputs:
framework: ${{ steps.variables.outputs.framework }}
major_version: ${{ steps.variables.outputs.major_version }}
version: ${{ steps.variables.outputs.version }}
steps:
2024-07-14 21:36:17 +00:00
- name: Check out
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
- name: Setup Environment Variables
id: variables
shell: bash
run: |
# Add 800 to the build number because GitHub won't let us pick an arbitrary starting point
SONARR_VERSION="${{ env.VERSION }}.$((${{ github.run_number }}+800))"
DOTNET_VERSION=$(jq -r '.sdk.version' global.json)
echo "SDK_PATH=${{ env.DOTNET_ROOT }}/sdk/${DOTNET_VERSION}" >> "$GITHUB_ENV"
echo "SONARR_VERSION=$SONARR_VERSION" >> "$GITHUB_ENV"
echo "BRANCH=${RAW_BRANCH_NAME//\//-}" >> "$GITHUB_ENV"
echo "framework=${{ env.FRAMEWORK }}" >> "$GITHUB_OUTPUT"
echo "major_version=${{ env.SONARR_MAJOR_VERSION }}" >> "$GITHUB_OUTPUT"
echo "version=$SONARR_VERSION" >> "$GITHUB_OUTPUT"
- name: Enable Extra Platforms In SDK
shell: bash
run: ./build.sh --enable-extra-platforms-in-sdk
- name: Build Backend
shell: bash
run: ./build.sh --backend --enable-extra-platforms --packages
# Test Artifacts
- name: Publish win-x64 Test Artifact
uses: ./.github/actions/publish-test-artifact
with:
framework: ${{ env.FRAMEWORK }}
runtime: win-x64
- name: Publish linux-x64 Test Artifact
uses: ./.github/actions/publish-test-artifact
with:
framework: ${{ env.FRAMEWORK }}
runtime: linux-x64
- name: Publish osx-arm64 Test Artifact
uses: ./.github/actions/publish-test-artifact
with:
framework: ${{ env.FRAMEWORK }}
runtime: osx-arm64
# Build Artifacts (grouped by OS)
- name: Publish FreeBSD Artifact
uses: actions/upload-artifact@v4
with:
name: build_freebsd
path: _artifacts/freebsd-*/**/*
- name: Publish Linux Artifact
uses: actions/upload-artifact@v4
with:
name: build_linux
path: _artifacts/linux-*/**/*
- name: Publish macOS Artifact
uses: actions/upload-artifact@v4
with:
name: build_macos
path: _artifacts/osx-*/**/*
- name: Publish Windows Artifact
uses: actions/upload-artifact@v4
with:
name: build_windows
path: _artifacts/win-*/**/*
2023-11-26 04:23:10 +00:00
frontend:
runs-on: ubuntu-latest
steps:
2024-07-14 21:36:17 +00:00
- name: Check out
uses: actions/checkout@v4
2023-11-26 04:23:10 +00:00
2024-07-14 21:36:17 +00:00
- name: Volta
uses: volta-cli/action@v4
2023-11-26 04:23:10 +00:00
2024-07-14 21:36:17 +00:00
- name: Yarn Install
run: yarn install
2023-11-26 04:23:10 +00:00
2024-07-14 21:36:17 +00:00
- name: Lint
run: yarn lint
2023-11-26 04:23:10 +00:00
2024-07-14 21:36:17 +00:00
- name: Stylelint
run: yarn stylelint -f github
2023-11-26 04:23:10 +00:00
2024-07-14 21:36:17 +00:00
- name: Build
run: yarn build --env production
2023-11-26 04:23:10 +00:00
2024-07-14 21:36:17 +00:00
- name: Publish UI Artifact
uses: actions/upload-artifact@v4
with:
name: build_ui
path: _output/UI/**/*
2023-11-26 04:23:10 +00:00
unit_test:
needs: backend
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
artifact: tests-linux-x64
filter: TestCategory!=ManualTest&TestCategory!=WINDOWS&TestCategory!=IntegrationTest&TestCategory!=AutomationTest
- os: macos-latest
2024-04-27 21:54:07 +00:00
artifact: tests-osx-arm64
2023-11-26 04:23:10 +00:00
filter: TestCategory!=ManualTest&TestCategory!=WINDOWS&TestCategory!=IntegrationTest&TestCategory!=AutomationTest
- os: windows-latest
artifact: tests-win-x64
filter: TestCategory!=ManualTest&TestCategory!=LINUX&TestCategory!=IntegrationTest&TestCategory!=AutomationTest
runs-on: ${{ matrix.os }}
steps:
2024-07-14 21:36:17 +00:00
- name: Check out
uses: actions/checkout@v4
2023-11-26 04:23:10 +00:00
2024-07-14 21:36:17 +00:00
- name: Test
uses: ./.github/actions/test
with:
os: ${{ matrix.os }}
artifact: ${{ matrix.artifact }}
pattern: Sonarr.*.Test.dll
filter: ${{ matrix.filter }}
2023-11-26 04:23:10 +00:00
unit_test_postgres:
needs: backend
runs-on: ubuntu-latest
steps:
2024-07-14 21:36:17 +00:00
- name: Check out
uses: actions/checkout@v4
- name: Test
uses: ./.github/actions/test
with:
os: ubuntu-latest
artifact: tests-linux-x64
pattern: Sonarr.*.Test.dll
filter: TestCategory!=ManualTest&TestCategory!=WINDOWS&TestCategory!=IntegrationTest&TestCategory!=AutomationTest
use_postgres: true
2023-11-26 04:23:10 +00:00
integration_test:
needs: backend
strategy:
2024-02-19 19:42:54 +00:00
fail-fast: false
2023-11-26 04:23:10 +00:00
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
artifact: tests-linux-x64
filter: TestCategory!=ManualTest&TestCategory!=WINDOWS&TestCategory=IntegrationTest
binary_artifact: build_linux
binary_path: linux-x64/${{ needs.backend.outputs.framework }}/Sonarr
- os: macos-latest
2024-04-27 21:54:07 +00:00
artifact: tests-osx-arm64
2023-11-26 04:23:10 +00:00
filter: TestCategory!=ManualTest&TestCategory!=WINDOWS&TestCategory=IntegrationTest
binary_artifact: build_macos
2024-04-27 21:54:07 +00:00
binary_path: osx-arm64/${{ needs.backend.outputs.framework }}/Sonarr
2023-11-26 04:23:10 +00:00
- os: windows-latest
artifact: tests-win-x64
2024-01-13 00:34:37 +00:00
filter: TestCategory!=ManualTest&TestCategory!=LINUX&TestCategory=IntegrationTest
2023-11-26 04:23:10 +00:00
binary_artifact: build_windows
binary_path: win-x64/${{ needs.backend.outputs.framework }}/Sonarr
runs-on: ${{ matrix.os }}
steps:
2024-07-14 21:36:17 +00:00
- name: Check out
uses: actions/checkout@v4
- name: Test
uses: ./.github/actions/test
with:
os: ${{ matrix.os }}
artifact: ${{ matrix.artifact }}
pattern: Sonarr.*.Test.dll
filter: ${{ matrix.filter }}
integration_tests: true
binary_artifact: ${{ matrix.binary_artifact }}
binary_path: ${{ matrix.binary_path }}
2023-11-26 04:23:10 +00:00
2024-01-14 01:10:00 +00:00
deploy:
if: ${{ github.ref_name == 'develop' || github.ref_name == 'main' }}
2024-04-11 23:32:48 +00:00
needs: [backend, frontend, unit_test, unit_test_postgres, integration_test]
2024-01-14 01:10:00 +00:00
secrets: inherit
uses: ./.github/workflows/deploy.yml
with:
framework: ${{ needs.backend.outputs.framework }}
branch: ${{ github.ref_name }}
major_version: ${{ needs.backend.outputs.major_version }}
version: ${{ needs.backend.outputs.version }}
notify:
name: Discord Notification
2024-07-14 21:36:17 +00:00
needs:
[
backend,
frontend,
unit_test,
unit_test_postgres,
integration_test,
deploy,
]
if: ${{ !cancelled() && (github.ref_name == 'develop' || github.ref_name == 'main') }}
env:
STATUS: ${{ contains(needs.*.result, 'failure') && 'failure' || 'success' }}
runs-on: ubuntu-latest
steps:
- name: Notify
2024-04-14 10:03:16 +00:00
uses: tsickert/discord-webhook@v6.0.0
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
2024-07-14 21:36:17 +00:00
username: "GitHub Actions"
avatar-url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
embed-title: "${{ github.workflow }}: ${{ env.STATUS == 'success' && 'Success' || 'Failure' }}"
2024-07-14 21:36:17 +00:00
embed-url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
embed-description: |
**Branch** ${{ github.ref }}
**Build** ${{ needs.backend.outputs.version }}
embed-color: ${{ env.STATUS == 'success' && '3066993' || '15158332' }}