Skip to content

Commit

Permalink
feat: use custom keystore with build command
Browse files Browse the repository at this point in the history
  • Loading branch information
ajinasokan committed Aug 9, 2022
1 parent 77eca9b commit a6100b0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ $ apkc run
....
```

To build APK with custom key store run `apkc build --keystore "/path/to/keystore.jks" --storepass "password" --keyalias "alias"`.

To build AAB run `apkc build --aab`. Output file will be at `build/app.{apk/aab}`.

You can add external jar dependencies to `myapp/jar` directory and native libs to `myapp/lib` in appropriate architecture sub directories.
Expand Down
4 changes: 2 additions & 2 deletions apk.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ func alignAPK() {
}

// signAPK signs apk with jarsigner and default debug keys
func signAPK() {
func signAPK(keyStore, storePass, keyAlias *string) {
LogI("build", "signing app")

cmd := exec.Command(jarsignerPath, "-verbose", "-sigalg", "SHA1withRSA", "-digestalg", "SHA1", "-storepass", "android", "-keystore", keyStorePath, filepath.Join("build", "bundle.zip"), "androiddebugkey")
cmd := exec.Command(jarsignerPath, "-verbose", "-sigalg", "SHA1withRSA", "-digestalg", "SHA1", "-storepass", *storePass, "-keystore", *keyStore, filepath.Join("build", "bundle.zip"), *keyAlias)
out, err := cmd.CombinedOutput()
if err != nil {
LogF("build", string(out))
Expand Down
7 changes: 6 additions & 1 deletion build.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ import (
// build compiles all the source code and bundles into apk file with dependencies
func build() {
buildCmd := flag.NewFlagSet("build", flag.ExitOnError)

useAAB := buildCmd.Bool("aab", false, "build aab instead of apk")
keyStore := buildCmd.String("keystore", keyStorePath, "path to keystore")
storePass := buildCmd.String("storepass", "android", "keystore password")
keyAlias := buildCmd.String("keyalias", "androiddebugkey", "key alias to use")

buildCmd.Parse(os.Args[2:])

prepare()
Expand All @@ -25,7 +30,7 @@ func build() {
if *useAAB {
buildAAB()
} else {
signAPK()
signAPK(keyStore, storePass, keyAlias)
alignAPK()
}
}
Expand Down

0 comments on commit a6100b0

Please sign in to comment.