Create build artifacts

This commit is contained in:
Mark McDowall 2024-01-05 13:31:50 -08:00
parent 9f5da7bfa3
commit 5df0f3953e
6 changed files with 180 additions and 18 deletions

29
.github/actions/archive/action.yml vendored Normal file
View File

@ -0,0 +1,29 @@
name: Archive
description: Archive binaries for deployment
inputs:
os:
description: 'OS that the packaging is running on'
required: true
artifact:
description: 'Binary artifact'
required: true
archive_type:
description: 'File type to use for the final package'
required: true
branch:
description: 'Git branch used for this build'
required: true
major_version:
description: 'Sonarr major version'
required: true
version:
description: 'Sonarr version'
required: true
runs:
using: 'composite'
steps:
- name: Archive Artifact
uses: thedoctor0/zip-release@0.7.5

45
.github/actions/package/action.yml vendored Normal file
View File

@ -0,0 +1,45 @@
name: Package
description: Packages binaries for deployment
inputs:
artifact:
description: 'Binary artifact'
required: true
branch:
description: 'Git branch used for this build'
required: true
major_version:
description: 'Sonarr major version'
required: true
version:
description: 'Sonarr version'
required: true
runs:
using: 'composite'
steps:
- name: Download UI Artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact }}
path: _artifacts
- name: Download UI Artifact
uses: actions/download-artifact@v4
with:
name: ui
path: _output/UI
- name: Create Packages
shell: bash
run: ./.github/actions/package.sh
- name: List Artifacts
shell: bash
run: ls -l _artifacts
# - name: Upload Artifact
# uses: actions/upload-artifact@v4
# with:
# name: ${{ env.RESULTS_NAME }}
# path: ${{ env.RESULTS_NAME }}

62
.github/actions/package/package.sh vendored Executable file
View File

