@@ -3,7 +3,7 @@ name: Build and Test
33on :
44 push :
55 branches : ["master", "feature/*"]
6- tags : ["v*"]
6+ tags : ["v*", "plugin-api-v*" ]
77 pull_request_target :
88 branches : ["master"]
99
1919 runs-on : ubuntu-latest
2020 outputs :
2121 version : ${{ steps.generateVersion.outputs.version }}
22+ plugin-api-version : ${{ steps.generateVersion.outputs.plugin-api-version }}
2223
2324 steps :
2425 - name : Checkout action file
@@ -33,18 +34,20 @@ jobs:
3334 id : generateVersion
3435 shell : pwsh
3536 run : |
36- $describe = git describe --long --tags --always
37- if ($describe -match '^v?(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)-(?<offset>\d+)-g(?<hash>[a-f0-9]+)$') {
38- if ([int]::Parse($Matches.offset) -eq 0) {
39- $version = "$($Matches.major).$($Matches.minor).$($Matches.patch)"
37+ foreach ($tagPrefix in @("", "plugin-api-")) {
38+ $describe = git describe --long --tags --always --match "$($tagPrefix)v*"
39+ if ($describe -match "^$($tagPrefix)v?(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)-(?<offset>\d+)-g(?<hash>[a-f0-9]+)`$") {
40+ if ([int]::Parse($Matches.offset) -eq 0) {
41+ $version = "$($Matches.major).$($Matches.minor).$($Matches.patch)"
42+ } else {
43+ $version = "$($Matches.major).$($Matches.minor).$([int]::Parse($Matches.patch) + 1)-dev.$($Matches.offset)+$($Matches.hash)"
44+ }
4045 } else {
41- $version = "$($Matches.major).$($Matches.minor).$([int]::Parse($Matches.patch) + 1)-dev.$($Matches.offset )+$($Matches.hash) "
46+ $version = "0.0.0-dev.$(git rev-list HEAD --count )+$describe "
4247 }
43- } else {
44- $ version = "0.0.0-dev.$(git rev-list HEAD --count)+$describe"
48+ Write-Host "Generated version number$(if ($tagPrefix -eq '') { '' } else { " $tagPrefix" } ): $version"
49+ echo "$($tagPrefix) version=$($version)" >> $Env:GITHUB_OUTPUT
4550 }
46- Write-Host "Generated version number: $version"
47- echo "version=$($version)" >> $Env:GITHUB_OUTPUT
4851
4952 buildOnLinux :
5053 name : Build on Linux
@@ -176,19 +179,19 @@ jobs:
176179 - name : Build and pack NuGetForUnity.PluginAPI
177180 run : >-
178181 dotnet pack ./src/NuGetForUnity.PluginAPI/NuGetForUnity.PluginAPI.csproj --nologo -c Release -o .
179- -p:Version=${{ needs.determineVersionNumber.outputs.version }} -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
182+ -p:Version=${{ needs.determineVersionNumber.outputs.plugin-api- version }} -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
180183 -p:ContinuousIntegrationBuild=true
181184
182185 - name : publish the NuGetForUnity.Cli NuGet package
183- if : github.ref_type == 'tag'
186+ if : github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
184187 run : >-
185- dotnet nuget push ./NuGetForUnity.Cli.${{ needs.determineVersionNumber.outputs.version }}.nupkg --api-key ${{secrets.NUGET_API_TOKEN}}
188+ dotnet nuget push ./NuGetForUnity.Cli.${{ needs.determineVersionNumber.outputs.version }}.nupkg --api-key ${{ secrets.NUGET_API_TOKEN }}
186189 --source https://api.nuget.org/v3/index.json
187190
188191 - name : publish the NuGetForUnity.PluginAPI NuGet package
189- if : github.ref_type == 'tag'
192+ if : github.ref_type == 'tag' && startsWith(github.ref_name, 'plugin-api-v')
190193 run : >-
191- dotnet nuget push ./NuGetForUnity.PluginAPI.${{ needs.determineVersionNumber.outputs.version }}.nupkg --api-key ${{secrets.NUGET_API_TOKEN}}
194+ dotnet nuget push ./NuGetForUnity.PluginAPI.${{ needs.determineVersionNumber.outputs.plugin-api- version }}.nupkg --api-key ${{ secrets.NUGET_API_TOKEN }}
192195 --source https://api.nuget.org/v3/index.json
193196
194197 - name : Upload NuGet packages
0 commit comments