ilharp / sign-android-release

A GitHub action to sign an APK or AAB
https://github.com/marketplace/actions/sign-android-release-2
MIT License
42 stars 10 forks source link

steps.sign_app.outputs.signedFile is not returning the correct path #18

Open DominusExult opened 9 months ago

DominusExult commented 9 months ago

I've run into trouble with this.

Using this action in https://github.com/exult/exult/blob/master/.github/workflows/snapshots-android.yml#L80 and then renaming & copying the apk to another folder:

 - name: Sign APK
        if: ${{ env.EXULT_REPO_ALIVE == 'true' }}
        uses: ilharp/sign-android-release@v1
        id: sign_app
        with:
          releaseDir: /home/runner/work/exult/build/android/app/build/outputs/apk/release
          signingKey: ${{ secrets.ANDROID_SIGNING_KEY }}
          keyAlias: ${{ secrets.ANDROID_KEY_ALIAS }}
          keyStorePassword: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
          keyPassword: ${{ secrets.ANDROID_KEY_PASSWORD }}
      - name: Save release artifact
        if: ${{ env.EXULT_REPO_ALIVE == 'true' }}
        run: cp ${{steps.sign_app.outputs.signedFile}} ./android-snapshot/exult-snapshot-signed.apk

The output of the signing action:

 Signing APK file.
  /usr/local/lib/android/sdk/build-tools/33.0.0/apksigner sign --ks *** --ks-key-alias *** --ks-pass pass:*** --out /home/runner/work/exult/build/android/app/build/outputs/apk/release/app-release-unsigned-aligned-signed.apk --key-pass pass:*** /home/runner/work/exult/build/android/app/build/outputs/apk/release/app-release-unsigned-aligned-temp.apk
Successfully signed 1 file(s).

But the "Save release artifact" action has this:

env:
    ...
    ANDROID_SIGNED_FILE: /home/runner/work/exult/exult/home/runner/work/exult/build/android/app/build/outputs/apk/release/app-release-unsigned-aligned-signed.apk
    ANDROID_SIGNED_FILES: /home/runner/work/exult/exult/home/runner/work/exult/build/android/app/build/outputs/apk/release/app-release-unsigned-aligned-signed.apk
    ANDROID_SIGNED_FILES_COUNT: 1
cp: cannot stat '/home/runner/work/exult/exult/home/runner/work/exult/build/android/app/build/outputs/apk/release/app-release-unsigned-aligned-signed.apk': No such file or directory

Why does it add /home/runner/work/exult/exult in front of the path?

ilharp commented 9 months ago

Please see the definition of releaseDir option in README:

Optional. The relative directory path in your project where your Android release file will be located. Defaults to app/build/outputs/apk/release.

releaseDir is the relative directory path of your release folder in your project. Never use absolute paths like /home/runner/work in GitHub Actions. GitHub Actions does not provide stability guarantees regarding absolute paths and may subject to change at any time.

DominusExult commented 9 months ago

Ouch, seems I'm running into a problem now. We are building outside of the project (to avoid running into other problems) and your action doesn't like relative paths with . or ... I had releaseDir: ./../build/android/app/build/outputs/apk/release which resulted in Error: AssertionError [ERR_ASSERTION]: Invalid pattern './../build/android/app/build/outputs/apk/release/**/*.apk'. Relative pathing '.' and '..' is not allowed.

ilharp commented 9 months ago

I see. Building outside the project directory seems reasonable. I'll modify the resolve logic of releaseDir later to support absolute path.

DominusExult commented 9 months ago

thank you! If everything fails, I can also try building in an extra subfolder of our source. Haven't done that yet.