@ -0,0 +1,62 @@
#!/bin/bash
outputFolder=_output
artifactsFolder=_artifacts
uiFolder="$outputFolder/UI"
for folder in _artifacts/*
do
name="${folder##*/}"
folderName="$outputFolder/$name"
sonarrFolder="$folderName/Sonarr"
echo "Creating package for $name"
rm -rf $folderName
mkdir $folderName
cp -r "$folder/net6.0/Sonarr" $sonarrFolder
echo "Copying UI folder"
cp -r $uiFolder $sonarrFolder
echo "Setting permissions"
find $sonarrFolder -name "ffprobe" -exec chmod a+x {} \;
find $sonarrFolder -name "Sonarr" -exec chmod a+x {} \;
find $sonarrFolder -name "Sonarr.Update" -exec chmod a+x {} \;
if [[ "$name" == *"osx"* ]]; then
echo "Creating macOS package"
packageName="$name-app"
packageFolder="$outputFolder/$packageName"
rm -rf $packageFolder
mkdir $packageFolder
cp -r distribution/macOS/Sonarr.app $packageFolder
mkdir -p $packageFolder/Sonarr.app/Contents/MacOS
echo "Copying Binaries"
cp -r $sonarrFolder/* $packageFolder/Sonarr.app/Contents/MacOS
echo "Removing Update Folder"
rm -r $packageFolder/Sonarr.app/Contents/MacOS/Sonarr.Update
echo "Packaging macOS app Artifact"
(cd $packageFolder; zip -rq "../../$artifactsFolder/$name-app.zip" ./Sonarr.app)
fi
echo "Packaging Artifact"
if [[ "$name" == *"linux"* ]] || [[ "$name" == *"osx"* ]] || [[ "$name" == *"freebsd"* ]]; then
tar -zcf "$artifactsFolder/$name.tar.gz" -C $folderName Sonarr
fi
if [[ "$name" == *"win"* ]]; then
if [ "$RUNNER_OS" = "Windows" ]
then
7z a -tzip "$artifactsFolder/$name.zip" $folderName
else
(cd $folderName; zip -rq "../../$artifactsFolder/$name.zip" ./Sonarr)
fi
fi
done

View File

@ -1,6 +1,6 @@
# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
name: Run test on DLLs matching the specified pattern
name: Test
description: Runs unit/integration tests
inputs:
@ -38,7 +38,7 @@ runs:
- name: Setup Test Variables
shell: bash
run: |
echo "RESULTS_NAME=${{ inputs.integration_tests && 'integation_' || 'unit_' }}${{ inputs.artifact }}${{ inputs.use_postgres && '_postgres' }}" >> "$GITHUB_ENV"
echo "RESULTS_NAME=${{ inputs.integration_tests && 'integation-' || 'unit-' }}${{ inputs.artifact }}${{ inputs.use_postgres && '_postgres' }}" >> "$GITHUB_ENV"
- name: Setup Postgres Environment Variables
if: ${{ inputs.use_postgres }}

View File

@ -21,6 +21,9 @@ env:
jobs:
backend:
runs-on: windows-latest
outputs:
major_version: ${{ steps.variables.outputs.major_version }}
version: ${{ steps.variables.outputs.version }}
steps:
- name: Check out
uses: actions/checkout@v3
@ -29,12 +32,14 @@ jobs:
uses: actions/setup-dotnet@v3
- name: Setup Environment Variables
id: variables
shell: bash
run: |
echo "Run ID: ${{ github.run_id }}"
DOTNET_VERSION=$(jq -r '.sdk.version' global.json)
echo "SDK_PATH=${{ env.DOTNET_ROOT }}/sdk/${DOTNET_VERSION}" >> "$GITHUB_ENV"
echo "SONARR_VERSION=${{ env.VERSION }}.${{ github.run_number }}" >> "$GITHUB_ENV"
echo "major_version=${{ env.SONARR_MAJOR_VERSION }}" >> "$GITHUB_OUTPUT"
echo "version=${{ env.VERSION }}.${{ github.run_number }}" >> "$GITHUB_OUTPUT"
- name: Enable Extra Platforms In SDK
shell: bash
@ -66,22 +71,22 @@ jobs:
- name: Publish FreeBSD Artifact
uses: actions/upload-artifact@v4
with:
name: freebsd
name: build_freebsd
path: _artifacts/freebsd-*/**/*
- name: Publish Linux Artifact
uses: actions/upload-artifact@v4
with:
name: linux
name: build_linux
path: _artifacts/linux-*/**/*
- name: Publish macOS Artifact
uses: actions/upload-artifact@v4
with:
name: macos
name: build_macos
path: _artifacts/osx-*/**/*
- name: Publish Windows Artifact
uses: actions/upload-artifact@v4
with:
name: windows
name: build_windows
path: _artifacts/win-*/**/*
frontend:
@ -164,17 +169,17 @@ jobs:
- os: ubuntu-latest
artifact: tests-linux-x64
filter: TestCategory!=ManualTest&TestCategory!=WINDOWS&TestCategory=IntegrationTest
binary_artifact: linux
binary_artifact: build_linux
binary_path: linux-x64/net6.0/Sonarr
- os: macos-latest
artifact: tests-osx-x64
filter: TestCategory!=ManualTest&TestCategory!=WINDOWS&TestCategory=IntegrationTest
binary_artifact: macos
binary_artifact: build_macos
binary_path: osx-x64/net6.0/Sonarr
- os: windows-latest
artifact: tests-win-x64
filter: TestCategory!=ManualTest&TestCategory=WINDOWS&TestCategory=IntegrationTest
binary_artifact: windows
binary_artifact: build_windows
binary_path: win-x64/net6.0/Sonarr
runs-on: ${{ matrix.os }}
steps:
@ -191,10 +196,13 @@ jobs:
integration_tests: true
binary_artifact: ${{ matrix.binary_artifact }}
binary_path: ${{ matrix.binary_path }}
deploy:
if: ${{ github.ref_name == 'develop' || github.ref_name == 'main' }}
needs: [backend, unit_test, unit_test_postgres, integration_test]
secrets: inherit
uses: ./.github/workflows/deploy.yml
with:
branch: ${{ github.ref_name }}
version: ${{ env.SONARR_VERSION }}
major_version: ${{ needs.backend.outputs.major_version }}
version: ${{ needs.backend.outputs.version }}

View File

@ -6,6 +6,9 @@ on:
branch:
required: true
type: string
major_version:
required: true
type: string
version:
required: true
type: string
@ -14,14 +17,29 @@ on:
required: true
jobs:
package_linux:
runs-on: ubuntu-latest
package_windows:
runs-on: windows-latest
steps:
- name: Check out
uses: actions/checkout@v3
- name: Download Artifact
uses: actions/download-artifact@v4
- name: Package
uses: ./.github/actions/package
with:
name: linux
path: _artifacts
os: windows-latest
artifact: build_windows
branch: ${{ inputs.branch }}
version: ${{ inputs.version }}
# package_linux:
# runs-on: ubuntu-latest
# steps:
# - name: Check out
# uses: actions/checkout@v3
# - name: Download Artifact
# uses: actions/download-artifact@v4
# with:
# name: build_linux
# path: _artifacts