disable wip react native activity #49
Workflow file for this run
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: CNPlus CI | |
env: | |
# The name of the main module repository | |
main_project_module: app | |
# The name of the Play Store | |
app_name: "Calendar Notifications Plus" | |
app_file_name_prefix: "calendar_notifications_plus" | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- '**' | |
pull_request: | |
branches: | |
- "**" # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#patterns-to-match-branches-and-tags | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
install-and-build-android: | |
runs-on: ubuntu-latest | |
env: | |
ENTRY_FILE: "index.tsx" | |
timeout-minutes: 30 | |
strategy: | |
matrix: | |
node-version: [18.x, 20.x] | |
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | |
# https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: "yarn" | |
- name: Expose yarn config as "$GITHUB_OUTPUT" | |
id: yarn-config | |
shell: bash | |
run: | | |
echo "CACHE_FOLDER=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT | |
# Yarn rotates the downloaded cache archives, @see https://github.com/actions/setup-node/issues/325 | |
# Yarn cache is also reusable between arch and os. | |
- name: Restore yarn cache | |
uses: actions/cache@v3 | |
id: yarn-download-cache | |
with: | |
path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }} | |
key: yarn-download-cache-${{ hashFiles('yarn.lock') }} | |
restore-keys: | | |
yarn-download-cache- | |
# Invalidated on yarn.lock changes | |
- name: Restore yarn install state | |
id: yarn-install-state-cache | |
uses: actions/cache@v3 | |
with: | |
path: .yarn/ci-cache/ | |
key: ${{ runner.os }}-yarn-install-state-cache-${{ hashFiles('yarn.lock', '.yarnrc.yml') }} | |
- run: yarn install --immutable --inline-builds | |
env: | |
# CI optimizations. Overrides yarnrc.yml options (or their defaults) in the CI action. | |
YARN_ENABLE_GLOBAL_CACHE: 'false' # Use local cache folder to keep downloaded archives | |
YARN_NM_MODE: 'hardlinks-local' # Hardlinks-(local|global) reduces io / node_modules size | |
YARN_INSTALL_STATE_PATH: .yarn/ci-cache/install-state.gz # Very small speedup when lock does not change | |
# Other environment variables | |
HUSKY: '0' # By default do not run HUSKY install | |
# Where android build starts. one day we will have a separate job for this but i dont know how pass the node_modules cache to it | |
# Set Current Date As Env Variable | |
- name: Set current date as env variable | |
run: echo "build_datetime=$(date +'%Y-%m-%d %H_%M_%S')" >> $GITHUB_ENV | |
# Set Repository Name As Env Variable | |
- name: Set repository name as env variable | |
run: echo "repository_name=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV | |
- name: set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: gradle | |
- name: Grant execute permission for gradlew and show version | |
run: cd android && chmod +x gradlew && ./gradlew --version | |
- name: Build with Gradle | |
run: cd android && ./gradlew build --warning-mode all --info --stacktrace | |
# Create APK Debug | |
- name: Build apk debug project (APK) - ${{ env.main_project_module }} module | |
run: cd android && ./gradlew assembleDebug | |
# Create APK Release | |
- name: Build apk release project (APK) - ${{ env.main_project_module }} module | |
run: cd android && ./gradlew assemble | |
# Create Bundle AAB Release | |
# Noted for main module build [main_project_module]:bundleRelease | |
- name: Build app bundle release (AAB) - ${{ env.main_project_module }} module | |
run: cd android && ./gradlew ${{ env.main_project_module }}:bundleRelease | |
- uses: r0adkll/sign-android-release@v1 | |
name: Sign debug app APKs | |
# ID used to access action output | |
id: sign_debug_app | |
with: | |
releaseDirectory: android/${{ env.main_project_module }}/build/outputs/apk/debug/ | |
signingKeyBase64: ${{ secrets.DEBUG_SIGNING_KEYSTORE }} | |
alias: ${{ secrets.DEBUG_KEYSTORE_ALIAS }} | |
keyStorePassword: ${{ secrets.DEBUG_KEYSTORE_PASSWORD }} | |
keyPassword: ${{ secrets.DEBUG_KEYSTORE_ALIAS_PASS }} | |
env: | |
# override default build-tools version (33.0.0) -- optional | |
BUILD_TOOLS_VERSION: "34.0.0" | |
- uses: r0adkll/sign-android-release@v1 | |
name: Sign RELEASE app APKs | |
# ID used to access action output | |
id: sign_release_app | |
with: | |
releaseDirectory: android/${{ env.main_project_module }}/build/outputs/apk/release/ | |
signingKeyBase64: ${{ secrets.RELEASE_SIGNING_KEYSTORE }} | |
alias: ${{ secrets.RELEASE_KEYSTORE_ALIAS }} | |
keyStorePassword: ${{ secrets.RELEASE_KEYSTORE_PASSWORD }} | |
keyPassword: ${{ secrets.RELEASE_KEYSTORE_ALIAS_PASS }} | |
env: | |
# override default build-tools version (33.0.0) -- optional | |
BUILD_TOOLS_VERSION: "34.0.0" | |
- uses: r0adkll/sign-android-release@v1 | |
name: Sign RELEASE app AABs | |
# ID used to access action output | |
id: sign_release_aab | |
with: | |
releaseDirectory: android/${{ env.main_project_module }}/build/outputs/bundle/release/ | |
signingKeyBase64: ${{ secrets.RELEASE_SIGNING_KEYSTORE }} | |
alias: ${{ secrets.RELEASE_KEYSTORE_ALIAS }} | |
keyStorePassword: ${{ secrets.RELEASE_KEYSTORE_PASSWORD }} | |
keyPassword: ${{ secrets.RELEASE_KEYSTORE_ALIAS_PASS }} | |
env: | |
# override default build-tools version (33.0.0) -- optional | |
BUILD_TOOLS_VERSION: "34.0.0" | |
# for tags: calendar_notifications_plus-1.2.3-debug.apk | |
# for PRs: calendar_notifications_plus-pr-123-feature-branch-abcdef-debug.apk | |
# for pushes to branches other than main: calendar_notifications_plus-feature-branch-abcdef-debug.apk | |
- name: Rename APKs | |
run: | | |
sanitize_branch_name() { | |
echo "$1" | sed 's/[^a-zA-Z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//' | sed 's/-$//' | cut -c1-20 | |
} | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
# For tags | |
VERSION=${GITHUB_REF#refs/tags/v} | |
SUFFIX="-${VERSION}" | |
elif [[ $GITHUB_REF == refs/pull/* ]]; then | |
# For pull requests | |
PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }') | |
BRANCH_NAME=$(sanitize_branch_name "$GITHUB_HEAD_REF") | |
SHORT_SHA=$(echo $GITHUB_SHA | cut -c1-7) | |
SUFFIX="-pr-${PR_NUMBER}-${BRANCH_NAME}-${SHORT_SHA}" | |
else | |
# For pushes to branches other than main | |
BRANCH_NAME=$(sanitize_branch_name "${GITHUB_REF#refs/heads/}") | |
SHORT_SHA=$(echo $GITHUB_SHA | cut -c1-7) | |
SUFFIX="-${BRANCH_NAME}-${SHORT_SHA}" | |
fi | |
mv ${{steps.sign_debug_app.outputs.signedReleaseFile}} ${{env.app_file_name_prefix}}${SUFFIX}-debug.apk | |
mv ${{steps.sign_release_app.outputs.signedReleaseFile}} ${{env.app_file_name_prefix}}${SUFFIX}-release.apk | |
mv ${{steps.sign_release_aab.outputs.signedReleaseFile}} ${{env.app_file_name_prefix}}${SUFFIX}.aab | |
# # Upload Artifact Build | |
# # Noted For Output [main_project_module]/build/outputs/apk/debug/ | |
# - name: Upload unsigned APK Debug - ${{ env.repository_name }} | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: ${{ matrix.node-version }} - ${{ env.build_datetime }} - ${{ env.app_name }} - ${{ env.repository_name }} - unsigned APK(s) debug generated | |
# path: android/${{ env.main_project_module }}/build/outputs/apk/debug/ | |
# Upload Artifact Build | |
- name: Upload SIGNED APK Debug - ${{ env.repository_name }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: signed - ${{ matrix.node-version }} - ${{ env.build_datetime }} - ${{ env.app_name }} - ${{ env.repository_name }} - APK(s) debug generated | |
path: ${{env.app_file_name_prefix}}-*-debug.apk | |
# # Noted For Output [main_project_module]/build/outputs/apk/release/ | |
# - name: Upload unsigned APK Release - ${{ env.repository_name }} | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: ${{ matrix.node-version }} - ${{ env.build_datetime }} - ${{ env.app_name }} - ${{ env.repository_name }} - unsigned APK(s) release generated | |
# path: android/${{ env.main_project_module }}/build/outputs/apk/release/ | |
# Upload Artifact Build | |
- name: Upload SIGNED APK RELEASE - ${{ env.repository_name }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: signed - ${{ matrix.node-version }} - ${{ env.build_datetime }} - ${{ env.app_name }} - ${{ env.repository_name }} - APK(s) release generated | |
path: ${{env.app_file_name_prefix}}-*-release.apk | |
# # Noted For Output [main_project_module]/build/outputs/bundle/release/ | |
# - name: Upload unsigned AAB (App Bundle) Release - ${{ env.repository_name }} | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: ${{ matrix.node-version }} - ${{ env.build_datetime }} - ${{ env.app_name }} - ${{ env.repository_name }} - unsigned App bundle(s) AAB release generated | |
# path: android/${{ env.main_project_module }}/build/outputs/bundle/release/ | |
# Upload Artifact Build | |
- name: Upload SIGNED AAB (App Bundle) Release - ${{ env.repository_name }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: signed - ${{ matrix.node-version }} - ${{ env.build_datetime }} - ${{ env.app_name }} - ${{ env.repository_name }} - App bundle(s) AAB release generated | |
path: ${{env.app_file_name_prefix}}-*.aab | |
- name: Comment PR | |
uses: actions/github-script@v6 | |
if: github.event_name == 'pull_request' | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const workflowUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `Build artifacts for this PR are available: | |
- [Debug APK](${workflowUrl}#artifacts) | |
- [Release APK](${workflowUrl}#artifacts) | |
- [AAB](${workflowUrl}#artifacts) | |
You can download these artifacts from the "Artifacts" section of the workflow run.` | |
}); | |
- name: Generate Changelog | |
run: | | |
echo "# Release ${GITHUB_REF#refs/tags/}" > ${{ github.workspace }}-CHANGELOG.txt | |
echo "" >> ${{ github.workspace }}-CHANGELOG.txt | |
echo "## What's Changed" >> ${{ github.workspace }}-CHANGELOG.txt | |
git log $(git describe --tags --abbrev=0 HEAD^)..HEAD --pretty=format:"* %s" >> ${{ github.workspace }}-CHANGELOG.txt | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/v') | |
with: | |
body_path: ${{ github.workspace }}-CHANGELOG.txt | |
files: | | |
${{env.app_file_name_prefix}}*-debug.apk | |
${{env.app_file_name_prefix}}*-release.apk | |
${{env.app_file_name_prefix}}*.aab |