Skip to content

Release 🚀

Release 🚀 #1

Workflow file for this run

# This workflow is based on the https://github.com/gladiuscode/github-actions-playground repository.
name: Release 🚀
on:
workflow_dispatch:
inputs:
dry-run:
description: 'Run release-it in dry-run mode'
required: false
default: false
type: boolean
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
- name: Lint library & example files
run: yarn lint
- name: Lint plugin files
run: yarn expo-plugin lint
- name: Typecheck library & example files
run: yarn typecheck
- name: Typecheck plugin files
run: yarn expo-plugin typecheck
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
- name: Run unit tests
run: yarn test --maxWorkers=2 --coverage
build-library:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
- name: Build package
run: yarn prepare
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: build-library-artifact
path: lib
build-plugin:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
- name: Build package
run: yarn expo-plugin prepare
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: build-plugin-artifact
path: plugin
build-android:
runs-on: ubuntu-latest
env:
TURBO_CACHE_DIR: .turbo/android
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
- name: Cache turborepo for Android
uses: actions/cache@v3
with:
path: ${{ env.TURBO_CACHE_DIR }}
key: ${{ runner.os }}-turborepo-android-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-turborepo-android-
- name: Check turborepo cache for Android
run: |
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
echo "turbo_cache_hit=1" >> $GITHUB_ENV
fi
- name: Install JDK
if: env.turbo_cache_hit != 1
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
- name: Finalize Android SDK
if: env.turbo_cache_hit != 1
run: |
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
- name: Cache Gradle
if: env.turbo_cache_hit != 1
uses: actions/cache@v3
with:
path: |
~/.gradle/wrapper
~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Run test
if: env.turbo_cache_hit != 1
run: |
cd example/android && ./gradlew react-native-orientation-director:testDebugUnitTest
- name: Build example for Android
env:
JAVA_OPTS: '-XX:MaxHeapSize=6g'
run: |
yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"
build-ios:
runs-on: macos-14
env:
TURBO_CACHE_DIR: .turbo/ios
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
- name: Cache turborepo for iOS
uses: actions/cache@v3
with:
path: ${{ env.TURBO_CACHE_DIR }}
key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-turborepo-ios-
- name: Check turborepo cache for iOS
run: |
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
echo "turbo_cache_hit=1" >> $GITHUB_ENV
fi
- name: Cache cocoapods
if: env.turbo_cache_hit != 1
id: cocoapods-cache
uses: actions/cache@v3
with:
path: |
**/ios/Pods
key: ${{ runner.os }}-cocoapods-${{ hashFiles('example/ios/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-cocoapods-
- name: Install cocoapods
if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true'
run: |
cd example/ios
pod install
env:
NO_FLIPPER: 1
RCT_NEW_ARCH_ENABLED: 1
- name: Build example for iOS
run: |
yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"
release:
name: Release
runs-on: ubuntu-latest
needs: [lint, test, build-plugin, build-library, build-android, build-ios]
steps:
# (1) Create a GitHub App token
# Note: the Github App must be installed on the repository and included in the bypass list of the ruleset.
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@v4
with:
# (2) Use the GitHub App token to init the repository
token: ${{ steps.app-token.outputs.token }}
# (3) Fetch all history so that release-it can determine the version
fetch-depth: 0
- name: Setup
uses: ./.github/actions/setup
# (4) Configure Git user
- name: Configure Git User
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Download Build Library Artifact
uses: actions/download-artifact@v4
with:
name: build-library-artifact
- name: Download Build Plugin Artifact
uses: actions/download-artifact@v4
with:
name: build-plugin-artifact
- name: Display current working directory
run: ls -R
- name: Release
run: |
if [ ${{ inputs.dry-run }} = true ]; then
yarn release-it --dry-run
else
yarn release-it
fi
env:
# (5) Make GITHUB_TOKEN available to release-it but use the GitHub App token
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
# (6) Make NPM_ACCESS_TOKEN available to release-it and npm publish command
NPM_ACCESS_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}