I am trying to upload an APK file to Slack using Github. My code somehow works adding a text but it doesn't really upload the actual apk file. I am building the apk file using Flutter. All I want to do is uploading an apk file and it would be also great to send a chat notification too.. but seems chat notifcation is completed but not working for uploading a file.
Thanks for your help in advance!
name: APK Deploy
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
# Setup Java environment in order to build the Android app.
- uses: actions/checkout#v1
- uses: actions/setup-java#v1
with:
java-version: '12.x'
# Setup the flutter environment.
- uses: subosito/flutter-action#v1
with:
channel: 'stable' # 'dev', 'alpha', default to: 'stable'
# flutter-version: '1.12.x' # you can also specify exact version of flutter
# Get flutter dependencies.
- run: flutter pub get
# Statically analyze the Dart code for any errors.
- run: flutter analyze .
# Run widget tests for our flutter project.
- run: flutter test
# Build apk.
- run: flutter build apk --release
- run: 'echo build/app/outputs/apk/release/app-release.apk > app-release.apk'
- uses: MeilCli/slack-upload-file#v1
with:
slack_token: ${{ secrets.SLACK_READ_WRITE_TOKEN }}
channels: ${{ secrets.SLACK_CHANNEL_DEPLOY }}
file_path: 'build/app/outputs/apk/release/app-release.apk'
file_name: 'app-release.apk'
file_type: 'apk'
initial_comment: '${{ github.ref }} - deployed the apk file to slack'
- name: action-slack
uses: 8398a7/action-slack#v3.8.0
with:
status: ${{ job.status }}
author_name: Build Notification
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
# Upload generated apk to the artifacts.
- name: release-apk
uses: actions/upload-artifact#v2
with:
name: app-release.apk
path: build/app/outputs/apk/release/app-release.apk
Looks like your issue might be in your path for the release-apk step. Might be worth changing it to this:
path: ${{ github.workspace }}/app/actions_builds/app-release.apk
Related
I use Github Action to automatically package the Android APK file (same signature file), but when installing to the phone, it prompts: "The signature of the app is inconsistent with the signature of the installed app". Does anyone know how to deal with it? Thank you!
My process configuration:
# This is a basic workflow to help you get started with Actions
name: build
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# 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_android:
# The type of runner that the job will run on
runs-on: ubuntu-latest
env:
KEY_JKS: ${{ secrets.KEY_JKS }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout#v3
- uses: subosito/flutter-action#v2
with:
flutter-version: '3.0.5'
channel: 'stable'
cache: true
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash
cache-path: /Users/runner/hostedtoolcache/flutter/:channel:-:version:-:arch
- name: Flutter action
# You may pin to the exact commit or the version.
uses: subosito/flutter-action#v2.7.0
- name: Create Key File
run: echo $KEY_JKS | base64 -di > android/app/release.jks
# build apk
- uses: actions/checkout#v3
- uses: actions/setup-java#v2
with:
distribution: 'zulu'
java-version: '11'
- uses: subosito/flutter-action#v2
with:
flutter-version: '3.0.5'
- run: flutter pub get
- run: flutter build apk
- uses: actions/upload-artifact#v1
with:
name: app-release.apk
path: build/app/outputs/apk/release/app-release.apk
token: ${{ secrets.GITHUB_TOKEN }}
I have solved this problem.The problem that appeared before, seems to be the cause of the cache.
The steps are as follows:
It mainly includes the modification of the following two lines:
- run: flutter clean
- run: echo $KEY_JKS | base64 -di > android/app/release.jks
Now my process file is like this:
# This is a basic workflow to help you get started with Actions
name: build
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# 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_android:
# The type of runner that the job will run on
runs-on: ubuntu-latest
env:
KEY_JKS: ${{ secrets.KEY_JKS }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout#v3
- uses: subosito/flutter-action#v2
with:
flutter-version: '3.0.5'
channel: 'stable'
cache: true
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash
cache-path: /home/runner/hostedtoolcache/flutter/:channel:-:version:-:arch
- name: Flutter action
uses: subosito/flutter-action#v2.7.0
# build apk
- uses: actions/checkout#v3
- uses: actions/setup-java#v2
with:
distribution: 'zulu'
java-version: '11'
- uses: subosito/flutter-action#v2
with:
flutter-version: '3.0.5'
- run: flutter clean
- run: echo $KEY_JKS | base64 -di > android/app/release.jks
- run: flutter pub get
- run: flutter build apk
- uses: actions/upload-artifact#v1
with:
name: app-release.apk
path: build/app/outputs/apk/release/app-release.apk
token: ${{ secrets.GITHUB_TOKEN }}
build_windows:
runs-on: windows-latest
steps:
- uses: actions/checkout#v3
- uses: subosito/flutter-action#v2
with:
channel: 'beta'
- run: flutter config --enable-windows-desktop
- run: flutter build windows
- uses: actions/upload-artifact#v1
with:
name: windows-build
path: "build/windows/runner/Release"
token: ${{ secrets.GITHUB_TOKEN }}
I am trying to upload an apk to firebase using github action.
I have commented out the code analysis and tests to make the action run faster so as to try and resolve the issue. I have also tried to upload an app bundle, I get the same response.
Here is the github action configuration.
name: Deploy app bundle to firebase
on:
push:
branches:
- dev
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-java#v1
with:
java-version: '12.x'
- uses: subosito/flutter-action#v1 # Setup flutter environment
with:
flutter-version: '2.5.0'
- run: flutter pub get
- run: flutter pub run build_runner build --delete-conflicting-outputs
- name: Create env file
run: |
cat << EOF > .env
STAGING_API_BASE_URL="${{ secrets.STAGING_API_BASE_URL }}"
PROD_API_BASE_URL="${{ secrets.PROD_API_BASE_URL }}"
BASE_PATH="${{ secrets.BASE_PATH }}"
EOF
# - run: flutter format --set-exit-if-changed # - run: flutter format --set-exit-if-changed .
#- run: flutter analyze # Analyze the project's Dart code. This causes job to exit
#- name: Run flutter analyze
# run: |
# chmod +x ./flutter_analyze.sh
# ./flutter_analyze.sh
#- run: flutter test # Run Flutter unit tests for the current project.
- name: Build Gradle
run: flutter build apk --debug
- uses: actions/checkout#v2 #This uploads artifacts from your workflow
with:
name: debug-apk
path: build/app/outputs/flutter-apk/app-debug.apk
- run: ls build/app/outputs/flutter-apk
- name: Upload artifact to Firebase App Distribution
uses: wzieba/Firebase-Distribution-Github-Action#v1.3.2
with:
appId: ${{secrets.FIREBASE_APP_ID}}
token: ${{secrets.FIREBASE_TOKEN}}
groups: testers
file: build/app/outputs/flutter-apk/app-debug.apk
When I run the workflow I get the following error:
You can use this script to find your built apk path:
run: |
echo "Find build artifacts"
apkPath=$(find app -name "*.apk" | head -1)
echo "Found apk at $apkPath"
if [[ -z ${apkPath} ]]
then
echo "No apks were found, skip publishing to App Distribution"
else
echo "Publishing $apkPath to App Center"
#publish your apk by using $apkPath
fi
it scans all agent files and finds apk file.
use
wzieba/Firebase-Distribution-Github-Action#v1.3.3
I had made a mistake on this line
- uses: actions/upload-artifact #This uploads artifacts from your workflow
The comment is correct but the action is wrong.
I should have used actions/upload-artifact https://github.com/wzieba/Firebase-Distribution-Github-Action/issues/51
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"
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
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.