Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- added `upm-branch` input
- fixed branch calculation
- updated version checkin push
  • Loading branch information
StephenHodgson authored Feb 8, 2024
1 parent 273c69c commit a589d1c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: xrtk/upm-release@v5
- uses: xrtk/upm-release@v5.1
name: publish upm package
with:
upm-username: 'xrtk-build-bot'
Expand Down
48 changes: 28 additions & 20 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,19 @@ inputs:
description: 'Is this package in preview?'
required: false
default: 'false'
upm-branch:
description: 'The branch to use for the UPM release. (Defaults to upm)'
required: false
default: 'upm'

runs:
using: "composite"
steps:
- id: target
name: Set target branch
if: ${{ github.ref != 'refs/heads/upm' && github.base_ref != 'upm' }}
run: |
$isPreview = '${{ github.base_ref == 'main' }}'
if ($isPreview -eq 'true') {
$branch = '${{ github.head_ref }}'
} else {
$branch = '${{ github.ref }}'
}
"BRANCH=$branch" >> $env:GITHUB_ENV
shell: pwsh

- uses: actions/checkout@v4
if: ${{ github.ref != 'refs/heads/upm' && github.base_ref != 'upm' }}
with:
token: ${{ inputs.github-token }}
ref: ${{ env.BRANCH }}
ref: ${{ inputs.upm-branch }}
fetch-depth: 0

- uses: actions/[email protected]
Expand Down Expand Up @@ -99,7 +88,15 @@ runs:
name: Validate Package Version
run: |
# validate version
$branch = '${{ env.BRANCH }}'
$branch = '${{ inputs.upm-branch }}'
if ([string]::IsNullOrEmpty($branch)) {
Write-Error "Failed to determine the branch to use for pushing the release."
exit 1
}
Write-Host "::debug::Release Branch: $branch"
$isPreview = '${{ github.base_ref == 'main' || inputs.preview == 'true' }}'
$packageDir = Get-Item -Path "${{ inputs.package-root }}" | Select-Object -ExpandProperty FullName
Expand Down Expand Up @@ -188,18 +185,31 @@ runs:
"VERSION=$version" >> $env:GITHUB_ENV
$packageInfo | ConvertTo-Json | Set-Content $packageFile
Write-Host "::debug::set git config"
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "GitHub Actions"
Write-Host "::debug::check current status"
git status
Write-Host "::debug::checkout $branch"
git checkout $branch
Write-Host "::debug::pull latest changes"
git pull
Write-Host "::debug::add package.json"
git add $packageFile
foreach ($file in $updatedFiles) {
git add $file
}
Write-Host "::debug::check current status"
git status
Write-Host "::debug::check branch"
git branch
Write-Host "::debug::commit version changes"
git commit -m "[skip ci] $version"
git push https://${{ inputs.github-username }}:$env:[email protected]/${{ github.repository }}.git $branch --force
Write-Host "::debug::push version changes"
git push https://${{ inputs.github-token }}@github.com/${{ github.repository }}.git $branch --force
$exit = 0
if ($LASTEXITCODE -gt 0) {
Expand All @@ -210,8 +220,6 @@ runs:
exit $exit
shell: pwsh
working-directory: ${{ github.workspace }}
env:
GITHUB_TOKEN: ${{ inputs.github-token }}

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

0 comments on commit a589d1c

Please sign in to comment.