|
| 1 | +name: Publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - v* |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + runs-on: windows-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: Extract version from tag |
| 14 | + uses: nowsprinting/check-version-format-action@v3 |
| 15 | + id: version |
| 16 | + with: |
| 17 | + prefix: 'v' |
| 18 | + |
| 19 | + - name: Invalid version tag |
| 20 | + if: steps.version.outputs.is_valid != 'true' |
| 21 | + run: | |
| 22 | + echo "Version tag format invalid: ${{ steps.version.outputs.full }}" |
| 23 | + exit 1 |
| 24 | +
|
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@v3 |
| 27 | + with: |
| 28 | + fetch-depth: 0 # Mandatory to use exact version from tag action |
| 29 | + |
| 30 | + - name: Setup .NET |
| 31 | + uses: actions/setup-dotnet@v3 |
| 32 | + with: |
| 33 | + dotnet-version: 8.0.x |
| 34 | + |
| 35 | + - name: Check version |
| 36 | + # assert version match with project version so only pre-release label can be changed based on release tag |
| 37 | + run: dotnet build -t:CheckVersion -c Release -p BuildVersion="${{ steps.version.outputs.major_without_prefix }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }}" |
| 38 | + |
| 39 | + - name: Set version info |
| 40 | + run: | |
| 41 | + $VersionPrefix="${{ steps.version.outputs.major_without_prefix }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }}" |
| 42 | + $VersionSuffix="${{ steps.version.outputs.prerelease }}" |
| 43 | + $IsStable="${{ steps.version.outputs.is_stable }}" |
| 44 | + if ( -not $VersionSuffix ) { |
| 45 | + $Version=$VersionPrefix |
| 46 | + } else { |
| 47 | + $Version="$VersionPrefix-$VersionSuffix" |
| 48 | + } |
| 49 | + echo "VersionPrefix=$VersionPrefix" >> $Env:GITHUB_ENV |
| 50 | + echo "VersionSuffix=$VersionSuffix" >> $Env:GITHUB_ENV |
| 51 | + echo "Version=$Version" >> $Env:GITHUB_ENV |
| 52 | + echo "IsStable=$IsStable" >> $Env:GITHUB_ENV |
| 53 | + echo "Create release: v$Version" |
| 54 | +
|
| 55 | + - name: Build |
| 56 | + run: dotnet test Aqua.sln -c Release /bl |
| 57 | + |
| 58 | + - name: Upload build log |
| 59 | + uses: actions/upload-artifact@v3 |
| 60 | + with: |
| 61 | + name: msbuild_log |
| 62 | + path: msbuild.binlog |
| 63 | + if-no-files-found: error |
| 64 | + |
| 65 | + - name: Upload packages |
| 66 | + uses: actions/upload-artifact@v3 |
| 67 | + with: |
| 68 | + name: nuget_packages |
| 69 | + path: artifacts |
| 70 | + if-no-files-found: error |
| 71 | + |
| 72 | + - name: Publish packages |
| 73 | + env: |
| 74 | + MYGET_AUTH_TOKEN: ${{ secrets.MYGET_AUTH_TOKEN }} |
| 75 | + NUGET_AUTH_TOKEN: ${{ secrets.NUGET_AUTH_TOKEN }} |
| 76 | + run: | |
| 77 | + dotnet nuget push artifacts\*.nupkg -k "$env:MYGET_AUTH_TOKEN" -s https://www.myget.org/F/aqua/api/v3/index.json |
| 78 | + dotnet nuget push artifacts\*.nupkg -k "$env:NUGET_AUTH_TOKEN" -s https://api.nuget.org/v3/index.json |
0 commit comments