Create Release Branch and Build RC #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} | |
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}.0-RC.0" | |
echo "VERSION=$new_version" >> $GITHUB_ENV | |
echo "::set-output name=VERSION::$new_version" | |
- 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: | | |
new_version=${{ env.VERSION }} | |
echo "Creating and pushing new branch release/v$new_version" | |
git checkout -b release/v$new_version || { echo "ERROR: Branch creation failed"; exit 1; } | |
git push origin release/v$new_version --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 }} | |
curl -X POST \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
-d "{\"title\":\"Release v$new_version\",\"body\":\"This PR is for the release of version $new_version\",\"head\":\"release/v$new_version\",\"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: release/v${{ needs.create-release-branch.outputs.version }} | |
- 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: eas build --platform android --profile release-candidate |