Update workflows
parent
d2b10980e3
commit
9a823060a7
|
@ -1,10 +1,10 @@
|
||||||
name: Build and test UPM packages for platforms on all available Unity Versions
|
name: Build and test UPM packages for platforms, all branches except main
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches-ignore:
|
branches-ignore:
|
||||||
- 'release'
|
- 'release'
|
||||||
# Ignore PRs targetting main
|
# Ignore PRs targeting main
|
||||||
|
|
||||||
# Allows you to run this workflow manually from the Actions tab
|
# Allows you to run this workflow manually from the Actions tab
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
@ -14,6 +14,7 @@ concurrency:
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
# Check Unity version required by the package
|
||||||
# Run Unity build unit tests defined in the package for a single version for feature branches
|
# Run Unity build unit tests defined in the package for a single version for feature branches
|
||||||
Run-Partial-Unit-Tests:
|
Run-Partial-Unit-Tests:
|
||||||
name: Run Unity Unit Tests
|
name: Run Unity Unit Tests
|
||||||
|
@ -26,12 +27,4 @@ jobs:
|
||||||
Run-Full-Unit-Tests:
|
Run-Full-Unit-Tests:
|
||||||
name: Run Unity Unit Tests
|
name: Run Unity Unit Tests
|
||||||
if: github.ref == 'refs/heads/development'
|
if: github.ref == 'refs/heads/development'
|
||||||
uses: ./.github/workflows/rununitybuildmultiversion.yml
|
uses: ./.github/workflows/rununitybuildmultiversion.yml
|
||||||
|
|
||||||
# Update the package release version
|
|
||||||
Update-Version:
|
|
||||||
name: Update Package Version
|
|
||||||
uses: ./.github/workflows/tagrelease.yml
|
|
||||||
with:
|
|
||||||
build-target: windows
|
|
||||||
secrets: inherit
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
name: Publish development branch on Merge
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- closed
|
||||||
|
branches:
|
||||||
|
- development
|
||||||
|
# On close of PR targeting development
|
||||||
|
|
||||||
|
# Allows you to run this workflow manually from the Actions tab
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release_on_merge:
|
||||||
|
if: github.event.pull_request.merged == true
|
||||||
|
name: Tag and Publish UPM package
|
||||||
|
uses: ./.github/workflows/upversionandtagrelease.yml
|
||||||
|
with:
|
||||||
|
build-host: ubuntu-latest
|
||||||
|
build-type: pre-release
|
||||||
|
secrets: inherit
|
|
@ -0,0 +1,91 @@
|
||||||
|
name: Publish main branch and increment version
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- closed
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
# Get Version to tag and release the branch, no up-version - [no-ver] included in PR title
|
||||||
|
validate-environment:
|
||||||
|
if: github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'no-ver')
|
||||||
|
name: Get Version from UPM package
|
||||||
|
uses: ./.github/workflows/getpackageversionfrompackage.yml
|
||||||
|
with:
|
||||||
|
build-host: ubuntu-latest
|
||||||
|
|
||||||
|
# Perform tagging
|
||||||
|
release-Package-only:
|
||||||
|
needs: validate-environment
|
||||||
|
name: Release package only, no upversion
|
||||||
|
uses: ./.github/workflows/tagrelease.yml
|
||||||
|
with:
|
||||||
|
build-host: ubuntu-latest
|
||||||
|
version: ${{ needs.validate-environment.outputs.packageversion }}
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
|
# Up version the release and publish major release
|
||||||
|
upversion-major-Package:
|
||||||
|
if: github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'no-ver') == false && contains(github.event.pull_request.title, 'major-release')
|
||||||
|
name: Major Version package and release
|
||||||
|
uses: ./.github/workflows/upversionandtagrelease.yml
|
||||||
|
with:
|
||||||
|
build-host: ubuntu-latest
|
||||||
|
build-type: major
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
|
# Up version the release and publish minor release
|
||||||
|
upversion-minor-Package:
|
||||||
|
if: github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'no-ver') == false && contains(github.event.pull_request.title, 'minor-release')
|
||||||
|
name: Minor Version package and release
|
||||||
|
uses: ./.github/workflows/upversionandtagrelease.yml
|
||||||
|
with:
|
||||||
|
build-host: ubuntu-latest
|
||||||
|
build-type: minor
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
|
# Up version the release and publish patch release (default)
|
||||||
|
upversion-patch-Package:
|
||||||
|
if: github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'no-ver') == false && contains(github.event.pull_request.title, 'minor-release') == false && contains(github.event.pull_request.title, 'major-release') == false
|
||||||
|
name: Patch Version package and release
|
||||||
|
uses: ./.github/workflows/upversionandtagrelease.yml
|
||||||
|
with:
|
||||||
|
build-host: ubuntu-latest
|
||||||
|
build-type: patch-release
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
|
release-Complete:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: [upversion-major-Package, upversion-minor-Package, upversion-patch-Package, release-Package-only]
|
||||||
|
name: Release complete
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Script Version
|
||||||
|
run: echo "Release done, updating Development"
|
||||||
|
|
||||||
|
# Refresh the development branch with the main publish
|
||||||
|
refresh-development:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: [release-Complete]
|
||||||
|
name: Refresh development branch
|
||||||
|
uses: ./.github/workflows/refreshbranch.yml
|
||||||
|
with:
|
||||||
|
build-host: ubuntu-latest
|
||||||
|
target-branch: development
|
||||||
|
source-branch: main
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
|
# Up version the development branch ready for future development
|
||||||
|
upversion-development:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: [refresh-development]
|
||||||
|
name: UpVersion the development branch for the next release
|
||||||
|
uses: ./.github/workflows/upversionandtagrelease.yml
|
||||||
|
with:
|
||||||
|
build-host: ubuntu-latest
|
||||||
|
build-type: patch
|
||||||
|
target-branch: development
|
||||||
|
createTag: false
|
||||||
|
secrets: inherit
|
|
@ -0,0 +1,43 @@
|
||||||
|
name: Refresh branch
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
build-host:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
target-branch:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
source-branch:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
packageRelease:
|
||||||
|
name: Refresh ${{ inputs.target-branch }} branch from ${{ inputs.source-branch }} branch
|
||||||
|
runs-on: ${{ inputs.build-host }}
|
||||||
|
steps:
|
||||||
|
- name: Script Version
|
||||||
|
run: |
|
||||||
|
echo "::group::Script Versioning"
|
||||||
|
$scriptVersion = "1.0.1"
|
||||||
|
echo "Build Script Version: $scriptVersion"
|
||||||
|
echo "::endgroup::"
|
||||||
|
shell: pwsh
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: ${{ inputs.target-branch }}
|
||||||
|
clean: true
|
||||||
|
token: ${{ secrets.GIT_PAT }}
|
||||||
|
- name: Refresh from Source Branch
|
||||||
|
run: |
|
||||||
|
git pull origin ${{ inputs.source-branch }}
|
||||||
|
git commit -m "Branch ${{ inputs.target-branch }} updated with changes from ${{ inputs.source-branch }} [skip ci]"
|
||||||
|
git push origin ${{ inputs.target-branch }}
|
||||||
|
echo "Branch ${{ inputs.target-branch }} updated with changes from ${{ inputs.source-branch }}"
|
||||||
|
shell: pwsh
|
|
@ -18,7 +18,7 @@ jobs:
|
||||||
- os: windows
|
- os: windows
|
||||||
unityVersion: 2019.4
|
unityVersion: 2019.4
|
||||||
build-target: Android
|
build-target: Android
|
||||||
- os: macos
|
- os: macOS
|
||||||
unityVersion: 2019.4
|
unityVersion: 2019.4
|
||||||
build-target: iOS
|
build-target: iOS
|
||||||
- os: windows
|
- os: windows
|
||||||
|
@ -30,7 +30,7 @@ jobs:
|
||||||
- os: windows
|
- os: windows
|
||||||
unityVersion: 2020.3
|
unityVersion: 2020.3
|
||||||
build-target: Android
|
build-target: Android
|
||||||
- os: macos
|
- os: macOS
|
||||||
unityVersion: 2020.3
|
unityVersion: 2020.3
|
||||||
build-target: iOS
|
build-target: iOS
|
||||||
- os: windows
|
- os: windows
|
||||||
|
@ -42,7 +42,7 @@ jobs:
|
||||||
- os: windows
|
- os: windows
|
||||||
unityVersion: 2021.3
|
unityVersion: 2021.3
|
||||||
build-target: Android
|
build-target: Android
|
||||||
- os: macos
|
- os: macOS
|
||||||
unityVersion: 2021.3
|
unityVersion: 2021.3
|
||||||
build-target: iOS
|
build-target: iOS
|
||||||
- os: windows
|
- os: windows
|
||||||
|
@ -54,7 +54,7 @@ jobs:
|
||||||
- os: windows
|
- os: windows
|
||||||
unityVersion: 2022.2
|
unityVersion: 2022.2
|
||||||
build-target: Android
|
build-target: Android
|
||||||
- os: macos
|
- os: macOS
|
||||||
unityVersion: 2022.2
|
unityVersion: 2022.2
|
||||||
build-target: iOS
|
build-target: iOS
|
||||||
- os: windows
|
- os: windows
|
||||||
|
@ -80,7 +80,7 @@ jobs:
|
||||||
name: 'Run Unity Builds'
|
name: 'Run Unity Builds'
|
||||||
run: |
|
run: |
|
||||||
echo "::group::Set Hub and editor locations"
|
echo "::group::Set Hub and editor locations"
|
||||||
$unityVersion = ${{ matrix.unityVersion }}
|
$unityVersion = '${{ matrix.unityVersion }}'
|
||||||
|
|
||||||
echo "::group::Set Hub and editor locations"
|
echo "::group::Set Hub and editor locations"
|
||||||
|
|
||||||
|
@ -90,6 +90,7 @@ jobs:
|
||||||
$hubPath = "C:\Program Files\Unity Hub\Unity Hub.exe"
|
$hubPath = "C:\Program Files\Unity Hub\Unity Hub.exe"
|
||||||
$editorRootPath = "C:\Program Files\Unity\Hub\Editor\"
|
$editorRootPath = "C:\Program Files\Unity\Hub\Editor\"
|
||||||
$editorFileEx = "\Editor\Unity.exe"
|
$editorFileEx = "\Editor\Unity.exe"
|
||||||
|
$directorySeparatorChar = "\"
|
||||||
|
|
||||||
#"Unity Hub.exe" -- --headless help
|
#"Unity Hub.exe" -- --headless help
|
||||||
#. 'C:\Program Files\Unity Hub\Unity Hub.exe' -- --headless help
|
#. 'C:\Program Files\Unity Hub\Unity Hub.exe' -- --headless help
|
||||||
|
@ -100,11 +101,12 @@ jobs:
|
||||||
}
|
}
|
||||||
elseif ( $global:PSVersionTable.OS.Contains("Darwin") )
|
elseif ( $global:PSVersionTable.OS.Contains("Darwin") )
|
||||||
{
|
{
|
||||||
$hubPath = "/Applications/Unity Hub.app/Contents/MacOS/Unity Hub"
|
$hubPath = "/Applications/Unity Hub.app/Contents/macOS/Unity Hub"
|
||||||
$editorRootPath = "/Applications/Unity/Hub/Editor/"
|
$editorRootPath = "/Applications/Unity/Hub/Editor/"
|
||||||
$editorFileEx = "/Unity.app/Contents/MacOS/Unity"
|
$editorFileEx = "/Unity.app/Contents/macOS/Unity"
|
||||||
|
$directorySeparatorChar = "/"
|
||||||
|
|
||||||
# /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless help
|
# /Applications/Unity\ Hub.app/Contents/macOS/Unity\ Hub -- --headless help
|
||||||
function unity-hub
|
function unity-hub
|
||||||
{
|
{
|
||||||
& $hubPath -- --headless $args.Split(" ") | Out-String -NoNewline
|
& $hubPath -- --headless $args.Split(" ") | Out-String -NoNewline
|
||||||
|
@ -115,6 +117,7 @@ jobs:
|
||||||
$hubPath = "$HOME/Unity Hub/UnityHub.AppImage"
|
$hubPath = "$HOME/Unity Hub/UnityHub.AppImage"
|
||||||
$editorRootPath = "$HOME/Unity/Hub/Editor/"
|
$editorRootPath = "$HOME/Unity/Hub/Editor/"
|
||||||
$editorFileEx = "/Editor/Unity"
|
$editorFileEx = "/Editor/Unity"
|
||||||
|
$directorySeparatorChar = "/"
|
||||||
|
|
||||||
# /UnityHub.AppImage --headless help
|
# /UnityHub.AppImage --headless help
|
||||||
# xvfb-run --auto-servernum "$HOME/Unity Hub/UnityHub.AppImage" --headless help
|
# xvfb-run --auto-servernum "$HOME/Unity Hub/UnityHub.AppImage" --headless help
|
||||||
|
@ -126,8 +129,6 @@ jobs:
|
||||||
|
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo "::group::Get String function to query a string for a value"
|
echo "::group::Get String function to query a string for a value"
|
||||||
|
|
||||||
function GetString($InputString, $InputPattern, $MatchIndex)
|
function GetString($InputString, $InputPattern, $MatchIndex)
|
||||||
|
@ -151,10 +152,9 @@ jobs:
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
echo "::group::Get Installed Unity version based on Matrix"
|
echo "::group::Get Installed Unity version based on Matrix"
|
||||||
echo 'Script Start'
|
|
||||||
echo "Unity hub path is {$hubPath}"
|
echo "Unity hub path is {$hubPath}"
|
||||||
echo "Requested unity version is {$unityVersion}"
|
echo "Requested unity version is {$unityVersion}"
|
||||||
|
|
||||||
$InstalledUnityVersions = unity-hub editors
|
$InstalledUnityVersions = unity-hub editors
|
||||||
$editorRootPath = unity-hub ip -g
|
$editorRootPath = unity-hub ip -g
|
||||||
echo "Installed unity versions are {$InstalledUnityVersions}"
|
echo "Installed unity versions are {$InstalledUnityVersions}"
|
||||||
|
@ -171,7 +171,7 @@ jobs:
|
||||||
$queryUnityVersion = GetString $InstalledUnityVersions "$unityVersion" -MatchIndex 0
|
$queryUnityVersion = GetString $InstalledUnityVersions "$unityVersion" -MatchIndex 0
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Found unity version is {$queryUnityVersion}"
|
echo "Found unity version is {$queryUnityVersion} for input {$unityVersion}"
|
||||||
|
|
||||||
if ($queryUnityVersion -ne 0)
|
if ($queryUnityVersion -ne 0)
|
||||||
{
|
{
|
||||||
|
@ -218,7 +218,7 @@ jobs:
|
||||||
}
|
}
|
||||||
elseif ( $global:PSVersionTable.OS.Contains("Darwin") ) {
|
elseif ( $global:PSVersionTable.OS.Contains("Darwin") ) {
|
||||||
echo 'Building using Mac'
|
echo 'Building using Mac'
|
||||||
$editorFileEx = "/Unity.app/Contents/MacOS/Unity"
|
$editorFileEx = "/Unity.app/Contents/macOS/Unity"
|
||||||
$editorrunpath = Join-Path $editorRootPath $unityVersion $editorFileEx
|
$editorrunpath = Join-Path $editorRootPath $unityVersion $editorFileEx
|
||||||
|
|
||||||
function unity-editor {
|
function unity-editor {
|
||||||
|
@ -456,4 +456,4 @@ jobs:
|
||||||
if: always()
|
if: always()
|
||||||
with:
|
with:
|
||||||
name: unity-build-log
|
name: unity-build-log
|
||||||
path: Logs/**
|
path: Logs/**
|
|
@ -19,7 +19,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: macos
|
- os: macOS
|
||||||
build-target: iOS
|
build-target: iOS
|
||||||
- os: windows
|
- os: windows
|
||||||
build-target: Android
|
build-target: Android
|
||||||
|
@ -40,12 +40,11 @@ jobs:
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
clean: true
|
clean: true
|
||||||
|
|
||||||
- id: build
|
- id: build
|
||||||
name: 'Run Unity Builds'
|
name: 'Run Unity Builds'
|
||||||
run: |
|
run: |
|
||||||
echo "::group::Set Hub and editor locations"
|
echo "::group::Set Hub and editor locations"
|
||||||
$unityVersion = ${{ inputs.unityVersion }}
|
$unityVersion = '${{ inputs.unityVersion }}'
|
||||||
|
|
||||||
echo "::group::Set Hub and editor locations"
|
echo "::group::Set Hub and editor locations"
|
||||||
|
|
||||||
|
@ -55,6 +54,7 @@ jobs:
|
||||||
$hubPath = "C:\Program Files\Unity Hub\Unity Hub.exe"
|
$hubPath = "C:\Program Files\Unity Hub\Unity Hub.exe"
|
||||||
$editorRootPath = "C:\Program Files\Unity\Hub\Editor\"
|
$editorRootPath = "C:\Program Files\Unity\Hub\Editor\"
|
||||||
$editorFileEx = "\Editor\Unity.exe"
|
$editorFileEx = "\Editor\Unity.exe"
|
||||||
|
$directorySeparatorChar = "\"
|
||||||
|
|
||||||
#"Unity Hub.exe" -- --headless help
|
#"Unity Hub.exe" -- --headless help
|
||||||
#. 'C:\Program Files\Unity Hub\Unity Hub.exe' -- --headless help
|
#. 'C:\Program Files\Unity Hub\Unity Hub.exe' -- --headless help
|
||||||
|
@ -68,6 +68,7 @@ jobs:
|
||||||
$hubPath = "/Applications/Unity Hub.app/Contents/MacOS/Unity Hub"
|
$hubPath = "/Applications/Unity Hub.app/Contents/MacOS/Unity Hub"
|
||||||
$editorRootPath = "/Applications/Unity/Hub/Editor/"
|
$editorRootPath = "/Applications/Unity/Hub/Editor/"
|
||||||
$editorFileEx = "/Unity.app/Contents/MacOS/Unity"
|
$editorFileEx = "/Unity.app/Contents/MacOS/Unity"
|
||||||
|
$directorySeparatorChar = "/"
|
||||||
|
|
||||||
# /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless help
|
# /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless help
|
||||||
function unity-hub
|
function unity-hub
|
||||||
|
@ -80,6 +81,7 @@ jobs:
|
||||||
$hubPath = "$HOME/Unity Hub/UnityHub.AppImage"
|
$hubPath = "$HOME/Unity Hub/UnityHub.AppImage"
|
||||||
$editorRootPath = "$HOME/Unity/Hub/Editor/"
|
$editorRootPath = "$HOME/Unity/Hub/Editor/"
|
||||||
$editorFileEx = "/Editor/Unity"
|
$editorFileEx = "/Editor/Unity"
|
||||||
|
$directorySeparatorChar = "/"
|
||||||
|
|
||||||
# /UnityHub.AppImage --headless help
|
# /UnityHub.AppImage --headless help
|
||||||
# xvfb-run --auto-servernum "$HOME/Unity Hub/UnityHub.AppImage" --headless help
|
# xvfb-run --auto-servernum "$HOME/Unity Hub/UnityHub.AppImage" --headless help
|
||||||
|
@ -91,8 +93,6 @@ jobs:
|
||||||
|
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo "::group::Get String function to query a string for a value"
|
echo "::group::Get String function to query a string for a value"
|
||||||
|
|
||||||
function GetString($InputString, $InputPattern, $MatchIndex)
|
function GetString($InputString, $InputPattern, $MatchIndex)
|
||||||
|
@ -115,8 +115,7 @@ jobs:
|
||||||
}
|
}
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
echo "::group::Get Installed Unity version based on Matrix"
|
echo "::group::Find Installed Unity version based on input"
|
||||||
echo 'Script Start'
|
|
||||||
echo "Unity hub path is {$hubPath}"
|
echo "Unity hub path is {$hubPath}"
|
||||||
echo "Requested unity version is {$unityVersion}"
|
echo "Requested unity version is {$unityVersion}"
|
||||||
|
|
||||||
|
@ -136,7 +135,7 @@ jobs:
|
||||||
$queryUnityVersion = GetString $InstalledUnityVersions "$unityVersion" -MatchIndex 0
|
$queryUnityVersion = GetString $InstalledUnityVersions "$unityVersion" -MatchIndex 0
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Found unity version is {$queryUnityVersion}"
|
echo "Found unity version is {$queryUnityVersion} for input {$unityVersion}"
|
||||||
|
|
||||||
if ($queryUnityVersion -ne 0)
|
if ($queryUnityVersion -ne 0)
|
||||||
{
|
{
|
||||||
|
@ -421,4 +420,4 @@ jobs:
|
||||||
if: always()
|
if: always()
|
||||||
with:
|
with:
|
||||||
name: unity-build-log
|
name: unity-build-log
|
||||||
path: Logs/**
|
path: Logs/**
|
|
@ -1,33 +1,26 @@
|
||||||
name: Package UPM project and deploy
|
name: Tag Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
build-target:
|
build-host:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
version:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
build-type:
|
|
||||||
required: false
|
# Allows you to run this workflow manually from the Actions tab
|
||||||
default: 'pre-release'
|
workflow_dispatch:
|
||||||
type: string
|
|
||||||
# options:
|
concurrency:
|
||||||
# - major
|
group: ${{ github.ref }}
|
||||||
# - minor
|
cancel-in-progress: true
|
||||||
# - patch
|
|
||||||
# - pre-release
|
|
||||||
# - build
|
|
||||||
outputs:
|
|
||||||
packageversion:
|
|
||||||
description: "Returns the version of Unity the UPM package requires"
|
|
||||||
value: ${{ jobs.packageRelease.outputs.packageversion }}
|
|
||||||
secrets:
|
|
||||||
GIT_USER_NAME:
|
|
||||||
required: false
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
packageRelease:
|
packageRelease:
|
||||||
name: Package UPM Project and tag
|
name: Package UPM Project and tag
|
||||||
runs-on: ${{ inputs.build-target }}
|
runs-on: ${{ inputs.build-host }}
|
||||||
outputs:
|
outputs:
|
||||||
packageversion: ${{ steps.getpackageversion.outputs.packageversion }}
|
packageversion: ${{ steps.getpackageversion.outputs.packageversion }}
|
||||||
steps:
|
steps:
|
||||||
|
@ -40,6 +33,7 @@ jobs:
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
clean: true
|
clean: true
|
||||||
token: ${{ secrets.GIT_PAT }}
|
token: ${{ secrets.GIT_PAT }}
|
||||||
|
@ -60,87 +54,26 @@ jobs:
|
||||||
$gitUser = "${{ secrets.GIT_USER_NAME }}"
|
$gitUser = "${{ secrets.GIT_USER_NAME }}"
|
||||||
$gitEmail = "$gitUser@users.noreply.github.com"
|
$gitEmail = "$gitUser@users.noreply.github.com"
|
||||||
}
|
}
|
||||||
echo "email $gitUser@users.noreply.github.com"
|
|
||||||
git config --global user.email "$gitUser@users.noreply.github.com"
|
git config --global user.email "$gitUser@users.noreply.github.com"
|
||||||
git config --global user.name "$gitUser"
|
git config --global user.name "$gitUser"
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
- id: getpackageversion
|
- name: Check if Tag Exists
|
||||||
name: Bump UPM Package version
|
|
||||||
run: |
|
run: |
|
||||||
function UpdateProjectVersionJSON {
|
$tagVersion = "${{ inputs.version }}"
|
||||||
param (
|
$tags = git tag
|
||||||
[Parameter(Mandatory)]
|
echo "Tags found are [$tags], searching for [$tagVersion]"
|
||||||
$type,
|
foreach ($tag in $tags)
|
||||||
$packageFile = 'package.json'
|
{
|
||||||
)
|
if($tag.Trim() -eq "$tagVersion")
|
||||||
<#
|
{
|
||||||
Type of build can be one of the following
|
Write-Error "$tagVersion tag already exists"
|
||||||
- 'build' # Build release - 1.0.0-pre-release.0+1
|
exit 1
|
||||||
- 'pre-release' # Pre-Release release - 1.0.0-pre-release.1
|
|
||||||
- 'patch' # Patch release - 1.0.1
|
|
||||||
- 'minor' # Minor release - 1.1.0
|
|
||||||
- 'major' # Major release - 2.0.0
|
|
||||||
#>
|
|
||||||
|
|
||||||
if ( -not (Test-Path -Path $packageFile) ) {
|
|
||||||
Write-Error "Failed to find a valid project manifest at `"$packageFile`""
|
|
||||||
return $null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$packageInfo = (Get-Content $packageFile -Raw) | ConvertFrom-Json
|
|
||||||
Write-Host "Detected Project Version:" $packageInfo.version
|
|
||||||
function IfNull($a, $b, $c) { if ($null -eq $a) { return $b } else { return $c } }
|
|
||||||
|
|
||||||
$packageSemVer = [System.Management.Automation.SemanticVersion]$packageInfo.version
|
|
||||||
$majorVersion = if($null -eq $packageSemVer.Major) {0} else {$packageSemVer.Major}
|
|
||||||
$minorVersion = if($null -eq $packageSemVer.Minor) {0} else {$packageSemVer.Minor}
|
|
||||||
$patchVersion = if($null -eq $packageSemVer.Patch) {0} else {$packageSemVer.Patch}
|
|
||||||
$prereleaseVersion = if($null -eq $packageSemVer.PreReleaseLabel) {0} else {$packageSemVer.PreReleaseLabel.Replace('pre-release.','')}
|
|
||||||
$buildVersion = if($null -eq $packageSemVer.BuildLabel) {0} else {$packageSemVer.BuildLabel}
|
|
||||||
|
|
||||||
# work out new version
|
|
||||||
switch ($type) {
|
|
||||||
'build' {
|
|
||||||
[int]$buildVersion += 1
|
|
||||||
$newPackageSemVer = [System.Management.Automation.SemanticVersion]::New($majorVersion, $minorVersion, $patchVersion, "pre-release." + $prereleaseVersion, $buildVersion)
|
|
||||||
}
|
|
||||||
'pre-release' {
|
|
||||||
[int]$prereleaseVersion += 1
|
|
||||||
$newPackageSemVer = [System.Management.Automation.SemanticVersion]::New($majorVersion, $minorVersion, $patchVersion, "pre-release." + $prereleaseVersion)
|
|
||||||
}
|
|
||||||
'patch' {
|
|
||||||
[int]$patchVersion += 1
|
|
||||||
$newPackageSemVer = [System.Management.Automation.SemanticVersion]::New($majorVersion, $minorVersion, $patchVersion)
|
|
||||||
}
|
|
||||||
'minor' {
|
|
||||||
[int]$minorVersion += 1
|
|
||||||
$newPackageSemVer = [System.Management.Automation.SemanticVersion]::New($majorVersion, $minorVersion, 0)
|
|
||||||
}
|
|
||||||
'major' {
|
|
||||||
[int]$majorVersion += 1
|
|
||||||
$newPackageSemVer = [System.Management.Automation.SemanticVersion]::New($majorVersion, 0, 0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "Upgrading project version [$packageSemVer] to [$newPackageSemVer]"
|
|
||||||
|
|
||||||
# Write out updated package info
|
|
||||||
|
|
||||||
$packageInfo.version = $newPackageSemVer.ToString()
|
|
||||||
$packageInfo | ConvertTo-Json | Set-Content $packageFile
|
|
||||||
|
|
||||||
return $packageInfo.version
|
|
||||||
}
|
}
|
||||||
|
shell: pwsh
|
||||||
$packageFile = 'package.json'
|
- name: Create tag and push
|
||||||
$result = UpdateProjectVersionJSON("${{ inputs.build-type }}","$packageFile")
|
run: |
|
||||||
if([string]::IsNullOrEmpty($result)) {
|
$tagVersion = "${{ inputs.version }}"
|
||||||
echo "Version patch failed"
|
git tag -fa "v$tagVersion" "${GITHUB_SHA}" -m "v$tagVersion Release [skip ci]"
|
||||||
exit 1
|
git push origin "v$tagVersion" --force
|
||||||
}
|
shell: pwsh
|
||||||
echo "packageversion=$result" >> $env:GITHUB_OUTPUT
|
|
||||||
git add "$packageFile"
|
|
||||||
git commit -m "Auto increment pre-release version to $result [skip ci]"
|
|
||||||
git tag -fa "$result" "${GITHUB_SHA}" -m "$result Release"
|
|
||||||
git push origin --force
|
|
||||||
shell: pwsh
|
|
|
@ -0,0 +1,181 @@
|
||||||
|
name: UpVersion Package UPM project and create new tag
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
build-host:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
build-type:
|
||||||
|
required: false
|
||||||
|
default: 'pre-release'
|
||||||
|
type: string
|
||||||
|
# options:
|
||||||
|
# - major
|
||||||
|
# - minor
|
||||||
|
# - patch
|
||||||
|
# - patch-release
|
||||||
|
# - pre-release
|
||||||
|
# - build
|
||||||
|
target-branch:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: ${{ github.ref }}
|
||||||
|
createTag:
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
|
default: true
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
packageversion:
|
||||||
|
description: "Returns the version of Unity the UPM package requires"
|
||||||
|
value: ${{ jobs.packageRelease.outputs.packageversion }}
|
||||||
|
secrets:
|
||||||
|
GIT_PAT:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
packageRelease:
|
||||||
|
name: Package UPM Project and tag
|
||||||
|
runs-on: ${{ inputs.build-host }}
|
||||||
|
outputs:
|
||||||
|
packageversion: ${{ steps.getpackageversion.outputs.packageversion }}
|
||||||
|
steps:
|
||||||
|
- name: Script Version
|
||||||
|
run: |
|
||||||
|
echo "::group::Script Versioning"
|
||||||
|
$scriptVersion = "1.0.2"
|
||||||
|
echo "Build Script Version: $scriptVersion"
|
||||||
|
echo "::endgroup::"
|
||||||
|
shell: pwsh
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: ${{ inputs.target-branch }}
|
||||||
|
fetch-depth: 0
|
||||||
|
submodules: recursive
|
||||||
|
clean: true
|
||||||
|
token: ${{ secrets.GIT_PAT }}
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
- name: Set Github vars
|
||||||
|
run: |
|
||||||
|
if([string]::IsNullOrEmpty('${{ secrets.GIT_USER_NAME }}')){
|
||||||
|
if([string]::IsNullOrEmpty('${{ secrets.GIT_USER_NAME }}')){
|
||||||
|
$gitUser = "action"
|
||||||
|
$gitEmail = "action@github.com"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$gitUser = "${GITHUB_ACTOR}"
|
||||||
|
$gitEmail = "$gitUser@users.noreply.github.com"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$gitUser = "${{ secrets.GIT_USER_NAME }}"
|
||||||
|
$gitEmail = "$gitUser@users.noreply.github.com"
|
||||||
|
}
|
||||||
|
git config --global user.email "$gitUser@users.noreply.github.com"
|
||||||
|
git config --global user.name "$gitUser"
|
||||||
|
shell: pwsh
|
||||||
|
- id: getpackageversion
|
||||||
|
name: Bump UPM Package version
|
||||||
|
run: |
|
||||||
|
function UpdateProjectVersionJSON {
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
$type,
|
||||||
|
$packageFile = 'package.json'
|
||||||
|
)
|
||||||
|
<#
|
||||||
|
Type of build can be one of the following
|
||||||
|
- 'build' # Build release - 1.0.0-pre.0+1
|
||||||
|
- 'pre-release' # Pre-Release - 1.0.0-pre.1
|
||||||
|
- 'patch-release' # Patch release - 1.0.1 (reset preview version to current patch, no increase)
|
||||||
|
- 'patch' # Patch release - 1.0.1
|
||||||
|
- 'minor' # Minor release - 1.1.0
|
||||||
|
- 'major' # Major release - 2.0.0
|
||||||
|
#>
|
||||||
|
|
||||||
|
if ( -not (Test-Path -Path $packageFile) ) {
|
||||||
|
Write-Error "Failed to find a valid project manifest at `"$packageFile`""
|
||||||
|
return $null
|
||||||
|
}
|
||||||
|
|
||||||
|
$packageInfo = (Get-Content $packageFile -Raw) | ConvertFrom-Json
|
||||||
|
Write-Host "Detected Project Version:" $packageInfo.version
|
||||||
|
function IfNull($a, $b, $c) { if ($null -eq $a) { return $b } else { return $c } }
|
||||||
|
|
||||||
|
$packageSemVer = [System.Management.Automation.SemanticVersion]$packageInfo.version
|
||||||
|
$majorVersion = if($null -eq $packageSemVer.Major) {0} else {$packageSemVer.Major}
|
||||||
|
$minorVersion = if($null -eq $packageSemVer.Minor) {0} else {$packageSemVer.Minor}
|
||||||
|
$patchVersion = if($null -eq $packageSemVer.Patch) {0} else {$packageSemVer.Patch}
|
||||||
|
$prereleaseVersion = if($null -eq $packageSemVer.PreReleaseLabel) {0} else {$packageSemVer.PreReleaseLabel.Replace('pre.','')}
|
||||||
|
$buildVersion = if($null -eq $packageSemVer.BuildLabel) {0} else {$packageSemVer.BuildLabel}
|
||||||
|
|
||||||
|
# work out new version
|
||||||
|
switch ($type) {
|
||||||
|
'build' {
|
||||||
|
[int]$buildVersion += 1
|
||||||
|
$newPackageSemVer = [System.Management.Automation.SemanticVersion]::New($majorVersion, $minorVersion, $patchVersion, "pre." + $prereleaseVersion, $buildVersion)
|
||||||
|
}
|
||||||
|
'pre-release' {
|
||||||
|
[int]$prereleaseVersion += 1
|
||||||
|
$newPackageSemVer = [System.Management.Automation.SemanticVersion]::New($majorVersion, $minorVersion, $patchVersion, "pre." + $prereleaseVersion)
|
||||||
|
}
|
||||||
|
'patch-release' {
|
||||||
|
$newPackageSemVer = [System.Management.Automation.SemanticVersion]::New($majorVersion, $minorVersion, $patchVersion)
|
||||||
|
}
|
||||||
|
'patch' {
|
||||||
|
[int]$patchVersion += 1
|
||||||
|
$newPackageSemVer = [System.Management.Automation.SemanticVersion]::New($majorVersion, $minorVersion, $patchVersion)
|
||||||
|
}
|
||||||
|
'minor' {
|
||||||
|
[int]$minorVersion += 1
|
||||||
|
$newPackageSemVer = [System.Management.Automation.SemanticVersion]::New($majorVersion, $minorVersion, 0)
|
||||||
|
}
|
||||||
|
'major' {
|
||||||
|
[int]$majorVersion += 1
|
||||||
|
$newPackageSemVer = [System.Management.Automation.SemanticVersion]::New($majorVersion, 0, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Upgrading project version [$packageSemVer] to [$newPackageSemVer]"
|
||||||
|
|
||||||
|
# Write out updated package info
|
||||||
|
|
||||||
|
$packageInfo.version = $newPackageSemVer.ToString()
|
||||||
|
$packageInfo | ConvertTo-Json | Set-Content $packageFile
|
||||||
|
|
||||||
|
return $packageInfo.version
|
||||||
|
}
|
||||||
|
|
||||||
|
$packageFile = 'package.json'
|
||||||
|
$result = UpdateProjectVersionJSON("${{ inputs.build-type }}","$packageFile")
|
||||||
|
if([string]::IsNullOrEmpty($result)) {
|
||||||
|
echo "Version patch failed"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
git add "$packageFile"
|
||||||
|
git commit -m "Auto increment pre-release version to $result [skip ci]"
|
||||||
|
git push origin
|
||||||
|
echo "packageversion=$result" >> $env:GITHUB_OUTPUT
|
||||||
|
shell: pwsh
|
||||||
|
- name: Check if Tag Exists
|
||||||
|
run: |
|
||||||
|
$tagVersion = '${{steps.getpackageversion.outputs.packageversion }}'
|
||||||
|
$tags = git tag
|
||||||
|
echo "Tags found are [$tags], searching for [$tagVersion]"
|
||||||
|
foreach ($tag in $tags)
|
||||||
|
{
|
||||||
|
if($tag.Trim() -eq "$tagVersion")
|
||||||
|
{
|
||||||
|
Write-Error "$tagVersion tag already exists"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
shell: pwsh
|
||||||
|
- name: Publish package tag
|
||||||
|
if: ${{inputs.createTag == true}}
|
||||||
|
run: |
|
||||||
|
$outputVersion = '${{steps.getpackageversion.outputs.packageversion }}'
|
||||||
|
git tag -fa "v$outputVersion" "${GITHUB_SHA}" -m "v$outputVersion Release"
|
||||||
|
git push origin "v$outputVersion" --force --tags
|
||||||
|
shell: pwsh
|
Loading…
Reference in New Issue