Build and Publish WebdriverIO Native Demo Apps #26
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: Build and Publish WebdriverIO Native Demo Apps | |
on: | |
workflow_dispatch: | |
inputs: | |
releaseType: | |
description: 'Release type - major, minor or patch' | |
required: true | |
default: 'patch' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
prepare_release: | |
runs-on: macos-latest | |
outputs: | |
new_version: ${{ steps.set_new_version.outputs.new_version }} | |
steps: | |
- name: ⬇️ Checkout Repository | |
uses: actions/checkout@v3 | |
- name: 🌲 Setup Git | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "WebdriverIO Release Bot" | |
- name: 🌲 Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20.x' | |
- name: 🧩 Install Dependencies | |
run: npm ci | |
- name: 🔄 Increment Version and Build Number | |
id: set_new_version | |
run: | | |
echo "new_version=$(npm version ${{ github.event.inputs.releaseType }} --no-git-tag-version)" >> $GITHUB_ENV | |
echo "New version: $new_version" | |
npm run build.versions | |
- name: 🌿 Create Pre-Release Branch | |
run: | | |
git checkout -b pre-release | |
git add . | |
git commit -m "chore: Preparing for release $NEW_VERSION" | |
git push origin pre-release | |
android_build: | |
needs: prepare_release | |
runs-on: ubuntu-latest | |
steps: | |
- name: ⬇️ Checkout Pre-Release Branch | |
uses: actions/checkout@v3 | |
with: | |
ref: pre-release | |
- name: 🧳 Cache Gradle Wrapper | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle-wrapper.properties') }} | |
- name: 🧳 Cache Gradle Dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
key: ${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle*', '**/gradle.lockfile') }} | |
restore-keys: | | |
${{ runner.os }}-gradle-cache- | |
- name: ☕ Setup Java and Android SDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: '17.x' | |
- name: 🌲 Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20.x' | |
- name: 🧩 Install Dependencies | |
run: npm ci | |
- name: 🏗️ Build Android Release | |
run: npm run android.release | |
- name: 📦 Move 🤖 Android Build | |
run: mv android/app/build/outputs/apk/release/app-release.apk android.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.apk | |
- name: 📤 Upload Android App | |
uses: actions/upload-artifact@v3 | |
with: | |
name: android.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.apk | |
path: android.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.apk | |
ios_build: | |
needs: prepare_release | |
# for https://github.com/facebook/react-native/issues/38294 | |
runs-on: macos-13 | |
steps: | |
- name: ⬇️ Checkout Pre-Release Branch | |
uses: actions/checkout@v3 | |
with: | |
ref: pre-release | |
- name: 🧳 Cache Cocoapods Pods | |
uses: actions/cache@v3 | |
with: | |
path: ios/Pods | |
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}-20231231 | |
restore-keys: | | |
${{ runner.os }}-pods- | |
- name: 🌲 Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20.x' | |
- name: 🧩 Install Dependencies | |
run: npm ci | |
# This is temp to fix the issue | |
# "error Cannot start server in new window because no terminal app was specified." | |
- name: 🚇 Start Metro Bundler | |
run: npm start -- --reset-cache & | |
# Using the 'verbose' xcodebuild command instead of the RN command | |
# to be able to alter the build path | |
- name: 🏗️ Build iOS Release | |
run: | | |
cd ios | |
pod install | |
xcodebuild \ | |
-workspace wdiodemoapp.xcworkspace \ | |
-configuration Release \ | |
-scheme wdiodemoapp \ | |
-sdk iphonesimulator \ | |
-derivedDataPath ./build \ | |
CODE_SIGN_IDENTITY="" \ | |
CODE_SIGNING_REQUIRED=NO | |
CODE_SIGNING_ALLOWED=NO | |
- name: 🛑 Stop Metro Bundler | |
if: always() | |
run: kill $(jobs -p) || true | |
- name: 📦 Zip and move iOS Simulator Build | |
run: | | |
mkdir Payload | |
cp -R ios/build/Build/Products/Release-iphonesimulator/wdiodemoapp.app Payload | |
zip -9 -r ios.simulator.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.zip Payload | |
rm -rf Payload | |
- name: 📤 Upload iOS App | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ios.simulator.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.zip | |
path: ios.simulator.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.zip | |
finalize: | |
needs: [prepare_release, android_build, ios_build] | |
runs-on: ubuntu-latest | |
if: success() | |
steps: | |
- name: ⬇️ Checkout Pre-Release Branch | |
uses: actions/checkout@v3 | |
with: | |
ref: pre-release | |
fetch-depth: 0 | |
- name: 🌲 Setup Git | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "WebdriverIO Release Bot" | |
- name: 🔖 Tag New Release | |
run: | | |
git tag -a "${{ needs.prepare_release.outputs.new_version }}" -m "Release ${{ needs.prepare_release.outputs.new_version }}" | |
git push origin "${{ needs.prepare_release.outputs.new_version }}" | |
- name: 🔀 Merge Pre-Release to Main | |
run: | | |
git fetch | |
git checkout main | |
git merge --no-ff pre-release -m "Merging pre-release to main: Release ${{ needs.prepare_release.outputs.new_version }}" || echo "Merge failed, printing diffs next." | |
git push origin main | |
continue-on-error: true | |
- name: 🕵️ Print Diffs if Merge Fails | |
if: failure() | |
run: | | |
echo "Printing diffs between main and pre-release..." | |
git diff main pre-release | |
echo "DIFFS_PRINTED=true" >> $GITHUB_ENV | |
- name: 🔥 Delete Pre-Release Branch | |
run: | | |
git push origin --delete pre-release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: 🚀 Create GitHub Release | |
id: create_release | |
if: env.DIFFS_PRINTED != 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
TAG_NAME: ${{ needs.prepare_release.outputs.new_version }} | |
RELEASE_NAME: Release ${{ needs.prepare_release.outputs.new_version }} | |
DRAFT: true | |
PRE_RELEASE: false | |
run: | | |
chmod +x .github/scripts/create_release.sh | |
.github/scripts/create_release.sh | |
- name: 📥 Download Android App Artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: android.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.apk | |
- name: 📥 Download iOS App Artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: ios.simulator.wdio.native.app.${{ needs.prepare_release.outputs.new_version }}.zip | |
- name: 📤 Upload Artifacts to Release | |
if: env.DIFFS_PRINTED != 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
chmod +x .github/scripts/upload_artifacts.sh "${{ steps.create_release.outputs.upload_url }}" ${{ needs.prepare_release.outputs.new_version }} ${{ secrets.GITHUB_TOKEN }} | |
.github/scripts/upload_artifacts.sh | |
cleanup: | |
runs-on: ubuntu-latest | |
if: ${{ failure() && (needs.prepare_release.result == 'failure' || needs.android_build.result == 'failure' || needs.ios_build.result == 'failure' || needs.finalize.result == 'failure') }} | |
needs: [prepare_release, android_build, ios_build, finalize] | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: 🔥 Delete Pre-Release Branch | |
run: | | |
git push origin --delete pre-release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |