|
| 1 | +name: Stravaig PROJECT NAME HERE |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + |
| 7 | + paths-ignore: |
| 8 | + - 'README.md' |
| 9 | + - 'Example/**' |
| 10 | + - '.vscode/**' |
| 11 | + - '.gitignore' |
| 12 | + - 'contributors.md' |
| 13 | + - 'release-notes/**' |
| 14 | + - '.github/PULL_REQUEST_TEMPLATE/**' |
| 15 | + - 'src/.idea/**' |
| 16 | + |
| 17 | + pull_request: |
| 18 | + types: [assigned, opened, synchronize, reopened] |
| 19 | + paths-ignore: |
| 20 | + - 'README.md' |
| 21 | + - 'Example/**' |
| 22 | + - '.vscode/**' |
| 23 | + - '.gitignore' |
| 24 | + |
| 25 | + workflow_dispatch: |
| 26 | + inputs: |
| 27 | + isPublic: |
| 28 | + description: 'Is Public Release' |
| 29 | + required: false |
| 30 | + default: "false" |
| 31 | + isPreview: |
| 32 | + description: 'Is Preview Release' |
| 33 | + required: false |
| 34 | + default: "true" |
| 35 | + |
| 36 | +jobs: |
| 37 | + build: |
| 38 | + name: Build, Test, and Release |
| 39 | + runs-on: ubuntu-latest |
| 40 | + env: |
| 41 | + STRAVAIG_SOLUTION: src/XXXX.sln |
| 42 | + STRAVAIG_TESTS: XXXX.Tests |
| 43 | + STRAVAIG_PROJECT: XXXX |
| 44 | + |
| 45 | + steps: |
| 46 | + - name: Check out code |
| 47 | + uses: actions/checkout@v3 |
| 48 | + with: |
| 49 | + fetch-depth: 0 |
| 50 | + |
| 51 | + - name: Set version number |
| 52 | + shell: pwsh |
| 53 | + run: ./Set-Version.ps1 -IsPublic "${{ github.event.inputs.isPublic }}" -IsPreview "${{ github.event.inputs.isPreview }}" |
| 54 | + |
| 55 | + - name: Display workflow state |
| 56 | + run: | |
| 57 | + echo "GITHUB_SHA: $GITHUB_SHA" |
| 58 | + echo "Solution: $STRAVAIG_SOLUTION" |
| 59 | + echo "Project: $STRAVAIG_PROJECT" |
| 60 | + echo "Tests: $STRAVAIG_TESTS" |
| 61 | + echo "Package version: $STRAVAIG_PACKAGE_VERSION" |
| 62 | + echo "Version Suffix: $STRAVAIG_PACKAGE_VERSION_SUFFIX" |
| 63 | + echo "Full Version: $STRAVAIG_PACKAGE_FULL_VERSION" |
| 64 | + echo "Publish To NuGet: $STRAVAIG_PUBLISH_TO_NUGET" |
| 65 | + echo "Is Preview: $STRAVAIG_IS_PREVIEW" |
| 66 | + echo "Is Stable: $STRAVAIG_IS_STABLE" |
| 67 | + |
| 68 | + - uses: actions/setup-dotnet@v3 |
| 69 | + name: Setup .NET 6.0 and 7.0 |
| 70 | + with: |
| 71 | + dotnet-version: | |
| 72 | + 6.0.x |
| 73 | + 7.0.x |
| 74 | + |
| 75 | + - name: .NET State |
| 76 | + run: dotnet --info |
| 77 | + |
| 78 | + - name: Build Solution |
| 79 | + run: dotnet build $STRAVAIG_SOLUTION --configuration Release |
| 80 | + |
| 81 | + - name: Run Tests |
| 82 | + run: dotnet test src/$STRAVAIG_TESTS/$STRAVAIG_TESTS.csproj --configuration Release |
| 83 | + |
| 84 | + - name: Package Preview Release |
| 85 | + if: ${{ env.STRAVAIG_IS_PREVIEW == 'true' }} |
| 86 | + run: dotnet pack ./src/$STRAVAIG_PROJECT/$STRAVAIG_PROJECT.csproj --configuration Release --output ./out --include-symbols --include-source /p:VersionPrefix="$STRAVAIG_PACKAGE_VERSION" --version-suffix "$STRAVAIG_PACKAGE_VERSION_SUFFIX" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg |
| 87 | + |
| 88 | + - name: Package Stable Release |
| 89 | + if: ${{ env.STRAVAIG_IS_STABLE == 'true' }} |
| 90 | + run: dotnet pack ./src/$STRAVAIG_PROJECT/$STRAVAIG_PROJECT.csproj --configuration Release --output ./out --include-symbols --include-source /p:VersionPrefix="$STRAVAIG_PACKAGE_VERSION" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg |
| 91 | + |
| 92 | + - name: Push package to NuGet |
| 93 | + if: ${{ env.STRAVAIG_PUBLISH_TO_NUGET == 'true' }} |
| 94 | + shell: pwsh |
| 95 | + run: | |
| 96 | + Get-ChildItem ./out/*.nupkg | ForEach-Object { |
| 97 | + $name = $_.FullName; |
| 98 | + Write-Output "Pushing $name"; |
| 99 | + dotnet nuget push "$name" --api-key ${{ secrets.STRAVAIG_NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json |
| 100 | + } |
| 101 | +
|
| 102 | + - name: List Contributors |
| 103 | + shell: pwsh |
| 104 | + run: ./list-contributors.ps1 -HideSummaryAwards |
| 105 | + |
| 106 | + - name: Build Release Notes |
| 107 | + shell: pwsh |
| 108 | + run: ./build-release-notes.ps1 |
| 109 | + |
| 110 | + - name: Archive Simulated Release Information |
| 111 | + if: ${{ env.STRAVAIG_PUBLISH_TO_NUGET == 'false' }} |
| 112 | + uses: actions/upload-artifact@v3 |
| 113 | + with: |
| 114 | + name: simulated-release-information |
| 115 | + path: | |
| 116 | + contributors.md |
| 117 | + release-notes/full-release-notes.md |
| 118 | + release-notes/release-notes-${{ env.STRAVAIG_PACKAGE_FULL_VERSION }}.md |
| 119 | + out/** |
| 120 | + retention-days: 7 |
| 121 | + |
| 122 | + - name: Archive Release Notes |
| 123 | + if: ${{ env.STRAVAIG_PUBLISH_TO_NUGET == 'true' }} |
| 124 | + uses: actions/upload-artifact@v3 |
| 125 | + with: |
| 126 | + name: release-information |
| 127 | + path: | |
| 128 | + contributors.md |
| 129 | + release-notes/full-release-notes.md |
| 130 | + release-notes/release-notes-${{ env.STRAVAIG_PACKAGE_FULL_VERSION }}.md |
| 131 | + out/** |
| 132 | + |
| 133 | + - name: Create Release |
| 134 | + if: ${{ env.STRAVAIG_PUBLISH_TO_NUGET == 'true' }} |
| 135 | + shell: pwsh |
| 136 | + env: |
| 137 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 138 | + run: | |
| 139 | + $assets = @(); |
| 140 | + $assets += "./out/*.nupkg" |
| 141 | + $assets += "./out/*.snupkg" |
| 142 | + $assets += "LICENSE" |
| 143 | + $assets += "contributors.md" |
| 144 | + $assets += "README.md" |
| 145 | + $assets += "./release-notes/release-notes-${{ env.STRAVAIG_PACKAGE_FULL_VERSION }}.md" |
| 146 | + ./Create-Release.ps1 -NotesFile "./release-body.md" -Assets $assets |
| 147 | + |
| 148 | + - name: Bump version |
| 149 | + #IF Publishing & Stable release |
| 150 | + if: ${{ env.STRAVAIG_PUBLISH_TO_NUGET == 'true' && env.STRAVAIG_IS_STABLE == 'true' }} |
| 151 | + shell: pwsh |
| 152 | + run: ./Bump-Version.ps1 -BumpPatch |
| 153 | + |
| 154 | + - name: Reset WIP release notes |
| 155 | + #IF Publishing & Stable release |
| 156 | + if: ${{ env.STRAVAIG_PUBLISH_TO_NUGET == 'true' && env.STRAVAIG_IS_STABLE == 'true' }} |
| 157 | + shell: pwsh |
| 158 | + run: ./Reset-WipReleaseNotes.ps1 |
| 159 | + |
| 160 | + - name: Update Docs |
| 161 | + #IF Publishing & Stable release |
| 162 | + if: ${{ env.STRAVAIG_PUBLISH_TO_NUGET == 'true' && env.STRAVAIG_IS_STABLE == 'true' }} |
| 163 | + shell: pwsh |
| 164 | + run: ./Update-Docs.ps1 |
| 165 | + |
| 166 | + - name: Commit post release updates |
| 167 | + #IF Publishing & Stable release |
| 168 | + if: ${{ env.STRAVAIG_PUBLISH_TO_NUGET == 'true' && env.STRAVAIG_IS_STABLE == 'true' }} |
| 169 | + uses: EndBug/add-and-commit@v5 |
| 170 | + with: |
| 171 | + add: ./contributors.md ./release-notes/** ./version.txt docs/** |
| 172 | + author_name: StravaigBot |
| 173 | + |
| 174 | + message: "[bot] Post v${{ env.STRAVAIG_PACKAGE_FULL_VERSION }} Release & Bump Version updates." |
| 175 | + env: |
| 176 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments