Package version selection #189
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Test | |
on: | |
push: | |
branches: ["master", "feature/*"] | |
tags: ["v*"] | |
pull_request_target: | |
branches: ["master"] | |
permissions: | |
actions: read | |
checks: write | |
contents: read | |
statuses: write | |
jobs: | |
determineVersionNumber: | |
name: Determine Version Number | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.generateVersion.outputs.version }} | |
steps: | |
- name: Checkout action file | |
uses: Bhacaz/checkout-files@v2 | |
with: | |
files: .github/actions/checkout/action.yml | |
- name: Checkout | |
uses: ./.github/actions/checkout | |
- name: Generate Version Number | |
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)" | |
} else { | |
$version = "$($Matches.major).$($Matches.minor).$([int]::Parse($Matches.patch) + 1)-dev.$($Matches.offset)+$($Matches.hash)" | |
} | |
} else { | |
$version = "0.0.0-dev.$(git rev-list HEAD --count)+$describe" | |
} | |
Write-Host "Generated version number: $version" | |
echo "version=$($version)" >> $Env:GITHUB_OUTPUT | |
buildOnLinux: | |
name: Build on linux | |
runs-on: ubuntu-latest | |
needs: [determineVersionNumber] | |
steps: | |
- name: Checkout action file | |
uses: Bhacaz/checkout-files@v2 | |
with: | |
files: .github/actions/checkout/action.yml | |
- name: Checkout | |
uses: ./.github/actions/checkout | |
- name: Create DLL | |
uses: ./.github/actions/create-dll | |
with: | |
version: ${{ needs.determineVersionNumber.outputs.version }} | |
- name: Upload NuGetForUnity.dll | |
uses: actions/upload-artifact@v3 | |
with: | |
name: NuGetForUnity.dll | |
path: ./src/NuGetForUnity.CreateDll/bin/Release/NugetForUnity.dll | |
if-no-files-found: error | |
packageOnLinux: | |
name: Create .unitypackage on linux | |
runs-on: ubuntu-latest | |
needs: [buildOnLinux, determineVersionNumber] | |
steps: | |
- name: Checkout action file | |
uses: Bhacaz/checkout-files@v2 | |
with: | |
files: .github/actions/checkout/action.yml | |
- name: Checkout | |
uses: ./.github/actions/checkout | |
- name: Download NuGetForUnity.dll | |
uses: actions/download-artifact@v3 | |
with: | |
name: NuGetForUnity.dll | |
path: ./src/NuGetForUnity.Packager/Assets/NuGet/Editor | |
- name: Unity - Packager (build .unitypackage) | |
uses: game-ci/[email protected] | |
env: | |
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} | |
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} | |
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} | |
with: | |
# Platform that the build should target. | |
targetPlatform: StandaloneWindows64 | |
# Version of unity to use for building the project. Use "auto" to get from your ProjectSettings/ProjectVersion.txt | |
unityVersion: auto | |
# Relative path to the project to be built. | |
projectPath: ./src/NuGetForUnity.Packager | |
# Path to a Namespace.Class.StaticMethod to run to perform the build. | |
buildMethod: NugetForUnity.Export.Execute | |
# custom versioning | |
versioning: "Custom" | |
version: ${{ needs.determineVersionNumber.outputs.version }} | |
- name: Upload UnityPackage | |
uses: actions/upload-artifact@v3 | |
with: | |
name: NuGetForUnity.${{ needs.determineVersionNumber.outputs.version }}.unitypackage | |
path: ./src/NuGetForUnity.Packager/NugetForUnity.unitypackage | |
if-no-files-found: error | |
packageTool: | |
name: Pack .NET Core Global Tool | |
runs-on: ubuntu-latest | |
needs: [determineVersionNumber] | |
steps: | |
- name: Checkout action file | |
uses: Bhacaz/checkout-files@v2 | |
with: | |
files: .github/actions/checkout/action.yml | |
- name: Checkout | |
uses: ./.github/actions/checkout | |
- name: Setup dotnet | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: "7.0.x" | |
- name: Build and pack | |
run: >- | |
dotnet pack ./src/NuGetForUnity.Cli/NuGetForUnity.Cli.csproj --nologo -c Release -o . | |
-p:Version=${{ needs.determineVersionNumber.outputs.version }} -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg | |
-p:ContinuousIntegrationBuild=true | |
- name: publish the NuGetForUnity.Cli NuGet package | |
if: github.ref_type == 'tag' | |
run: >- | |
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: Upload NuGetForUnity.Cli NuGet package | |
uses: actions/upload-artifact@v3 | |
with: | |
name: NuGetForUnity.Cli.${{ needs.determineVersionNumber.outputs.version }}.nupkg | |
path: ./NuGetForUnity.Cli.*.nupkg | |
if-no-files-found: error | |
testUbuntu: | |
name: Test on linux | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout action file | |
uses: Bhacaz/checkout-files@v2 | |
with: | |
files: .github/actions/checkout/action.yml | |
- name: Checkout | |
uses: ./.github/actions/checkout | |
- name: Unity - Run tests | |
uses: game-ci/[email protected] | |
env: | |
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} | |
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} | |
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} | |
with: | |
projectPath: src/NuGetForUnity.Tests | |
githubToken: ${{ secrets.GITHUB_TOKEN }} | |
testMode: EditMode | |
runTestProjectsOnLinux: | |
name: Run test projects on linux | |
runs-on: ubuntu-latest | |
needs: [packageTool, determineVersionNumber] | |
strategy: | |
fail-fast: false | |
matrix: | |
projectPath: | |
- src/TestProjects/ImportAndUseNuGetPackages | |
- src/TestProjects/ImportAndUseNuGetPackages2021 | |
steps: | |
- name: Checkout action file | |
uses: Bhacaz/checkout-files@v2 | |
with: | |
files: .github/actions/checkout/action.yml | |
- name: Checkout | |
uses: ./.github/actions/checkout | |
- name: Download NuGetForUnity.Cli NuGet package | |
uses: actions/download-artifact@v3 | |
with: | |
name: NuGetForUnity.Cli.${{ needs.determineVersionNumber.outputs.version }}.nupkg | |
path: . | |
- name: Install NuGetForUnity.Cli Tool | |
run: dotnet tool install --add-source . NuGetForUnity.Cli --version ${{ needs.determineVersionNumber.outputs.version }} | |
- name: Restore NuGet packages using NuGetForUnity.Cli | |
run: dotnet nugetforunity restore '${{ matrix.projectPath }}' | |
- name: Unity - Build project ${{ matrix.projectPath }} | |
uses: game-ci/[email protected] | |
env: | |
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} | |
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} | |
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} | |
with: | |
# Platform that the build should target. | |
targetPlatform: StandaloneWindows64 | |
# Relative path to the project to be built. | |
projectPath: ${{ matrix.projectPath }} | |
# disable versioning | |
versioning: "None" |