Skip to content

Commit

Permalink
Merge pr, preview, and release workflows into one and publish to GitH…
Browse files Browse the repository at this point in the history
…ub packages
  • Loading branch information
mburumaxwell committed Feb 27, 2024
1 parent 0b4e2cc commit deb320d
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 155 deletions.
93 changes: 62 additions & 31 deletions .github/workflows/preview.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
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

jobs:
Build:
runs-on: ubuntu-latest
name: Build

steps:
- name: Checkout
Expand Down Expand Up @@ -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: >
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 }}
Expand Down
42 changes: 0 additions & 42 deletions .github/workflows/pr.yml

This file was deleted.

82 changes: 0 additions & 82 deletions .github/workflows/release.yml

This file was deleted.

0 comments on commit deb320d

Please sign in to comment.