forked from flutter/flutter
-
Notifications
You must be signed in to change notification settings - Fork 1
89 lines (77 loc) · 2.98 KB
/
cut-release-branch.yml
File metadata and controls
89 lines (77 loc) · 2.98 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Cut Release Branch
on:
workflow_dispatch:
inputs:
version:
description: 'Version string (format X.Y)'
required: true
type: string
commit_hash:
description: 'The hash of the commit to branch off of'
required: true
type: string
jobs:
check-membership:
runs-on: ubuntu-latest
outputs:
is_member: ${{ steps.check.outputs.is_member }}
steps:
- name: Check if user is in the required team
id: check
env:
GH_TOKEN: ${{ secrets.FLUTTER_READ_ORG }}
run: |
# Use the GitHub CLI to check team membership
# Returns 204 if member, 404 if not
if gh api orgs/flutter/teams/flutter-release-eng/memberships/${{ github.actor }} --silent; then
echo "is_member=true" >> $GITHUB_OUTPUT
else
echo "::error::User ${{ github.actor }} is not a member of flutter-release-eng."
exit 1
fi
create-release-branch:
needs: check-membership
runs-on: ubuntu-latest
permissions:
contents: write # Required to create branches and push commits
steps:
- name: Validate Version Format
run: |
if [[ ! "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+$ ]]; then
echo "Error: Version must be in 'X.Y' format (e.g., 3.10)."
exit 1
fi
- name: Checkout target commit
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
ref: ${{ inputs.commit_hash }}
token: ${{ secrets.FLUTTERACTIONSBOT_CP_TOKEN }}
- name: Set Environment Variables
run: |
echo "BRANCH_NAME=flutter-${{ inputs.version }}-candidate.0" >> $GITHUB_ENV
- name: Check if branch already exists
run: |
if git ls-remote --exit-code --heads origin ${{ env.BRANCH_NAME }}; then
echo "Error: Branch ${{ env.BRANCH_NAME }} already exists on remote."
exit 1
fi
- name: Configure Git
run: |
git config user.name "flutteractionsbot"
git config user.email "<flutter-actions-bot@google.com>"
- name: Create Branch and Version File
run: |
# Create and switch to the new branch locally
git checkout -b ${{ env.BRANCH_NAME }}
# Create the version file
mkdir -p bin/internal/
echo -n "${{ env.BRANCH_NAME }}" > bin/internal/release-candidate-branch.version
# Commit the change
git add bin/internal/release-candidate-branch.version
git commit -m "Initialize release branch ${{ env.BRANCH_NAME }}"
- name: Push new branch
run: |
git push origin ${{ env.BRANCH_NAME }}
echo "## Release Branch \`${{ env.BRANCH_NAME }}\` Cut Successfully" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "🔗 **View Branch** https://github.com/$GITHUB_REPOSITORY/tree/${{ env.BRANCH_NAME }}" >> $GITHUB_STEP_SUMMARY