-
Notifications
You must be signed in to change notification settings - Fork 1
114 lines (97 loc) · 3.96 KB
/
create-release-candidate.yml
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
name: Create Release Branch and Build RC
on:
workflow_dispatch:
jobs:
create-release-branch:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.read_version.outputs.VERSION }}
branch_name: ${{ steps.read_version.outputs.BRANCH_NAME }}
commit_sha: ${{ steps.get_commit_sha.outputs.COMMIT_SHA }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: develop
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Read package.json version
id: read_version
run: |
version=$(node -p "require('./package.json').version")
major=$(echo $version | cut -d. -f1)
minor=$(echo $version | cut -d. -f2)
patch=$(echo $version | cut -d. -f3 | cut -d- -f1)
new_version="${major}.${minor}.${patch}-RC.0"
branch_name="release/v${major}.${minor}.${patch}"
echo "VERSION=$new_version" >> $GITHUB_ENV
echo "BRANCH_NAME=$branch_name" >> $GITHUB_ENV
echo "::set-output name=VERSION::$new_version"
echo "::set-output name=BRANCH_NAME::$branch_name"
- name: Configure git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Create and push new branch
run: |
name=${{ env.BRANCH_NAME }}
echo "Creating and pushing new branch $name"
git checkout -b $name || { echo "ERROR: Branch creation failed"; exit 1; }
git push origin $name --force || { echo "ERROR: Push failed"; exit 1; }
- name: Get latest commit SHA
id: get_commit_sha
run: |
commit_sha=$(git rev-parse HEAD)
echo "Commit SHA: $commit_sha"
echo "COMMIT_SHA=$commit_sha" >> $GITHUB_ENV
echo "::set-output name=COMMIT_SHA::$commit_sha"
- name: Check if deploy branch exists
id: check_deploy_branch
run: |
if git ls-remote --exit-code --heads origin deploy; then
echo "Deploy branch exists."
echo "DEPLOY_BRANCH_EXISTS=true" >> $GITHUB_ENV
else
echo "Deploy branch does not exist."
echo "DEPLOY_BRANCH_EXISTS=false" >> $GITHUB_ENV
fi
- name: Create Pull Request to deploy
if: env.DEPLOY_BRANCH_EXISTS == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
new_version=${{ env.VERSION }}
branch_name=${{ env.BRANCH_NAME }}
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $GITHUB_TOKEN" \
-d "{\"title\":\"$branch_name\",\"body\":\"This PR is for the release of version $new_version\",\"head\":\"$branch_name\",\"base\":\"deploy\"}" \
https://api.github.com/repos/${{ github.repository }}/pulls
- name: Notify if deploy branch is missing
if: env.DEPLOY_BRANCH_EXISTS == 'false'
run: echo "The deploy branch does not exist. Please create it manually."
dispatch-eas-build:
runs-on: ubuntu-latest
needs: create-release-branch
steps:
- name: 🏗 Setup EAS
uses: expo/expo-github-action@v8
with:
eas-version: latest
token: ${{ secrets.EXPO }}
- name: Checkout Release Branch
uses: actions/checkout@v3
with:
ref: ${{ needs.create-release-branch.outputs.branch_name }}
- name: 📦 Install dependencies
run: npm install
- name: Build Release Candidate APK
env:
COMMIT_SHA: ${{ needs.create-release-branch.outputs.commit_sha }}
VERSION: ${{ needs.create-release-branch.outputs.version }}
run: |
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "COMMIT_SHA=${COMMIT_SHA}" >> $GITHUB_ENV
eas build --platform android --profile release-candidate