如何通过 github-actions 生成 Android 调试密钥库文件?
How can I generate an Android debug keystore file through github-actions?
我正在尝试通过 github 操作工作流程生成一个 android 调试密钥库文件,它也成功生成,但是在第一个 keytool
命令后生成错误。
工作流 YAML -
name: APK Build CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build-upload:
runs-on: windows-latest
steps:
- uses: actions/setup-java@v1.3.0
with:
java-version: '12.x'
- name: Generating debug keystore and SHA1 key
shell: powershell
run: |
keytool -genkey -dname "cn=Abhishek Dubey, ou=DSCBVPPUNE, o=Google, l=Pune, st=Maharashtra, c=IN" -keystore "%USERPROFILE%\.android\debug.keystore" -storepass android -alias android -keyalg RSA -keysize 4096 -validity 10000 -v
keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias android -storepass android -keypass android
- uses: subosito/flutter-action@v1.2.0
with:
channel: 'stable'
- uses: actions/checkout@v2.0.0
- run: flutter doctor -v
- run: flutter pub get
- run: flutter build apk --debug
- name: Upload APK artifact
uses: actions/upload-artifact@v1.0.0
with:
name: dsc-app-debug
path: build\app\outputs\apk\debug\app-debug.apk
这是工作流错误日志 -
2020-03-30T10:51:07.0942983Z ##[section]Starting: Request a runner to run this job
2020-03-30T10:51:07.1787698Z Requesting a hosted runner in current repository's account/organization with labels: 'windows-latest', require runner match: True
2020-03-30T10:51:07.2818901Z Labels matched hosted runners has been found, waiting for one of them get assigned for this job.
2020-03-30T10:51:07.3281652Z ##[section]Finishing: Request a runner to run this job
2020-03-30T10:51:12.2777678Z Current runner version: '2.165.2'
2020-03-30T10:51:12.2779084Z Prepare workflow directory
2020-03-30T10:51:12.3126736Z Prepare all required actions
2020-03-30T10:51:12.3144714Z Download action repository 'actions/setup-java@v1.3.0'
2020-03-30T10:51:14.2626826Z Download action repository 'subosito/flutter-action@v1.2.0'
2020-03-30T10:51:14.5595001Z Download action repository 'actions/checkout@v2.0.0'
2020-03-30T10:51:14.7296316Z Download action repository 'actions/upload-artifact@v1.0.0'
2020-03-30T10:51:15.0924171Z ##[group]Run actions/setup-java@v1.3.0
2020-03-30T10:51:15.0924559Z with:
2020-03-30T10:51:15.0924791Z java-version: 12.x
2020-03-30T10:51:15.0924939Z java-package: jdk
2020-03-30T10:51:15.0925077Z architecture: x64
2020-03-30T10:51:15.0925218Z ##[endgroup]
2020-03-30T10:51:19.7216639Z [command]C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('d:\a\_tempde345a4-212a-4cde-89db-b56d983114a6', 'd:\a\_temp\temp_1332655762')"
2020-03-30T10:51:27.2442931Z Added matchers: 'java'. Problem matchers scan action output for known warning or error strings and report these inline.
2020-03-30T10:51:27.2443791Z creating settings.xml with server-id: github; environment variables: username=$GITHUB_ACTOR and password=$GITHUB_TOKEN
2020-03-30T10:51:27.2444263Z writing C:\Users\runneradmin\.m2\settings.xml
2020-03-30T10:51:27.2756164Z ##[group]Run keytool -genkey -dname "cn=Abhishek Dubey, ou=DSCBVPPUNE, o=Google, l=Pune, st=Maharashtra, c=IN" -keystore "%USERPROFILE%\.android\debug.keystore" -storepass android -alias android -keyalg RSA -keysize 4096 -validity 10000 -v
2020-03-30T10:51:27.2756653Z [36;1mkeytool -genkey -dname "cn=Abhishek Dubey, ou=DSCBVPPUNE, o=Google, l=Pune, st=Maharashtra, c=IN" -keystore "%USERPROFILE%\.android\debug.keystore" -storepass android -alias android -keyalg RSA -keysize 4096 -validity 10000 -v[0m
2020-03-30T10:51:27.2756873Z [36;1mkeytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias android -storepass android -keypass android[0m
2020-03-30T10:51:27.2796986Z shell: C:\windows\system32\cmd.EXE /D /E:ON /V:OFF /S /C "CALL "{0}""
2020-03-30T10:51:27.2797308Z env:
2020-03-30T10:51:27.2797432Z JAVA_HOME: C:\hostedtoolcache\windows\jdk.0.2\x64
2020-03-30T10:51:27.2797563Z JAVA_HOME_12.0.2_x64: C:\hostedtoolcache\windows\jdk.0.2\x64
2020-03-30T10:51:27.2797706Z ##[endgroup]
2020-03-30T10:51:33.1348518Z Generating 4,096 bit RSA key pair and self-signed certificate (SHA384withRSA) with a validity of 10,000 days
2020-03-30T10:51:33.1351683Z for: CN=Abhishek Dubey, OU=DSCBVPPUNE, O=Google, L=Pune, ST=Maharashtra, C=IN
2020-03-30T10:51:33.2985238Z [Storing C:\Users\runneradmin\.android\debug.keystore]
2020-03-30T10:51:33.3942546Z keytool error: java.io.FileNotFoundException: C:\Users\runneradmin\.android\debug.keystore (The system cannot find the path specified)
2020-03-30T10:51:33.3946273Z java.io.FileNotFoundException: C:\Users\runneradmin\.android\debug.keystore (The system cannot find the path specified)
2020-03-30T10:51:33.3947754Z at java.base/java.io.FileOutputStream.open0(Native Method)
2020-03-30T10:51:33.3948500Z at java.base/java.io.FileOutputStream.open(FileOutputStream.java:292)
2020-03-30T10:51:33.3948997Z at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:235)
2020-03-30T10:51:33.3949599Z at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:124)
2020-03-30T10:51:33.3950138Z at java.base/sun.security.tools.keytool.Main.doCommands(Main.java:1333)
2020-03-30T10:51:33.3950637Z at java.base/sun.security.tools.keytool.Main.run(Main.java:409)
2020-03-30T10:51:33.3950994Z at java.base/sun.security.tools.keytool.Main.main(Main.java:402)
2020-03-30T10:51:33.5856551Z keytool error: java.lang.Exception: Keystore file does not exist: C:\Users\runneradmin\.android\debug.keystore
2020-03-30T10:51:33.5859287Z java.lang.Exception: Keystore file does not exist: C:\Users\runneradmin\.android\debug.keystore
2020-03-30T10:51:33.5859446Z at java.base/sun.security.tools.keytool.Main.doCommands(Main.java:899)
2020-03-30T10:51:33.5859564Z at java.base/sun.security.tools.keytool.Main.run(Main.java:409)
2020-03-30T10:51:33.5859874Z at java.base/sun.security.tools.keytool.Main.main(Main.java:402)
2020-03-30T10:51:33.6251340Z ##[error]Process completed with exit code 1.
2020-03-30T10:51:33.6413059Z Cleaning up orphan processes
我做错了什么?
我找到问题了。
工作流失败,因为 keytool
试图在 C:\Users\runneradmin\.android
中创建 debug.keystore 文件,但在执行时未创建文件夹。
更新 YAML -
name: APK Build CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build-upload:
runs-on: windows-latest
steps:
- uses: actions/setup-java@v1.3.0
with:
java-version: '12.x'
- name: Generating debug keystore and SHA1 key
shell: powershell
run: |
md C:\Users\runneradmin\.android
keytool -genkey -dname "cn=Abhishek Dubey, ou=DSCBVPPUNE, o=Google, l=Pune, st=Maharashtra, c=IN" -keystore C:\Users\runneradmin\.android\debug.keystore -storepass android -alias AndroidDebugKey -keyalg RSA -keysize 4096 -validity 10000 -v
- name: Displaying debug.keystore file
shell: powershell
run: keytool -list -v -keystore C:\Users\runneradmin\.android\debug.keystore -alias AndroidDebugKey -storepass android -keypass android
- uses: subosito/flutter-action@v1.2.0
with:
channel: 'stable'
- uses: actions/checkout@v2.0.0
- run: flutter doctor -v
- run: flutter pub get
- run: flutter build apk --debug
- name: Upload APK artifact
uses: actions/upload-artifact@v1.0.0
with:
name: dsc-app-debug
path: build/app/outputs/apk/debug/app-debug.apk
我将生成的 SHA1 添加到我的 firebase 项目中,应用程序在云 firestore 数据库中运行得很好。
我正在尝试通过 github 操作工作流程生成一个 android 调试密钥库文件,它也成功生成,但是在第一个 keytool
命令后生成错误。
工作流 YAML -
name: APK Build CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build-upload:
runs-on: windows-latest
steps:
- uses: actions/setup-java@v1.3.0
with:
java-version: '12.x'
- name: Generating debug keystore and SHA1 key
shell: powershell
run: |
keytool -genkey -dname "cn=Abhishek Dubey, ou=DSCBVPPUNE, o=Google, l=Pune, st=Maharashtra, c=IN" -keystore "%USERPROFILE%\.android\debug.keystore" -storepass android -alias android -keyalg RSA -keysize 4096 -validity 10000 -v
keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias android -storepass android -keypass android
- uses: subosito/flutter-action@v1.2.0
with:
channel: 'stable'
- uses: actions/checkout@v2.0.0
- run: flutter doctor -v
- run: flutter pub get
- run: flutter build apk --debug
- name: Upload APK artifact
uses: actions/upload-artifact@v1.0.0
with:
name: dsc-app-debug
path: build\app\outputs\apk\debug\app-debug.apk
这是工作流错误日志 -
2020-03-30T10:51:07.0942983Z ##[section]Starting: Request a runner to run this job
2020-03-30T10:51:07.1787698Z Requesting a hosted runner in current repository's account/organization with labels: 'windows-latest', require runner match: True
2020-03-30T10:51:07.2818901Z Labels matched hosted runners has been found, waiting for one of them get assigned for this job.
2020-03-30T10:51:07.3281652Z ##[section]Finishing: Request a runner to run this job
2020-03-30T10:51:12.2777678Z Current runner version: '2.165.2'
2020-03-30T10:51:12.2779084Z Prepare workflow directory
2020-03-30T10:51:12.3126736Z Prepare all required actions
2020-03-30T10:51:12.3144714Z Download action repository 'actions/setup-java@v1.3.0'
2020-03-30T10:51:14.2626826Z Download action repository 'subosito/flutter-action@v1.2.0'
2020-03-30T10:51:14.5595001Z Download action repository 'actions/checkout@v2.0.0'
2020-03-30T10:51:14.7296316Z Download action repository 'actions/upload-artifact@v1.0.0'
2020-03-30T10:51:15.0924171Z ##[group]Run actions/setup-java@v1.3.0
2020-03-30T10:51:15.0924559Z with:
2020-03-30T10:51:15.0924791Z java-version: 12.x
2020-03-30T10:51:15.0924939Z java-package: jdk
2020-03-30T10:51:15.0925077Z architecture: x64
2020-03-30T10:51:15.0925218Z ##[endgroup]
2020-03-30T10:51:19.7216639Z [command]C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('d:\a\_tempde345a4-212a-4cde-89db-b56d983114a6', 'd:\a\_temp\temp_1332655762')"
2020-03-30T10:51:27.2442931Z Added matchers: 'java'. Problem matchers scan action output for known warning or error strings and report these inline.
2020-03-30T10:51:27.2443791Z creating settings.xml with server-id: github; environment variables: username=$GITHUB_ACTOR and password=$GITHUB_TOKEN
2020-03-30T10:51:27.2444263Z writing C:\Users\runneradmin\.m2\settings.xml
2020-03-30T10:51:27.2756164Z ##[group]Run keytool -genkey -dname "cn=Abhishek Dubey, ou=DSCBVPPUNE, o=Google, l=Pune, st=Maharashtra, c=IN" -keystore "%USERPROFILE%\.android\debug.keystore" -storepass android -alias android -keyalg RSA -keysize 4096 -validity 10000 -v
2020-03-30T10:51:27.2756653Z [36;1mkeytool -genkey -dname "cn=Abhishek Dubey, ou=DSCBVPPUNE, o=Google, l=Pune, st=Maharashtra, c=IN" -keystore "%USERPROFILE%\.android\debug.keystore" -storepass android -alias android -keyalg RSA -keysize 4096 -validity 10000 -v[0m
2020-03-30T10:51:27.2756873Z [36;1mkeytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias android -storepass android -keypass android[0m
2020-03-30T10:51:27.2796986Z shell: C:\windows\system32\cmd.EXE /D /E:ON /V:OFF /S /C "CALL "{0}""
2020-03-30T10:51:27.2797308Z env:
2020-03-30T10:51:27.2797432Z JAVA_HOME: C:\hostedtoolcache\windows\jdk.0.2\x64
2020-03-30T10:51:27.2797563Z JAVA_HOME_12.0.2_x64: C:\hostedtoolcache\windows\jdk.0.2\x64
2020-03-30T10:51:27.2797706Z ##[endgroup]
2020-03-30T10:51:33.1348518Z Generating 4,096 bit RSA key pair and self-signed certificate (SHA384withRSA) with a validity of 10,000 days
2020-03-30T10:51:33.1351683Z for: CN=Abhishek Dubey, OU=DSCBVPPUNE, O=Google, L=Pune, ST=Maharashtra, C=IN
2020-03-30T10:51:33.2985238Z [Storing C:\Users\runneradmin\.android\debug.keystore]
2020-03-30T10:51:33.3942546Z keytool error: java.io.FileNotFoundException: C:\Users\runneradmin\.android\debug.keystore (The system cannot find the path specified)
2020-03-30T10:51:33.3946273Z java.io.FileNotFoundException: C:\Users\runneradmin\.android\debug.keystore (The system cannot find the path specified)
2020-03-30T10:51:33.3947754Z at java.base/java.io.FileOutputStream.open0(Native Method)
2020-03-30T10:51:33.3948500Z at java.base/java.io.FileOutputStream.open(FileOutputStream.java:292)
2020-03-30T10:51:33.3948997Z at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:235)
2020-03-30T10:51:33.3949599Z at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:124)
2020-03-30T10:51:33.3950138Z at java.base/sun.security.tools.keytool.Main.doCommands(Main.java:1333)
2020-03-30T10:51:33.3950637Z at java.base/sun.security.tools.keytool.Main.run(Main.java:409)
2020-03-30T10:51:33.3950994Z at java.base/sun.security.tools.keytool.Main.main(Main.java:402)
2020-03-30T10:51:33.5856551Z keytool error: java.lang.Exception: Keystore file does not exist: C:\Users\runneradmin\.android\debug.keystore
2020-03-30T10:51:33.5859287Z java.lang.Exception: Keystore file does not exist: C:\Users\runneradmin\.android\debug.keystore
2020-03-30T10:51:33.5859446Z at java.base/sun.security.tools.keytool.Main.doCommands(Main.java:899)
2020-03-30T10:51:33.5859564Z at java.base/sun.security.tools.keytool.Main.run(Main.java:409)
2020-03-30T10:51:33.5859874Z at java.base/sun.security.tools.keytool.Main.main(Main.java:402)
2020-03-30T10:51:33.6251340Z ##[error]Process completed with exit code 1.
2020-03-30T10:51:33.6413059Z Cleaning up orphan processes
我做错了什么?
我找到问题了。
工作流失败,因为 keytool
试图在 C:\Users\runneradmin\.android
中创建 debug.keystore 文件,但在执行时未创建文件夹。
更新 YAML -
name: APK Build CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build-upload:
runs-on: windows-latest
steps:
- uses: actions/setup-java@v1.3.0
with:
java-version: '12.x'
- name: Generating debug keystore and SHA1 key
shell: powershell
run: |
md C:\Users\runneradmin\.android
keytool -genkey -dname "cn=Abhishek Dubey, ou=DSCBVPPUNE, o=Google, l=Pune, st=Maharashtra, c=IN" -keystore C:\Users\runneradmin\.android\debug.keystore -storepass android -alias AndroidDebugKey -keyalg RSA -keysize 4096 -validity 10000 -v
- name: Displaying debug.keystore file
shell: powershell
run: keytool -list -v -keystore C:\Users\runneradmin\.android\debug.keystore -alias AndroidDebugKey -storepass android -keypass android
- uses: subosito/flutter-action@v1.2.0
with:
channel: 'stable'
- uses: actions/checkout@v2.0.0
- run: flutter doctor -v
- run: flutter pub get
- run: flutter build apk --debug
- name: Upload APK artifact
uses: actions/upload-artifact@v1.0.0
with:
name: dsc-app-debug
path: build/app/outputs/apk/debug/app-debug.apk
我将生成的 SHA1 添加到我的 firebase 项目中,应用程序在云 firestore 数据库中运行得很好。