|
1 | 1 | name: CI
|
2 | 2 |
|
3 |
| -on: [push, pull_request] |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + is_stable_build: |
| 9 | + description: Use a version number indicating this is a stable release |
| 10 | + required: true |
| 11 | + default: "false" |
| 12 | + release: |
| 13 | + description: Create a release |
| 14 | + required: true |
| 15 | + default: "false" |
| 16 | + branches: |
| 17 | + - main |
| 18 | + - release/* |
4 | 19 |
|
5 | 20 | env:
|
| 21 | + IS_STABLE_BUILD: ${{ github.event.inputs.is_stable_build }} |
6 | 22 | BUILD_NUMBER: ${{ github.run_number }}
|
7 | 23 |
|
8 | 24 | jobs:
|
9 | 25 | build:
|
10 |
| - if: "!contains(github.event.head_commit.message, 'ci skip')" |
| 26 | + if: "!contains(github.event.head_commit.message, 'ci skip') || github.event_name == 'workflow_dispatch'" |
11 | 27 | strategy:
|
12 | 28 | fail-fast: false
|
13 | 29 | matrix:
|
14 | 30 | os: [windows-latest, ubuntu-latest, macos-latest]
|
15 | 31 |
|
16 | 32 | runs-on: ${{ matrix.os }}
|
17 | 33 |
|
| 34 | + outputs: |
| 35 | + package_version: ${{ steps.build_script.outputs.package_version }} |
| 36 | + |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@v2 |
| 39 | + - name: Setup .NET Core 2.1 |
| 40 | + uses: actions/setup-dotnet@v1 |
| 41 | + with: |
| 42 | + dotnet-version: "2.1.x" |
| 43 | + - name: Setup .NET Core 3.1 |
| 44 | + uses: actions/setup-dotnet@v1 |
| 45 | + with: |
| 46 | + dotnet-version: "3.1.x" |
| 47 | + - name: Setup .NET 5 |
| 48 | + uses: actions/setup-dotnet@v1 |
| 49 | + with: |
| 50 | + dotnet-version: "5.0.x" |
| 51 | + - name: Run build script |
| 52 | + id: build_script |
| 53 | + run: ./build.ps1 -ci |
| 54 | + - uses: actions/upload-artifact@v2 |
| 55 | + if: ${{ matrix.os == 'windows-latest' }} |
| 56 | + with: |
| 57 | + name: packages |
| 58 | + path: artifacts/ |
| 59 | + if-no-files-found: error |
| 60 | + - uses: codecov/codecov-action@v1 |
| 61 | + with: |
| 62 | + name: unittests-${{ matrix.os }} |
| 63 | + fail_ci_if_error: true |
| 64 | + release: |
| 65 | + if: "github.event.inputs.release" |
| 66 | + needs: build |
| 67 | + runs-on: windows-latest |
| 68 | + env: |
| 69 | + PACKAGE_VERSION: ${{ needs.build.outputs.package_version }} |
18 | 70 | steps:
|
19 |
| - - uses: actions/checkout@v2 |
20 |
| - - name: Setup .NET Core 2.1 |
21 |
| - uses: actions/setup-dotnet@v1 |
22 |
| - with: |
23 |
| - dotnet-version: '2.1.x' |
24 |
| - - name: Setup .NET Core 3.1 |
25 |
| - uses: actions/setup-dotnet@v1 |
26 |
| - with: |
27 |
| - dotnet-version: '3.1.x' |
28 |
| - - name: Setup .NET 5 |
29 |
| - uses: actions/setup-dotnet@v1 |
30 |
| - with: |
31 |
| - dotnet-version: '5.0.x' |
32 |
| - - name: Run build script |
33 |
| - run: ./build.ps1 -ci |
34 |
| - - uses: actions/upload-artifact@v2 |
35 |
| - if: ${{ matrix.os == 'windows-latest' }} |
36 |
| - with: |
37 |
| - name: packages |
38 |
| - path: artifacts/ |
39 |
| - - uses: codecov/codecov-action@v1 |
40 |
| - with: |
41 |
| - name: unittests-${{ matrix.os }} |
42 |
| - fail_ci_if_error: true |
| 71 | + - run: echo "Releasing ${{ env.PACKAGE_VERSION }}" |
| 72 | + - name: Setup NuGet |
| 73 | + uses: NuGet/setup-nuget@v1 |
| 74 | + with: |
| 75 | + nuget-version: latest |
| 76 | + - uses: actions/download-artifact@v2 |
| 77 | + with: |
| 78 | + name: packages |
| 79 | + path: packages |
| 80 | + - name: Configure GitHub NuGet registry |
| 81 | + run: nuget sources add -name github -source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json -username ${{ github.repository_owner }} -password ${{ secrets.GITHUB_TOKEN }} |
| 82 | + - name: Push to GitHub package registry |
| 83 | + run: nuget push packages\*.nupkg -ApiKey ${{ secrets.GITHUB_TOKEN }} -Source github |
| 84 | + - name: Push to NuGet.org |
| 85 | + run: nuget push packages\*.nupkg -ApiKey ${{ secrets.NUGET_API_KEY }} -Source https://nuget.org |
| 86 | + - name: Create GitHub release |
| 87 | + uses: softprops/action-gh-release@v1 |
| 88 | + env: |
| 89 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 90 | + with: |
| 91 | + name: ${{ env.PACKAGE_VERSION }} |
| 92 | + tag_name: v${{ env.PACKAGE_VERSION }} |
| 93 | + body: | |
| 94 | + See changes in https://github.com/natemcmaster/CommandLineUtils/blob/main/CHANGELOG.md |
| 95 | +
|
| 96 | + Packages have been posted to these feeds: |
| 97 | +
|
| 98 | + #### NuGet.org |
| 99 | + https://nuget.org/packages/McMaster.Extensions.CommandLineUtils/${{ env.PACKAGE_VERSION }} |
| 100 | + https://nuget.org/packages/McMaster.Extensions.Hosting.CommandLine/${{ env.PACKAGE_VERSION }} |
| 101 | +
|
| 102 | + #### GitHub Package Registry |
| 103 | + https://github.com/natemcmaster?tab=packages&repo_name=CommandLineUtils |
| 104 | +
|
| 105 | + draft: true |
| 106 | + prerelease: ${{ env.IS_STABLE_BUILD == 'false' }} # Example: v3.1.0-beta |
| 107 | + files: packages/* |
0 commit comments