Skip to content

Commit 3a0d442

Browse files
Restore automations
1 parent 24e4ede commit 3a0d442

6 files changed

Lines changed: 488 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Publish development branch on Merge
2+
3+
on:
4+
pull_request:
5+
types:
6+
- closed
7+
branches:
8+
- development
9+
# On close of PR targeting development
10+
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
concurrency:
15+
group: ${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
release_on_merge:
20+
if: github.event.pull_request.merged == true
21+
name: Tag and Publish UPM package
22+
uses: ./.github/workflows/upversionandtagrelease.yml
23+
with:
24+
build-host: ubuntu-latest
25+
build-type: pre-release
26+
secrets: inherit
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Get the Package version from a UPM Package.json file
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
build-host:
7+
required: true
8+
type: string
9+
version-file-path:
10+
description: 'Optional, specify a path to search for the upm package.json file. Use this if validation fails to find a valid package.json file.\n **Note, Version file MUST contain the attribute "Unity" with the full Unity version expected, e.g. "2020.2.3f1"'
11+
type: string
12+
required: false
13+
outputs:
14+
packageversion:
15+
description: "Returns the version of the UPM package"
16+
value: ${{ jobs.get_package_version.outputs.upmpackageversion }}
17+
18+
jobs:
19+
get_package_version:
20+
name: Get required Package version from UPM Package
21+
runs-on: ${{ inputs.build-host }}
22+
outputs:
23+
upmpackageversion: ${{ steps.getVersion.outputs.packageversion }}
24+
steps:
25+
- name: Script Version
26+
run: |
27+
echo "::group::Script Versioning"
28+
$scriptVersion = "1.0.0"
29+
echo "Build Script Version: $scriptVersion"
30+
echo "::endgroup::"
31+
shell: pwsh
32+
- uses: actions/checkout@v7
33+
with:
34+
submodules: recursive
35+
clean: true
36+
- id: getVersion
37+
name: 'Get Package Version Number'
38+
run: |
39+
echo "::group::Validating input"
40+
41+
$versionFile = "${{ inputs.version-file-path }}"
42+
if([string]::IsNullOrEmpty($versionFile))
43+
{
44+
echo 'version input was empty, using default'
45+
$versionFile = 'package.json'
46+
}
47+
echo 'Checking for project json at $versionFile'
48+
49+
if ( -not (Test-Path -Path $versionFile) ) {
50+
Write-Error "Failed to find a valid package.json file"
51+
exit 1
52+
}
53+
54+
echo "::endgroup::"
55+
56+
echo "::group::Package Version UPM check"
57+
58+
$package_json = Get-Content -Path $versionFile | ConvertFrom-Json
59+
$packageVersion = $package_json.version
60+
61+
if([string]::IsNullOrEmpty($packageVersion)) {
62+
Write-Error "Project.json version number does not exist or is empty"
63+
exit 1
64+
}
65+
66+
echo "packageversion=$packageVersion" >> $env:GITHUB_OUTPUT
67+
68+
echo "Detected version is $packageVersion"
69+
echo "::endgroup::"
70+
shell: pwsh

.github/workflows/main-publish.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Publish main branch and increment version
2+
3+
on:
4+
pull_request:
5+
types:
6+
- closed
7+
branches:
8+
- release
9+
10+
jobs:
11+
# Get Version to tag and release the branch, no up-version - [no-ver] included in PR title
12+
validate-environment:
13+
if: github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'no-ver')
14+
name: Get Version from UPM package
15+
uses: ./.github/workflows/getpackageversionfrompackage.yml
16+
with:
17+
build-host: ubuntu-latest
18+
19+
# Perform tagging
20+
release-Package-only:
21+
needs: validate-environment
22+
name: Release package only, no upversion
23+
uses: ./.github/workflows/tagrelease.yml
24+
with:
25+
build-host: ubuntu-latest
26+
version: ${{ needs.validate-environment.outputs.packageversion }}
27+
secrets: inherit
28+
29+
# Up version the release and publish major release
30+
upversion-major-Package:
31+
if: github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'no-ver') == false && contains(github.event.pull_request.title, 'major-release')
32+
name: Major Version package and release
33+
uses: ./.github/workflows/upversionandtagrelease.yml
34+
with:
35+
build-host: ubuntu-latest
36+
build-type: major
37+
secrets: inherit
38+
39+
# Up version the release and publish minor release
40+
upversion-minor-Package:
41+
if: github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'no-ver') == false && contains(github.event.pull_request.title, 'minor-release')
42+
name: Minor Version package and release
43+
uses: ./.github/workflows/upversionandtagrelease.yml
44+
with:
45+
build-host: ubuntu-latest
46+
build-type: minor
47+
secrets: inherit
48+
49+
# Up version the release and publish patch release (default)
50+
upversion-patch-Package:
51+
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
52+
name: Patch Version package and release
53+
uses: ./.github/workflows/upversionandtagrelease.yml
54+
with:
55+
build-host: ubuntu-latest
56+
build-type: patch-release
57+
secrets: inherit
58+
59+
release-Complete:
60+
if: ${{ always() }}
61+
needs: [upversion-major-Package, upversion-minor-Package, upversion-patch-Package, release-Package-only]
62+
name: Release complete
63+
runs-on: ubuntu-latest
64+
steps:
65+
- name: Script Version
66+
run: echo "Release done, updating Development"
67+
68+
# Refresh the development branch with the main publish
69+
refresh-development:
70+
if: ${{ always() }}
71+
needs: [release-Complete]
72+
name: Refresh development branch
73+
uses: ./.github/workflows/refreshbranch.yml
74+
with:
75+
build-host: ubuntu-latest
76+
target-branch: development
77+
source-branch: main
78+
secrets: inherit
79+
80+
# Up version the development branch ready for future development
81+
upversion-development:
82+
if: ${{ always() }}
83+
needs: [refresh-development]
84+
name: UpVersion the development branch for the next release
85+
uses: ./.github/workflows/upversionandtagrelease.yml
86+
with:
87+
build-host: ubuntu-latest
88+
build-type: patch
89+
target-branch: development
90+
createTag: false
91+
secrets: inherit
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Refresh branch
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
build-host:
7+
required: true
8+
type: string
9+
target-branch:
10+
required: true
11+
type: string
12+
source-branch:
13+
required: true
14+
type: string
15+
16+
concurrency:
17+
group: ${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
packageRelease:
22+
name: Refresh ${{ inputs.target-branch }} branch from ${{ inputs.source-branch }} branch
23+
runs-on: ${{ inputs.build-host }}
24+
steps:
25+
- name: Script Version
26+
run: |
27+
echo "::group::Script Versioning"
28+
$scriptVersion = "1.0.1"
29+
echo "Build Script Version: $scriptVersion"
30+
echo "::endgroup::"
31+
shell: pwsh
32+
- uses: actions/checkout@v7
33+
with:
34+
ref: ${{ inputs.target-branch }}
35+
clean: true
36+
token: ${{ secrets.GIT_PAT }}
37+
- name: Refresh from Source Branch
38+
run: |
39+
git pull origin ${{ inputs.source-branch }}
40+
git commit -m "Branch ${{ inputs.target-branch }} updated with changes from ${{ inputs.source-branch }} [skip ci]"
41+
git push origin ${{ inputs.target-branch }}
42+
echo "Branch ${{ inputs.target-branch }} updated with changes from ${{ inputs.source-branch }}"
43+
shell: pwsh

.github/workflows/tagrelease.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Tag Release
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
build-host:
7+
required: true
8+
type: string
9+
version:
10+
required: true
11+
type: string
12+
13+
# Allows you to run this workflow manually from the Actions tab
14+
workflow_dispatch:
15+
16+
concurrency:
17+
group: ${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
packageRelease:
22+
name: Package UPM Project and tag
23+
runs-on: ${{ inputs.build-host }}
24+
steps:
25+
- name: Script Version
26+
run: |
27+
echo "::group::Script Versioning"
28+
$scriptVersion = "1.0.2"
29+
echo "Build Script Version: $scriptVersion"
30+
echo "::endgroup::"
31+
shell: pwsh
32+
- uses: actions/checkout@v7
33+
with:
34+
fetch-depth: 0
35+
submodules: recursive
36+
clean: true
37+
token: ${{ secrets.GIT_PAT }}
38+
- uses: actions/setup-node@v6
39+
- name: Set Github vars
40+
run: |
41+
if([string]::IsNullOrEmpty('${{ secrets.GIT_USER_NAME }}')){
42+
if([string]::IsNullOrEmpty('${{ secrets.GIT_USER_NAME }}')){
43+
$gitUser = "action"
44+
$gitEmail = "action@github.com"
45+
}
46+
else {
47+
$gitUser = "${GITHUB_ACTOR}"
48+
$gitEmail = "$gitUser@users.noreply.github.com"
49+
}
50+
}
51+
else {
52+
$gitUser = "${{ secrets.GIT_USER_NAME }}"
53+
$gitEmail = "$gitUser@users.noreply.github.com"
54+
}
55+
git config --global user.email "$gitUser@users.noreply.github.com"
56+
git config --global user.name "$gitUser"
57+
shell: pwsh
58+
- name: Check if Tag Exists
59+
run: |
60+
$tagVersion = "${{ inputs.version }}"
61+
$tags = git tag
62+
echo "Tags found are [$tags], searching for [$tagVersion]"
63+
foreach ($tag in $tags)
64+
{
65+
if($tag.Trim() -eq "$tagVersion")
66+
{
67+
Write-Error "$tagVersion tag already exists"
68+
exit 1
69+
}
70+
}
71+
shell: pwsh
72+
- name: Create tag and push
73+
run: |
74+
$tagVersion = "${{ inputs.version }}"
75+
git tag -fa "v$tagVersion" "${GITHUB_SHA}" -m "v$tagVersion Release [skip ci]"
76+
git push origin "v$tagVersion" --force
77+
shell: pwsh

0 commit comments

Comments
 (0)