Create a Github action workflow for android - android

I am using this workflow but getting error in this
name: react-native-android-build-aab
on:
push:
branches:
- master
jobs:
install-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- name: Install npm dependencies
run: |
npm install
build-android:
needs: install-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- name: Install npm dependencies
run: |
npm install
- name: Build Android Release
run: |
cd android && ./gradlew bundleRelease
- name: Upload Artifact
uses: actions/upload-artifact#v1
with:
name: app-release.aab
path: app/build/outputs/
Upload Artifact error
0s
Run actions/upload-artifact#v1
Error: Path does not exist /home/runner/work/appwe/appwe/app/build/outputs/
Error: Exit code 1 returned from process: file name '/home/runner/runners/2.294.0/bin/Runner.PluginHost', arguments 'action "GitHub.Runner.Plugins.Artifact.PublishArtifact, Runner.Plugins"'.
Tried multiple solutions but nothing worked. if try the above github action with .apk it works fine. So please let me know how can i create a bundle with action. Thanks

Related

GitHub Actions ./gradlew build job succeed but does not create build directory

I am trying to make CI process with GitHub Actions for Android project. Before making a real process, the goal is to build gradle and debug apk file automatically.
The job succeed for each step, however, neither build directory nor apk file is being created.
I read various posts and tried each post suggests, but nothing gave me a solution.
What part do I need to change to get the desired result?
Firstly, Below is log I got from ./gradlew build command. It says that the process definitely has gotten into :app:build
> Task :app:lintDebug
> Task :app:lint
> Task :app:check
> Task :app:build
BUILD SUCCESSFUL in 1m 22s
And here is a GitHub Actions Job I made.
Android_CI_Test.yml
name: Android CI Test
on:
pull_request:
branches:
- main
- release
- dev
- staging
push:
branches:
- main
- release
jobs:
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- name: Set Up java
id: set_up_java
uses: actions/setup-java#v3
with:
java-version: 11
distribution: "corretto"
- name: Set Android SDK
uses: android-actions/setup-android#v2
- name: Cache Gradle
uses: actions/cache#v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/buildSrc/**/*.kt') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Grand Gradlew Permission
id: grand_gradlew_permission
run: chmod +x ./gradlew
- name: Validate Gradlew
id: validate_gradlew
uses: gradle/wrapper-validation-action#v1
- name: Set Up Gradle
id: set_up_gradle
uses: gradle/gradle-build-action#v2
- name: Build
id: build_gradle
run: ./gradlew build
- name: Build debug APK
id: build_debug_apk
run: ./gradlew assembleDebug --stacktrace
I tried changing Grand Gradlew Permission to chmod +x ./gradlew , changing Build debug APK to bash ./gradlew assembleDebug or ./gradlew app:assembleDebug but none of them has succeeded.

github actions flutter gives error 'Artifact pattern :build/app/outputs/apk/release/*.apk did not match any files'

