@@ -4,7 +4,7 @@ permissions:
44
55on :
66 push :
7- branches : [main]
7+ branches : ["**"] # Run on all branches
88 workflow_dispatch :
99
1010env :
2121 build_number : ${{ steps.version-control.outputs.build_number }}
2222 build_date : ${{ steps.version-control.outputs.build_date }}
2323 is_production : ${{ steps.version-control.outputs.is_production }}
24+ branch_name : ${{ steps.extract-branch.outputs.branch_name }}
2425 steps :
2526 # ========================
2627 # 🛠️ Repository Setup
3031 with :
3132 fetch-depth : 0
3233
34+ - name : " 🔍 Extract branch name"
35+ id : extract-branch
36+ shell : bash
37+ run : |
38+ BRANCH_NAME=${GITHUB_REF#refs/heads/}
39+ echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
40+ echo "Branch: $BRANCH_NAME"
41+
3342 # ========================
3443 # ⚙️ Environment Configuration
3544 # ========================
7382 APP_VERSION=$(jq -r '.version' version.json)
7483 IS_PRODUCTION="true"
7584 else
76- APP_VERSION="1.0.0-prerelease.${{ github.run_number }}"
85+ # For non-main branches, create a prerelease version with branch name
86+ BRANCH_NAME=${{ steps.extract-branch.outputs.branch_name }}
87+ SANITIZED_BRANCH=$(echo "$BRANCH_NAME" | sed 's/[^a-zA-Z0-9]/-/g')
88+ # Get base version from version.json
89+ BASE_VERSION=$(jq -r '.version' version.json)
90+ APP_VERSION="${BASE_VERSION}-pre.${SANITIZED_BRANCH}.${{ github.run_number }}"
7791 IS_PRODUCTION="false"
7892 fi
7993
@@ -109,7 +123,17 @@ jobs:
109123 run : |
110124 echo "🔄 Initializing build process..."
111125 sudo apt-get install -y jq
112- BUILD_JSON=$(npx eas build -p android --profile production --non-interactive --json)
126+
127+ # Choose profile based on branch
128+ if [ "${{ github.ref }}" == "refs/heads/main" ]; then
129+ BUILD_PROFILE="production"
130+ else
131+ BUILD_PROFILE="preview" # Use a different profile for pre-releases if needed
132+ fi
133+
134+ echo "Using build profile: $BUILD_PROFILE"
135+
136+ BUILD_JSON=$(npx eas build -p android --profile $BUILD_PROFILE --non-interactive --json)
113137 echo "Raw build output: $BUILD_JSON"
114138 BUILD_ID=$(echo "$BUILD_JSON" | jq -r '.[0].id')
115139 if [[ -z "$BUILD_ID" || "$BUILD_ID" == "null" ]]; then
@@ -274,7 +298,6 @@ jobs:
274298 CHANGELOG=$(git log --pretty=format:"- %s (%h) by %an" -n 15)
275299 echo "$CHANGELOG" > changelog.txt
276300
277- # FIXED OUTPUT HANDLING (ONLY CHANGE)
278301 delimiter=$(openssl rand -hex 6)
279302 echo "CHANGELOG<<${delimiter}" >> $GITHUB_OUTPUT
280303 cat changelog.txt >> $GITHUB_OUTPUT
@@ -316,11 +339,14 @@ jobs:
316339 RELEASE_TAG="v${{ needs.build-android.outputs.app_version }}"
317340 RELEASE_TITLE="Production Release v${{ needs.build-android.outputs.app_version }}"
318341 else
319- echo "🟡 Nightly build detected"
320- RELEASE_TAG="nightly-${{ needs.build-android.outputs.build_date }}"
321- RELEASE_TITLE="Nightly Build (${{ needs.build-android.outputs.build_date }})"
342+ echo "🟡 Pre-release build detected"
343+ BRANCH_NAME="${{ needs.build-android.outputs.branch_name }}"
344+ RELEASE_TAG="prerelease-${BRANCH_NAME}-${{ needs.build-android.outputs.build_date }}"
345+ RELEASE_TITLE="Pre-release (${BRANCH_NAME}) v${{ needs.build-android.outputs.app_version }}"
322346 fi
323347 echo "RELEASE_TAG=${RELEASE_TAG}" >> $GITHUB_OUTPUT
348+ echo "RELEASE_TITLE=${RELEASE_TITLE}" >> $GITHUB_OUTPUT
349+
324350 - name : " 🎉 Publish GitHub Release"
325351 uses : softprops/action-gh-release@v2
326352 with :
0 commit comments