Updated the action for common #13
This file contains 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: Build common on Pull Request and Push | |
on: | |
workflow_dispatch: | |
push: | |
paths: ['common/**', '.github/workflows/common**'] | |
pull_request: | |
paths: ['common/**', '.github/workflows/common**'] | |
env: | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
DOTNET_NOLOGO: true | |
NuGetDirectory: ${{ github.workspace}}/nuget | |
defaults: | |
run: | |
shell: pwsh | |
jobs: | |
Pack: | |
name: Build and Pack NuGet package and upload to artifact | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup .NET Core SDK 8.0.x | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 8.0.x | |
- name: Pack NuGet Package | |
working-directory: ./common/UTube.Common | |
run: | | |
dotnet build --configuration Release | |
dotnet pack --configuration Release --output ${{ env.NuGetDirectory }} | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: nuget | |
if-no-files-found: error | |
retention-days: 7 | |
path: ${{ env.NuGetDirectory }}/*.nupkg | |
Publish: | |
name: Publish NuGet package to GitHub | |
runs-on: ubuntu-latest | |
needs: Pack | |
if: success() && github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: nuget | |
path: ${{ env.NuGetDirectory }} | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v4 | |
- name: Publish NuGet package | |
run: | | |
dotnet nuget add source --username Rahim373 --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/Rahim373/index.json" | |
foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg)) { | |
dotnet nuget push $file --api-key "${{ secrets.GITHUB_TOKEN }}" --source "github" --skip-duplicate | |
} |