-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (65 loc) · 2.57 KB
/
prep-release.yml
File metadata and controls
73 lines (65 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Prepares release information and branch, outputs release metadata
# Avoid passing `target_repo`, just used by sdk-shared itself
name: Release Preparation
on:
workflow_call:
inputs:
version:
required: true
type: string
description: The new version being released (e.g., 5.2.15-beta.1)
target_branch:
required: false
type: string
description: The branch to target for the release branch creation
default: main
target_repo:
required: false
type: string
description: FOR WRAPPERS ONLY. The repository to target for the release branch creation
secrets:
GH_PUSH_TOKEN:
required: false
description: GitHub token with push permissions
outputs:
release_branch:
description: Name of the release branch
value: ${{ jobs.prepare_release.outputs.release_branch }}
jobs:
prepare_release:
runs-on: ubuntu-latest
outputs:
release_branch: ${{ steps.release_branch.outputs.releaseBranch }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
ref:
${{ inputs.target_branch }}
# To be set by callee since we have nested reusable workflows call which gets to set to the caller repo by default
# But we need to create the release branch in the callee's repository
repository: ${{ inputs.target_repo || github.repository }}
token: ${{ secrets.GH_PUSH_TOKEN || github.token }}
- name: Release branch name
id: release_branch
run: |
# Use the full version including alpha/beta suffix
echo "releaseBranch=rel/${{ inputs.version }}" >> $GITHUB_OUTPUT
- name: Setup Git user
uses: onesignal/sdk-shared/.github/actions/setup-git-user@main
- name: Create or rebase release branch
run: |
releaseBranch="${{ steps.release_branch.outputs.releaseBranch }}"
targetBranch="${{ inputs.target_branch }}"
# Check if branch already exists on remote
if git ls-remote --heads origin "$releaseBranch" | grep -q "$releaseBranch"; then
echo "ℹ️ Branch $releaseBranch already exists, rebasing onto $targetBranch"
git fetch origin "$releaseBranch"
git checkout "$releaseBranch"
git rebase "origin/$targetBranch"
git push --force-with-lease origin "$releaseBranch"
else
# Create branch and push
git checkout -b "$releaseBranch"
git push -u origin "$releaseBranch"
fi