diff --git a/.github/workflows/preview.yml b/.github/workflows/build.yml similarity index 55% rename from .github/workflows/preview.yml rename to .github/workflows/build.yml index 4d05c478..ee46f289 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/build.yml @@ -1,20 +1,29 @@ -name: Publish Preview +name: Build on: + push: + # branches: + # - main + tags: + - '*' + paths-ignore: + - README.md + - '**/README.md' + - LICENSE + - CHANGELOG.md + - docs/** + pull_request: + branches: + - main + paths-ignore: + - README.md + - '**/README.md' + - LICENSE + - CHANGELOG.md + - docs/** workflow_dispatch: - inputs: - reason: - description: 'Reason for running the action' - required: false - default: 'Pre-Release' - private: - description: 'Whether to publish to the private feed' - required: false - default: 'true' - public: - description: 'Whether to publish to the public NuGet feed' - required: false - default: 'false' + schedule: + - cron: '0 1 * * *' # daily at 1am UTC env: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 @@ -22,6 +31,7 @@ env: jobs: Build: runs-on: ubuntu-latest + name: Build steps: - name: Checkout @@ -49,17 +59,10 @@ jobs: run: dotnet restore - name: Build - run: > - dotnet build - --configuration Release - --no-restore + run: dotnet build --configuration Release --no-restore - name: Test - run: > - dotnet test - --configuration Release - --no-build - --collect "Code coverage" + run: dotnet test --configuration Release --no-build - name: Pack run: > @@ -76,10 +79,12 @@ jobs: path: ${{ github.workspace }}/drop/* name: drop - PrivateFeed: + # TODO: remove support for Azure Artifacts once we have migrated all packages to GitHub Packages + AzureArtifacts: runs-on: ubuntu-latest needs: Build - if: ${{ github.event.inputs.private == 'true' }} + name: Publish (Azure Artifacts) + if: ${{ (github.ref == 'refs/heads/main') || startsWith(github.ref, 'refs/tags') }} steps: - uses: actions/download-artifact@v4 @@ -91,21 +96,21 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: '8.x' - source-url: ${{ secrets.PRIVATE_FEED_URL }} + source-url: "https://pkgs.dev.azure.com/tingle/_packaging/tingle/nuget/v3/index.json" env: NUGET_AUTH_TOKEN: ${{ secrets.PRIVATE_FEED_API_KEY }} - - name: Publish to private feed - # if: startsWith(github.ref, 'refs/tags/') + - name: Publish to pkgs.dev.azure.com/tingle run: > dotnet nuget push "${{ github.workspace }}/drop/*" -k ${{ secrets.PRIVATE_FEED_API_KEY }} --skip-duplicate - PublicFeed: + GitHubPackages: runs-on: ubuntu-latest needs: Build - if: ${{ github.event.inputs.public == 'true' }} + name: Publish (GitHub Packages) + if: ${{ (github.ref == 'refs/heads/main') || startsWith(github.ref, 'refs/tags') }} steps: - uses: actions/download-artifact@v4 @@ -117,12 +122,38 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: '8.x' + source-url: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json + env: + NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish to nuget.pkg.github.com + run: > + dotnet nuget push "${{ github.workspace }}/drop/*" + -k ${{ secrets.GITHUB_TOKEN }} + --skip-duplicate + + NugetOrg: + runs-on: ubuntu-latest + needs: [AzureArtifacts, GitHubPackages] + name: Publish (Nuget.org) + if: ${{ startsWith(github.ref, 'refs/tags') }} + + steps: + - uses: actions/download-artifact@v4 + with: + name: drop + path: ${{ github.workspace }}/drop + + - name: Setup .NET SDK + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.x source-url: https://api.nuget.org/v3/index.json env: NUGET_AUTH_TOKEN: ${{ secrets.NUGET_API_KEY }} - name: Publish to NuGet.org - # if: startsWith(github.ref, 'refs/tags/') + if: startsWith(github.ref, 'refs/tags/') run: > dotnet nuget push "${{ github.workspace }}/drop/*" -k ${{ secrets.NUGET_API_KEY }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml deleted file mode 100644 index 33a6ba8b..00000000 --- a/.github/workflows/pr.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Validate PR - -on: - pull_request: - branches: - - main - paths-ignore: - - README.md - - LICENSE - - CHANGELOG.md - - docs/** - -jobs: - Build: - runs-on: ubuntu-latest - env: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup .NET SDK - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 8.x - - - name: Install dependencies - run: dotnet restore - - - name: Build - run: > - dotnet build - --configuration Release - --no-restore - - - name: Test - run: > - dotnet test - --configuration Release - --no-build - --collect "Code coverage" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 39600593..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: Build and Publish - -on: - push: - # branches: - # - main - tags: - - '*' - paths-ignore: - - README.md - - LICENSE - - CHANGELOG.md - - docs/** - -jobs: - Build: - runs-on: ubuntu-latest - env: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Required for GitVersion - - - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v0 - with: - versionSpec: '5.x' - - - name: Determine Version - uses: gittools/actions/gitversion/execute@v0 - id: gitversion - with: - useConfigFile: true - - - name: Setup .NET SDK - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 8.x - source-url: https://api.nuget.org/v3/index.json - env: - NUGET_AUTH_TOKEN: ${{ secrets.NUGET_API_KEY }} - - - name: Install dependencies - run: dotnet restore - - - name: Build - run: > - dotnet build - --configuration Release - --no-restore - - - name: Test - run: > - dotnet test - --configuration Release - --no-build - --collect "Code coverage" - - - name: Pack - run: > - dotnet pack - --configuration Release - --no-build - --output ${{ github.workspace }}/drop - -p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersion }} - -p:VersionPrefix=${{ steps.gitversion.outputs.nuGetVersion }} - - - name: Publish Artifact - uses: actions/upload-artifact@v4 - with: - path: ${{ github.workspace }}/drop/* - name: drop - - - name: Publish to NuGet.org - if: startsWith(github.ref, 'refs/tags/') - run: > - dotnet nuget push "${{ github.workspace }}/drop/*" - -k ${{ secrets.NUGET_API_KEY }} - --skip-duplicate