不過趕者去烤肉,有些地方寫的不正確,今天又拆了一天出來說明&更新
in android/app/build.gradle
def getMyVersionCode = { ->
def code = project.hasProperty('versionCode') ? versionCode.toInteger() : -1
println "VersionCode is set to $code"
return code
}
def getMyVersionName = { ->
def name = project.hasProperty('versionName') ? versionName : "1.0"
println "VersionName is set to $name"
return name
}
in android/app/build.gradle
defaultConfig {
applicationId "dev.dayuan.rn3d"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
+ versionCode getMyVersionCode()
+ versionName getMyVersionName()
- // versionCode 1
- // versionName "1.0"
}
in android/gradle.properties
起始版號
+ versionCode=5
+ versionName=0.0.5
}
gradle build bundleRelease -PversionCode=483 -PversionName=4.0.3
adb -s emulator-5554 install app/build/outputs/apk/release/app-release.apk
name: Github Actions
# on: [push, pull_request]
on:
push:
branches: [ Release-Store ]
tags:
- 'Store*'
pull_request:
branches: [ Release-Store ]
jobs:
build:
runs-on: ubuntu-latest
container: reactnativecommunity/react-native-android
steps:
- name: "#️⃣ Generate Build Number"
id: buildnumber
uses: einaregilsson/build-number@v2
with:
token: ${{ secrets.ACTION_TEST }}
- name: "#️⃣ Generate Build Number store"
id: buildnumber_store
uses: einaregilsson/build-number@v2
with:
token: ${{ secrets.ACTION_TEST }}
prefix: store
- name: Print new build number
run: |
echo "Build number is $BUILD_NUMBER"
echo "Build number is $buildnumber" ${{ steps.buildnumber.outputs.build_number }}
echo "Build number is $buildnumber_store" ${{ steps.buildnumber.outputs.buildnumber_store }}
echo $BUILD_NUMBER
- uses: actions/checkout@v2
- name: Envinfo
run: npx envinfo
- name: Build application
run: |
yarn install && cd android && chmod +x gradlew && ./gradlew build bundleRelease
du -shc `find . -regex '.+\.\(apk\|aab\)$'`
# run: yarn install && cd android && chmod +x gradlew && ./gradlew assembleRelease
# ./gradlew build bundleRelease
# du -shc `find . -regex '.+\.\(apk\|aab\)$'`
#Prepare Release
- name: Prepare Release
id: prepare_release
# if: contains(github.ref, 'tags/')
run: |
APK_PATH=`find . -name '*.apk' | grep release`
echo ::set-output name=apk_path::$APK_PATH
APK_NAME=`basename $APK_PATH`
echo ::set-output name=apk_name::$APK_NAME
BUNDLE_PATH=`find . -name '*.aab' | grep release | grep -v intermediates`
echo ::set-output name=bundle_path::$BUNDLE_PATH
BUNDLE_NAME=`basename $BUNDLE_PATH`
echo ::set-output name=bundle_name::$BUNDLE_NAME
# 選用
# TAG_NAME=`echo $GITHUB_REF | cut -d / -f3`
# echo ::set-output name=tag_name::$TAG_NAME
# PACKAGE_NAME=`./tools/aapt2 dump packagename $APK_PATH`
# echo ::set-output name=package_name::$PACKAGE_NAME
- name: Print build PATH
run: |
echo ${{steps.prepare_release.outputs.bundle_path}}
echo ${{steps.prepare_release.outputs.apk_name}}
echo ${{steps.prepare_release.outputs.bundle_path}}/${{steps.prepare_release.outputs.apk_name}}
# 簽署 BBA
- name: Sign AAB
id: sign
uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: ./android/app/build/outputs/bundle/release/
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
#Uploads
- name: Upload Artifact
if: steps.prepare_release.outputs.apk_path
uses: actions/upload-artifact@v1
with:
name: app-release.apk
path: android/app/build/outputs/apk/release/
#Uploads
- name: Upload Artifact
if: steps.prepare_release.outputs.bundle_path
uses: actions/upload-artifact@v1
with:
name: app-release.aab
path: android/app/build/outputs/bundle/release/
- name: Create GitHub release
id: create_release
# if: steps.version_check.outputs.changed == 'true'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.ACTION_TEST }}
with:
tag_name: V-${{ steps.buildnumber.outputs.build_number }}
release_name: V-${{ steps.buildnumber.outputs.build_number }}
body: |
![release!](https://i.giphy.com/media/lPulaaB9lDMnGZiivs/source.gif)
# Changelog
Release type: ${{ steps.buildnumber.outputs.build_number }}
prerelease: true
- name: Upload APK Asset
if: steps.create_release.outputs.upload_url && steps.prepare_release.outputs.apk_path && steps.prepare_release.outputs.apk_name
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{steps.create_release.outputs.upload_url}}
asset_path: ${{steps.prepare_release.outputs.apk_path}}
asset_name: ${{steps.prepare_release.outputs.apk_name}}
asset_content_type: application/vnd.android.package-archive
# 選用 BBA
- name: Upload Bundle Asset
if: steps.create_release.outputs.upload_url && steps.prepare_release.outputs.bundle_path && steps.prepare_release.outputs.bundle_name
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{steps.create_release.outputs.upload_url}}
asset_path: ${{steps.prepare_release.outputs.bundle_path}}
asset_name: ${{steps.prepare_release.outputs.bundle_name}}
asset_content_type: application/octet-stream
# 上傳 BBA
- name: Upload Android Release to Play Store (internal track publishing is default)
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
packageName: dev.dayuan.rn3d
releaseFile: ${{steps.prepare_release.outputs.bundle_path}}
track: internal
whatsNewDirectory: distribution/whatsnew