Merge remote-tracking branch 'origin/main' #31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: publish | |
| on: | |
| workflow_dispatch: # Allow running the workflow manually from the GitHub UI | |
| push: | |
| branches: | |
| - 'main' | |
| pull_request: | |
| branches: | |
| - '*' | |
| release: | |
| types: | |
| - published | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
| DOTNET_NOLOGO: true | |
| NUGET_DIRECTORY: ${{ github.workspace }}/nuget | |
| defaults: | |
| run: | |
| shell: pwsh | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 9.0.x | |
| - name: Run tests | |
| run: dotnet test src/HomeBlaze.sln --configuration Release | |
| build-and-push-image: | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| needs: [ test ] | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Install .NET SDK | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 9.0.x | |
| # Add support for more platforms with QEMU (optional) | |
| # https://github.com/docker/setup-qemu-action | |
| # - name: Set up QEMU | |
| # uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ./src | |
| file: ./src/HomeBlaze/Dockerfile | |
| platforms: linux/amd64,linux/arm64 # removed linux/arm/v7 and linux/386 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| pack: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 9.0.x | |
| - run: dotnet build src/HomeBlaze.sln --configuration Release | |
| - run: dotnet pack src/HomeBlaze.sln --configuration Release --no-build --output ${{ env.NUGET_DIRECTORY }} -p:PackageVersion=1.0.0 #${{ github.event.release.tag_name }} | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: nuget | |
| if-no-files-found: error | |
| retention-days: 7 | |
| path: ${{ env.NUGET_DIRECTORY }}/*.nupkg | |
| validate: | |
| runs-on: ubuntu-latest | |
| needs: [ pack ] | |
| steps: | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 9.0.x | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: nuget | |
| path: ${{ env.NUGET_DIRECTORY }} | |
| - name: Install nuget validator | |
| run: dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global | |
| - name: Validate package | |
| run: meziantou.validate-nuget-package --excluded-rules IconMustBeSet,ReadmeMustBeSet,Symbols,ProjectUrlMustBeSet (Get-ChildItem "${{ env.NUGET_DIRECTORY }}/*.nupkg") | |
| deploy: | |
| if: github.event_name == 'release' | |
| runs-on: ubuntu-latest | |
| needs: [ validate, test ] | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: nuget | |
| path: ${{ env.NUGET_DIRECTORY }} | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 9.0.x | |
| # 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.NUGET_DIRECTORY }}" -Recurse -Include *.nupkg)) { | |
| dotnet nuget push $file --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| } |