Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin API versioning #604

Merged
merged 4 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build and Test
on:
push:
branches: ["master", "feature/*"]
tags: ["v*"]
tags: ["v*", "plugin-api-v*"]
pull_request_target:
branches: ["master"]

Expand All @@ -19,6 +19,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.generateVersion.outputs.version }}
plugin-api-version: ${{ steps.generateVersion.outputs.plugin-api-version }}

steps:
- name: Checkout action file
Expand All @@ -33,18 +34,20 @@ jobs:
id: generateVersion
shell: pwsh
run: |
$describe = git describe --long --tags --always
if ($describe -match '^v?(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)-(?<offset>\d+)-g(?<hash>[a-f0-9]+)$') {
if ([int]::Parse($Matches.offset) -eq 0) {
$version = "$($Matches.major).$($Matches.minor).$($Matches.patch)"
foreach ($tagPrefix in @("", "plugin-api-")) {
$describe = git describe --long --tags --always --match "$($tagPrefix)v*"
if ($describe -match "^$($tagPrefix)v?(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)-(?<offset>\d+)-g(?<hash>[a-f0-9]+)`$") {
if ([int]::Parse($Matches.offset) -eq 0) {
$version = "$($Matches.major).$($Matches.minor).$($Matches.patch)"
} else {
$version = "$($Matches.major).$($Matches.minor).$([int]::Parse($Matches.patch) + 1)-dev.$($Matches.offset)+$($Matches.hash)"
}
} else {
$version = "$($Matches.major).$($Matches.minor).$([int]::Parse($Matches.patch) + 1)-dev.$($Matches.offset)+$($Matches.hash)"
$version = "0.0.0-dev.$(git rev-list HEAD --count)+$describe"
}
} else {
$version = "0.0.0-dev.$(git rev-list HEAD --count)+$describe"
Write-Host "Generated version number$(if ($tagPrefix -eq '') { '' } else { " $tagPrefix" } ): $version"
echo "$($tagPrefix)version=$($version)" >> $Env:GITHUB_OUTPUT
}
Write-Host "Generated version number: $version"
echo "version=$($version)" >> $Env:GITHUB_OUTPUT

buildOnLinux:
name: Build on Linux
Expand Down Expand Up @@ -176,19 +179,19 @@ jobs:
- name: Build and pack NuGetForUnity.PluginAPI
run: >-
dotnet pack ./src/NuGetForUnity.PluginAPI/NuGetForUnity.PluginAPI.csproj --nologo -c Release -o .
-p:Version=${{ needs.determineVersionNumber.outputs.version }} -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
-p:Version=${{ needs.determineVersionNumber.outputs.plugin-api-version }} -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
-p:ContinuousIntegrationBuild=true

- name: publish the NuGetForUnity.Cli NuGet package
if: github.ref_type == 'tag'
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
run: >-
dotnet nuget push ./NuGetForUnity.Cli.${{ needs.determineVersionNumber.outputs.version }}.nupkg --api-key ${{secrets.NUGET_API_TOKEN}}
dotnet nuget push ./NuGetForUnity.Cli.${{ needs.determineVersionNumber.outputs.version }}.nupkg --api-key ${{ secrets.NUGET_API_TOKEN }}
--source https://api.nuget.org/v3/index.json

- name: publish the NuGetForUnity.PluginAPI NuGet package
if: github.ref_type == 'tag'
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'plugin-api-v')
run: >-
dotnet nuget push ./NuGetForUnity.PluginAPI.${{ needs.determineVersionNumber.outputs.version }}.nupkg --api-key ${{secrets.NUGET_API_TOKEN}}
dotnet nuget push ./NuGetForUnity.PluginAPI.${{ needs.determineVersionNumber.outputs.plugin-api-version }}.nupkg --api-key ${{ secrets.NUGET_API_TOKEN }}
--source https://api.nuget.org/v3/index.json

- name: Upload NuGet packages
Expand Down
1 change: 1 addition & 0 deletions src/NuGetForUnity.PluginAPI/NuGetForUnity.PluginAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<PackageTags>Unity</PackageTags>
<Title>NuGetForUnity PluginAPI</Title>
<Description>The API used to develop plug-ins for NuGetForUnity.</Description>
<Version>1.0.0</Version>
</PropertyGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition=" '$(Configuration)' == 'Release' ">
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(MSBuildThisFileDirectory)..\NuGetForUnity\Editor\PluginAPI\" />
Expand Down
1 change: 1 addition & 0 deletions tools/build-plugin-api.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dotnet publish --configuration Release $PSScriptRoot/../src/NuGetForUnity.PluginAPI/NuGetForUnity.PluginAPI.csproj