mirror of
https://github.com/minibits-cash/minibits_wallet.git
synced 2026-10-05 19:28:26 +00:00
146 lines
5.8 KiB
YAML
146 lines
5.8 KiB
YAML
name: Minibits JS bundle code push
|
|
|
|
# This workflow is manually triggered. Only if package.json version has changed it creates .env file,
|
|
# builds new js bundle and pushes it to devices running app with TEST env and STAGING code push deployment key.
|
|
# At the end it creates and pushes new version tag to github.
|
|
on: workflow_dispatch
|
|
|
|
jobs:
|
|
deploy-code-push:
|
|
runs-on: macos-latest
|
|
permissions:
|
|
id-token: write
|
|
contents: write
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 2
|
|
|
|
# Fetch javascript bundle version from package.json
|
|
- name: Read package.json version and detect changes
|
|
id: version-check
|
|
uses: salsify/action-detect-and-tag-new-version@v2
|
|
with:
|
|
create-tag: false
|
|
|
|
- name: Set versions
|
|
run: |-
|
|
echo "PREV_JS_VERSION=${{steps.version-check.outputs.previous-version }}" >> $GITHUB_ENV
|
|
echo "CURRENT_JS_VERSION=${{steps.version-check.outputs.current-version }}" >> $GITHUB_ENV
|
|
|
|
# Codepush build will continue only if version changed from previous commit
|
|
- name: Detect version change
|
|
run: |
|
|
echo "IS_VERSION_CHANGED=true" >> $GITHUB_ENV
|
|
if [ "${{ env.PREV_JS_VERSION }}" != "${{ env.CURRENT_JS_VERSION }}" ]; then
|
|
echo "IS_VERSION_CHANGED=true" >> $GITHUB_ENV
|
|
echo "Detected version change"
|
|
else
|
|
echo "IS_VERSION_CHANGED=false" >> $GITHUB_ENV
|
|
echo "No version change, skipping further processing"
|
|
fi
|
|
|
|
# Fetch native app versionName and versionCode from app/build.gradle
|
|
- name: Get Android native version
|
|
if: ${{ env.IS_VERSION_CHANGED == 'true' }}
|
|
id: version-reader-android
|
|
uses: ltDino/android-get-version-action@v1.0
|
|
with:
|
|
gradlePath: android/app/build.gradle
|
|
|
|
# Get commit hash
|
|
- name: Get commit hash
|
|
if: ${{ env.IS_VERSION_CHANGED == 'true' }}
|
|
id: commit-hash
|
|
uses: pr-mpt/actions-commit-hash@v2
|
|
|
|
- name: Set commit hash and native version information
|
|
if: ${{ env.IS_VERSION_CHANGED == 'true' }}
|
|
run: |-
|
|
echo "NATIVE_VERSION=${{steps.version-reader-android.outputs.versionName }}" >> $GITHUB_ENV
|
|
echo "COMMIT_HASH=${{steps.commit-hash.outputs.short }}" >> $GITHUB_ENV
|
|
|
|
# Get commit message
|
|
- name: Get last commit message
|
|
uses: actions/github-script@v6
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
const response = await github.rest.repos.getCommit({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
ref: context.sha
|
|
});
|
|
const lastCommit = response.data.commit;
|
|
const message = lastCommit.message;
|
|
console.log(message);
|
|
core.exportVariable('COMMIT_MESSAGE', message);
|
|
|
|
# Create .env file
|
|
- name: Generate .env
|
|
if: ${{ env.IS_VERSION_CHANGED == 'true' }}
|
|
run: |-
|
|
echo APP_ENV='TEST' >> .env
|
|
echo LOG_LEVEL='INFO' >> .env
|
|
echo SENTRY_ACTIVE='TRUE' >> .env
|
|
echo SENTRY_DSN='${{ secrets.SENTRY_DSN }}' >> .env
|
|
echo CODEPUSH_STAGING_DEPLOYMENT_KEY='${{ secrets.CODEPUSH_STAGING_DEPLOYMENT_KEY }}' >> .env
|
|
echo NATIVE_VERSION_ANDROID='${{ env.NATIVE_VERSION }}' >> .env
|
|
echo JS_BUNDLE_VERSION='${{ env.CURRENT_JS_VERSION }}' >> .env
|
|
echo COMMIT='${{ env.COMMIT_HASH }}' >> .env
|
|
|
|
# Install dependecies from package.json
|
|
- name: Install app dependencies
|
|
if: ${{ env.IS_VERSION_CHANGED == 'true' }}
|
|
uses: bahmutov/npm-install@v1.6.0
|
|
|
|
|
|
- name: Install Sentry CLI
|
|
if: ${{ env.IS_VERSION_CHANGED == 'true' }}
|
|
run: npm install @sentry/cli
|
|
|
|
# Code push with source maps export for Sentry
|
|
- name: Install AppCenter CLI
|
|
if: ${{ env.IS_VERSION_CHANGED == 'true' }}
|
|
run: npm install -g appcenter-cli
|
|
|
|
- name: Deploy to CodePush Android
|
|
if: ${{ env.IS_VERSION_CHANGED == 'true' }}
|
|
run: appcenter codepush release-react -a minibits-cash/minibits_wallet_android -d Staging --description '${{ env.COMMIT_MESSAGE }} (v${{ env.CURRENT_JS_VERSION }})' --sourcemap-output ./build/index.android.bundle.map --output-dir ./build
|
|
env:
|
|
APPCENTER_ACCESS_TOKEN: ${{ secrets.APPCENTER_ACCESS_TOKEN_ANDROID }}
|
|
|
|
# Upload source files to Sentry
|
|
- name: Upload source files to Sentry
|
|
if: ${{ env.IS_VERSION_CHANGED == 'true' }}
|
|
run: |-
|
|
./node_modules/.bin/sentry-cli login --auth-token ${{ secrets.SENTRY_AUTH_TOKEN }}
|
|
./node_modules/.bin/sentry-cli releases \
|
|
files minibits_wallet_android@${{ env.CURRENT_JS_VERSION }} \
|
|
upload-sourcemaps \
|
|
--strip-prefix /build \
|
|
--dist ${{ env.NATIVE_VERSION }} \
|
|
--org ${{ secrets.SENTRY_ORG }} \
|
|
--project react-native \
|
|
./build/index.android.bundle.map ./build/Codepush/index.android.bundle
|
|
|
|
|
|
# Create the release tag in github repo
|
|
- name: Create tag
|
|
if: ${{ env.IS_VERSION_CHANGED == 'true' }}
|
|
uses: actions/github-script@v6
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
const tagPrefix = "v";
|
|
const tagName = tagPrefix + process.env.CURRENT_JS_VERSION;
|
|
github.rest.git.createRef({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
ref: `refs/tags/${tagName}`,
|
|
sha: context.sha
|
|
});
|
|
|