I created GitHub actions to run to build apk on macOS. but it gives me warning that Artifact pattern :build/app/outputs/apk/release/*.apk did not match any files.
This is a public repo, can someone please help me here. in official docs it says the same path and locally i can build apk successfully (on windows machine).
I used MacOS to generate iOs App which i'll do later.
Link of repo.
magento-mobile-oss
workflow-
name: Magento Mobile
on:
push:
branches: [ oss ]
pull_request:
branches: [ oss ]
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout#v1
- uses: actions/setup-java#v1
with:
java-version: '12.x'
- uses: subosito/flutter-action#v1
with:
channel: stable
env:
KEY_JKS: ${{ secrets.KEY_JKS }}
KEY_PASSWORD: ${{ secrets.ALIAS_PASSWORD }}
ALIAS_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: echo $KEY_JKS > key.jks && flutter pub get && flutter test && flutter build apk --split-per-abi --verbose
- name: Create a Release APK
uses: ncipollo/release-action#v1
with:
artifacts: "build/app/outputs/apk/release/*.apk"
token: ${{ secrets.OSS_TOKEN }}
commit: oss
tag: v1.0.${{ github.run_number }}
Your workflow doesn't build the APK, and therefore, there's no build/app/outputs/apk/release/*.apk file. So the release action doesn't find the location of the artifacts. Here is the workflow you can use to modify yours and tweak it as you wish:
# This is a basic workflow to help you get started with Actions
name: Build Flutter APK
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "develop" branch
push:
branches: ["develop"]
tags:
- "v*"
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
permissions:
contents: write
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout#v3
- uses: actions/setup-java#v1
with:
java-version: "12.x"
- name: Setup Flutter
uses: subosito/flutter-action#v1
with:
channel: "beta"
- name: Decode android/neumodore_key.jks
run: echo "${{ secrets.KEYSTORE_JKS_PROD }}" | base64 --decode > android/keystore.jks
- name: Decode android/key.properties
run: echo "${{ secrets.KEY_PROPERTIES_PROD }}" | base64 --decode > android/key.properties
- name: Pub Get Packages
run: flutter pub get
- name: Build APK
run: flutter build apk
- name: Create Release
uses: ncipollo/release-action#v1.10.0
with:
artifacts: "build/app/outputs/apk/release/*.apk"

What values I should configure in my github actions secrets in order to sign my apk?

According to this answer I should run te following command in order to build an apk and sign it?
./gradlew assembleRelease -Pandroid.injected.signing.store.file=$KEYFILE -Pandroid.injected.signing.store.password=$STORE_PASSWORD -Pandroid.injected.signing.key.alias=$KEY_ALIAS -Pandroid.injected.signing.key.password=$KEY_PASSWORD
And using the android studio I made the following key configuration that is used for building the app:
The generated files in /home/pcmagas/Kwdikas/androidKeys/h330s_fu is contained using the following 2 files:
h300s_fu
private_key.pepk
And the action responsible for building and signing the apk is:
name: pr
on:
push:
branches: [master]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout latest code
uses: actions/checkout#v1
- name: Set up JDK 8
uses: actions/setup-java#v2
with:
java-version: '8'
distribution: 'adopt'
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: test
run: ./gradlew test
- name: build
run: ./gradlew buildRelease
- name: Assemble Release Bundle
run: ./gradlew assembleRelease
Hence the environmental variables:
$KEYFILE
$STORE_PASSWORD
$KEY_ALIAS
$KEY_PASSWORD
Must be configured with github secrets. But what values should I configure for them? I mean what role has the h300s_fu file and the private_key.pepk one?

Fastlane + Github Actions: Couldn't find gradlew at path

I'm trying to implement a CI/CD workflow for Flutter using Github Actions and Fastlane. But, when the lane is executing throws the following error:
I create the Fastlane folder inside the android folder. Like the image
This is the content of my Fastfile:
update_fastlane
default_platform(:android)
platform :android do
desc "Deploy to closed beta track"
lane :closed_beta do
begin
gradle(task: "clean")
gradle(
task: "bundle",
build_type: 'Release'
)
upload_to_play_store(
track: 'Closed beta',
aab: '../build/app/outputs/bundle/release/app-release.aab',
skip_upload_metadata: true,
skip_upload_images: true,
skip_upload_screenshots: true,
release_status: "draft",
version_code: flutter_version()["version_code"],
)
end
end
end
And my GitHub action workflow that allows to make the build and deployment is like below. The Run Fastlane step is the error point
name: Continuous Delivery to Play Store
on:
push:
branches:
- "v*"
jobs:
# Continuous integration
build_android:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout#v2
- name: Setup Java
uses: actions/setup-java#v1
with:
java-version: 12.x
- name: Decrypt Android keys
run: sh ./.github/scripts/decrypt_android_keys.sh
env:
ANDROID_KEYS_SECRET_PASSPHRASE: ${{ secrets.ANDROID_KEYS_SECRET_PASSPHRASE }}
- name: Setup Flutter
uses: subosito/flutter-action#v1
with:
flutter-version: 1.22.5
- name: Install Flutter dependencies
run: flutter pub get
# Add build runner commands here if you have any
- name: Format files
run: flutter format --set-exit-if-changed .
- name: Analyze files
run: flutter analyze .
- name: Run the tests
run: flutter test
- name: Build the APK
run: flutter build apk
- name: Upload artifact to Github
uses: actions/upload-artifact#v1
with:
name: release-apk
path: build/app/outputs/apk/release/app-release.apk
# Continuous delivery
deploy_android:
runs-on: ubuntu-latest
needs: [build_android]
steps:
- name: Checkout code
uses: actions/checkout#v2
- name: Setup Java
uses: actions/setup-java#v1
with:
java-version: 12.x
- name: Decrypt Android keys
run: sh ./.github/scripts/decrypt_android_keys.sh
env:
ANDROID_KEYS_SECRET_PASSPHRASE: ${{ secrets.ANDROID_KEYS_SECRET_PASSPHRASE }}
- name: Setup Flutter
uses: subosito/flutter-action#v1
with:
flutter-version: 1.22.5
- name: Install Flutter dependencies
run: flutter pub get
- name: Build app bundle
run: flutter build appbundle
- uses: actions/checkout#v2
- uses: ruby/setup-ruby#v1
with:
ruby-version: 2.6
bundler-cache: true
- name: Check file existence
run: echo find . -name "gradlew"
- uses: maierj/fastlane-action#v2.0.0
with:
lane: closed_beta
subdirectory: android
Run flutter build appbundle -v before other tasks in a lane like this
lane :beta do
sh "flutter build appbundle -v" <- Add this
upload_to_play_store(
track: 'beta',
aab: '../build/app/outputs/bundle/release/app-release.aab',
json_key_data: ENV['PLAY_STORE_CONFIG_JSON'],
)
end```
I have the same issue and what I found that gradlew is excluded in .gitignore inside /android folder of your flutter project.
While following runs on your local machine, it won't run Github runner:
gradle(task: "clean")
gradle(
task: "bundle",
build_type: 'Release'
)
Consider deleting lines above from Fastfile as you already do build on Github
behalf here:
name: Build the APK
run: flutter build apk

Add artifact from github actions to releases

So im trying to implement a release section on my yml file for a generated artifact, explaining myself: i would like to add an artifact to my releases with my yml file.
Here's the only yml file am working on for an android app:
name: Android CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- run: mkdir -p app/build/outputs/apk/release
- run: echo hello > app/build/outputs/apk/release/app-release-unsigned.apk
- uses: actions/upload-artifact#v2
with:
name: my-artifact
path: app/build/outputs/apk/release/app-release-unsigned.apk
- name: set up JDK 1.8
uses: actions/setup-java#v1
with:
java-version: 1.8
- name: Permition Gradlew
run: chmod +x gradlew
- name: Build Gradlew
run: ./gradlew assembleRelease
The actions/upload-artifact#v2 Action is meant for uploading artifacts to GitHub Actions workflow runs, not for adding assets to a GitHub release. If you want to add build assets to a GitHub release, you should instead use the softprops/action-gh-release example described here. I've modified the example to match your specific scenario:
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
name: Upload Release Asset
jobs:
build:
name: Upload Release Asset
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout#v2
- name: Build project
run: |
mkdir -p app/build/outputs/apk/release
echo hello > app/build/outputs/apk/release/app-release-unsigned.apk
- name: Release with Notes
uses: softprops/action-gh-release#v1
with:
files: app/build/outputs/apk/release/app-release-unsigned.apk
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
You can repeat the final step as needed with different paths for adding further artifacts to the release.

Categories

Resources