Skip to content

Commit a589d1c

Browse files
- added `upm-branch` input - fixed branch calculation - updated version checkin push
1 parent 273c69c commit a589d1c

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
runs-on: ubuntu-latest
2323

2424
steps:
25-
- uses: xrtk/upm-release@v5
25+
- uses: xrtk/upm-release@v5.1
2626
name: publish upm package
2727
with:
2828
upm-username: 'xrtk-build-bot'

action.yaml

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,19 @@ inputs:
3333
description: 'Is this package in preview?'
3434
required: false
3535
default: 'false'
36+
upm-branch:
37+
description: 'The branch to use for the UPM release. (Defaults to upm)'
38+
required: false
39+
default: 'upm'
3640

3741
runs:
3842
using: "composite"
3943
steps:
40-
- id: target
41-
name: Set target branch
42-
if: ${{ github.ref != 'refs/heads/upm' && github.base_ref != 'upm' }}
43-
run: |
44-
$isPreview = '${{ github.base_ref == 'main' }}'
45-
46-
if ($isPreview -eq 'true') {
47-
$branch = '${{ github.head_ref }}'
48-
} else {
49-
$branch = '${{ github.ref }}'
50-
}
51-
52-
"BRANCH=$branch" >> $env:GITHUB_ENV
53-
shell: pwsh
54-
5544
- uses: actions/checkout@v4
5645
if: ${{ github.ref != 'refs/heads/upm' && github.base_ref != 'upm' }}
5746
with:
5847
token: ${{ inputs.github-token }}
59-
ref: ${{ env.BRANCH }}
48+
ref: ${{ inputs.upm-branch }}
6049
fetch-depth: 0
6150

6251
- uses: actions/[email protected]
@@ -99,7 +88,15 @@ runs:
9988
name: Validate Package Version
10089
run: |
10190
# validate version
102-
$branch = '${{ env.BRANCH }}'
91+
$branch = '${{ inputs.upm-branch }}'
92+
93+
if ([string]::IsNullOrEmpty($branch)) {
94+
Write-Error "Failed to determine the branch to use for pushing the release."
95+
exit 1
96+
}
97+
98+
Write-Host "::debug::Release Branch: $branch"
99+
103100
$isPreview = '${{ github.base_ref == 'main' || inputs.preview == 'true' }}'
104101
105102
$packageDir = Get-Item -Path "${{ inputs.package-root }}" | Select-Object -ExpandProperty FullName
@@ -188,18 +185,31 @@ runs:
188185
"VERSION=$version" >> $env:GITHUB_ENV
189186
$packageInfo | ConvertTo-Json | Set-Content $packageFile
190187
188+
Write-Host "::debug::set git config"
189+
git config user.email "github-actions[bot]@users.noreply.github.com"
190+
git config user.name "GitHub Actions"
191+
192+
Write-Host "::debug::check current status"
191193
git status
194+
Write-Host "::debug::checkout $branch"
192195
git checkout $branch
196+
Write-Host "::debug::pull latest changes"
193197
git pull
198+
Write-Host "::debug::add package.json"
194199
git add $packageFile
195200
196201
foreach ($file in $updatedFiles) {
197202
git add $file
198203
}
199204
205+
Write-Host "::debug::check current status"
200206
git status
207+
Write-Host "::debug::check branch"
208+
git branch
209+
Write-Host "::debug::commit version changes"
201210
git commit -m "[skip ci] $version"
202-
git push https://${{ inputs.github-username }}:$env:[email protected]/${{ github.repository }}.git $branch --force
211+
Write-Host "::debug::push version changes"
212+
git push https://${{ inputs.github-token }}@github.com/${{ github.repository }}.git $branch --force
203213
$exit = 0
204214
205215
if ($LASTEXITCODE -gt 0) {
@@ -210,8 +220,6 @@ runs:
210220
exit $exit
211221
shell: pwsh
212222
working-directory: ${{ github.workspace }}
213-
env:
214-
GITHUB_TOKEN: ${{ inputs.github-token }}
215223

216224
- uses: RageAgainstThePixel/[email protected]
217225
if: ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && env.VERSION != '' }}

0 commit comments

Comments
 (0)