Skip to content

Commit a9e8c39

Browse files
authored
Plugin API versioning (#604)
* separate versioning of PluginAPI * add version in PluginAPI csproj * add PluginAPI build script
1 parent 65f9602 commit a9e8c39

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

.github/workflows/main.yml

+18-15
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Build and Test
33
on:
44
push:
55
branches: ["master", "feature/*"]
6-
tags: ["v*"]
6+
tags: ["v*", "plugin-api-v*"]
77
pull_request_target:
88
branches: ["master"]
99

@@ -19,6 +19,7 @@ jobs:
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

src/NuGetForUnity.PluginAPI/NuGetForUnity.PluginAPI.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<PackageTags>Unity</PackageTags>
1515
<Title>NuGetForUnity PluginAPI</Title>
1616
<Description>The API used to develop plug-ins for NuGetForUnity.</Description>
17+
<Version>1.0.0</Version>
1718
</PropertyGroup>
1819
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition=" '$(Configuration)' == 'Release' ">
1920
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(MSBuildThisFileDirectory)..\NuGetForUnity\Editor\PluginAPI\" />

tools/build-plugin-api.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dotnet publish --configuration Release $PSScriptRoot/../src/NuGetForUnity.PluginAPI/NuGetForUnity.PluginAPI.csproj

0 commit comments

Comments
 (0)