Skip to content

feat: CrossPlatform version #5

feat: CrossPlatform version

feat: CrossPlatform version #5

Workflow file for this run

name: publish
on:
workflow_dispatch:
push:
branches:
- 'main' # Run the workflow when pushing to the main branch
tags:
- 'v*'
pull_request:
branches:
- '*' # Run the workflow for all pull requests
release:
types:
- published # Run the workflow when a new GitHub release is published
env:
NuGetDirectory: ${{ github.workspace}}/nuget
jobs:
ci-windows:
runs-on: windows-latest
strategy:
matrix:
dnversion: ['8.0.x']
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Setup .NET ${{ matrix.dnversion }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dnversion }}
- name: Restore packages
run: dotnet restore NAudio.Lame.CrossPlatform.sln
- name: Build LameDLLWrap (Debug|AnyCPU)
run: dotnet build LameDLLWrap -c:Debug -p:Platform=AnyCPU
- name: Build NAudio.Lame
run: dotnet build NAudio.Lame -c:Debug -p:Platform=AnyCPU
- name: Build Lame.Test
run: dotnet build Lame.Test -c:Debug -p:Platform=AnyCPU
- name: Run tests
run: dotnet test Lame.Test
ci-linux:
runs-on: ubuntu-latest
strategy:
matrix:
dnversion: ['8.0.x']
steps:
- name: Install libmp3lame
run: sudo apt-get install -y lame
- name: Check out repository
uses: actions/checkout@v4
- name: Setup .NET ${{ matrix.dnversion }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dnversion }}
- name: Restore packages
run: dotnet restore NAudio.Lame.CrossPlatform.sln
- name: Build LameDLLWrap (Debug|AnyCPU)
run: dotnet build LameDLLWrap -c:Debug -p:Platform=AnyCPU
- name: Build NAudio.Lame
run: dotnet build NAudio.Lame -c:Debug -p:Platform=AnyCPU
- name: Build Lame.Test
run: dotnet build Lame.Test -c:Debug -p:Platform=AnyCPU
- name: Run tests
run: dotnet test Lame.Test
create_nuget:
runs-on: ubuntu-latest
if: github.event_name == 'release' || startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
dnversion: ['8.0.x']
steps:
- uses: actions/checkout@v4
- name: Setup .NET ${{ matrix.dnversion }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dnversion }}
- name: Build Nuget package
run: |
VERSION_SUFFIX=""
if [[ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]]; then
VERSION_SUFFIX="/p:Version=${GITHUB_REF#refs/tags/}"
fi
dotnet pack ./NAudio.Lame/NAudio.Lame.csproj --configuration Release --output ${{ env.NuGetDirectory }} $VERSION_SUFFIX
# Publish the NuGet package as an artifact, so they can be used in the following jobs
- uses: actions/upload-artifact@v3
with:
name: nuget
if-no-files-found: error
retention-days: 7
path: ${{ env.NuGetDirectory }}/*.nupkg
deploy:
runs-on: ubuntu-latest
needs: [ create_nuget, ci-windows, ci-linux ]
strategy:
matrix:
dnversion: ['8.0.x']
steps:
# Download the NuGet package created in the previous job
- uses: actions/download-artifact@v3
with:
name: nuget
path: ${{ env.NuGetDirectory }}
- name: Setup .NET ${{ matrix.dnversion }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dnversion }}
# Publish all NuGet packages to NuGet.org
# Use --skip-duplicate to prevent errors if a package with the same version already exists.
# If you retry a failed workflow, already published packages will be skipped without error.
- name: Publish NuGet package
run: |
foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg)) {
dotnet nuget push $file --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
}