-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
132 lines (120 loc) · 4.68 KB
/
build-rc-auto.yml
File metadata and controls
132 lines (120 loc) · 4.68 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
##############################################################################################
#
# This Workflow is responsible for triggering release candidate builds (iOS & Android).
# It runs on every commit pushed to a release branch, but only when the release PR
# has the 'auto-rc-builds' label.
#
##############################################################################################
name: Auto RC builds
on:
push:
branches:
- 'release/*'
# testing branch.
# remove before merge
#
- 'rc-builds-gh-workflow'
jobs:
validate-and-check-label:
name: Validate branch and check PR label
runs-on: ubuntu-latest
outputs:
semver: ${{ steps.extract-version.outputs.semver }}
has-label: ${{ steps.check-label.outputs.has-label }}
permissions:
pull-requests: read
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Extract semver from branch name
id: extract-version
run: |
BRANCH_NAME="${{ github.ref_name }}"
echo "Checking branch: $BRANCH_NAME"
# bypass branch validation
# remove before merge
echo "semver=7.99.999" >> "$GITHUB_OUTPUT"
# Validate branch matches release/x.y.z format (semantic versioning)
# if [[ "$BRANCH_NAME" =~ ^release/[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
# VERSION="${BRANCH_NAME#release/}"
# echo "Valid release branch detected: $BRANCH_NAME (version: $VERSION)"
# echo "semver=$VERSION" >> "$GITHUB_OUTPUT"
# else
# echo "Branch '$BRANCH_NAME' does not match release/x.y.z pattern. Skipping."
# echo "semver=" >> "$GITHUB_OUTPUT"
# exit 1
# fi
- name: Find PR and check for auto-rc-builds label
id: check-label
run: |
BRANCH_NAME="${{ github.ref_name }}"
echo "Looking for PR with head branch: $BRANCH_NAME"
# Find PRs where the head branch matches our release branch
PR_NUMBER=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number' || echo "")
if [[ -z "$PR_NUMBER" ]]; then
echo "No PR found for branch $BRANCH_NAME. Skipping."
echo "has-label=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "Found PR #$PR_NUMBER"
# Check if PR has the auto-rc-builds label
LABELS=$(gh pr view "$PR_NUMBER" --json labels --jq '.labels[].name' || echo "")
if echo "$LABELS" | grep -qx "auto-rc-builds"; then
echo "PR #$PR_NUMBER has 'auto-rc-builds' label. Proceeding with build."
echo "has-label=true" >> "$GITHUB_OUTPUT"
else
echo "PR #$PR_NUMBER does not have 'auto-rc-builds' label. Skipping build."
echo "has-label=false" >> "$GITHUB_OUTPUT"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
generate-build-version:
uses: MetaMask/metamask-mobile-build-version/.github/workflows/metamask-mobile-build-version.yml@v0.3.0
permissions:
id-token: write
needs: validate-and-check-label
if: needs.validate-and-check-label.outputs.has-label == 'true'
bump-version:
runs-on: ubuntu-latest
needs:
- validate-and-check-label
- generate-build-version
if: needs.validate-and-check-label.outputs.has-label == 'true'
outputs:
commit-hash: ${{ steps.bump-script.outputs.commit-hash }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.ref }}
token: ${{ secrets.PR_TOKEN }}
- id: bump-script
uses: ./.github/actions/bump-build-version
with:
build-version: ${{ needs.generate-build-version.outputs.build-version }}
ref: ${{ github.ref_name }}
trigger-rc-build:
runs-on: ubuntu-latest
needs:
- validate-and-check-label
- generate-build-version
- bump-version
if: needs.validate-and-check-label.outputs.has-label == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.ref }}
- name: Trigger RC Build
env:
SEMVER: ${{ needs.validate-and-check-label.outputs.semver }}
GH_REF_NAME: ${{ github.ref_name }}
COMMIT_HASH: ${{ needs.bump-version.outputs.commit-hash }}
BUILD_NUMBER: ${{ needs.generate-build-version.outputs.build-version }}
BITRISE_APP_ID: ${{ secrets.BITRISE_APP_ID }}
BITRISE_BUILD_TRIGGER_TOKEN: ${{ secrets.BITRISE_BUILD_TRIGGER_TOKEN }}
BITRISE_API_TOKEN: ${{ secrets.BITRISE_API_TOKEN }}
run: ./scripts/rc-builds.sh