From a9aa842a5519bc788bbc32273d72e1e2ae22fd2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Kwiecin=CC=81ski?= Date: Fri, 4 Sep 2020 10:28:03 +0200 Subject: [PATCH 1/4] Fail action on error --- .github/workflows/should_fail_workflow.yml | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/should_fail_workflow.yml diff --git a/.github/workflows/should_fail_workflow.yml b/.github/workflows/should_fail_workflow.yml new file mode 100644 index 0000000..246d879 --- /dev/null +++ b/.github/workflows/should_fail_workflow.yml @@ -0,0 +1,44 @@ +name: Test workflow that verifies the action fails on error +on: [ push, pull_request, workflow_dispatch ] +jobs: + should-fail: + continue-on-error: true + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@master + - name: Get sample .apk for test purposes + run: wget --output-document ApiDemos-debug.apk https://github.com/appium/appium/blob/906350fd335f9485376214fdd17c7cdb6c9ff26b/sample-code/apps/ApiDemos-debug.apk?raw=true + - name: (Should fail) Upload artifact without token + uses: ./ + with: + appName: ${{ secrets.APP_NAME }} + group: Collaborators + file: ApiDemos-debug.apk + releaseNotes: New bugs + - name: Create file 'JOB_FAILED.TXT' and write 'true' into it + if: ${{ failure() }} + run: echo 'true' > JOB_FAILED.TXT + - name: Upload file 'JOB_FAILED.TXT' as an artifact + if: ${{ failure() }} + uses: actions/upload-artifact@v2 + with: + name: pass_file + path: JOB_FAILED.TXT + check-failure: + needs: [ should-fail ] + runs-on: ubuntu-latest + steps: + - name: Download file 'JOB_FAILED.TXT' from artifact + uses: actions/download-artifact@v2 + with: + name: pass_file + path: pass_file + - id: set_output + name: Read file 'JOB_FAILED.TXT' and set output parameter + run: echo "::set-output name=JOB_FAILED::$( Date: Sat, 5 Sep 2020 10:02:02 +0200 Subject: [PATCH 2/4] Remove test workflow file --- .github/workflows/should_fail_workflow.yml | 44 ---------------------- 1 file changed, 44 deletions(-) delete mode 100644 .github/workflows/should_fail_workflow.yml diff --git a/.github/workflows/should_fail_workflow.yml b/.github/workflows/should_fail_workflow.yml deleted file mode 100644 index 246d879..0000000 --- a/.github/workflows/should_fail_workflow.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Test workflow that verifies the action fails on error -on: [ push, pull_request, workflow_dispatch ] -jobs: - should-fail: - continue-on-error: true - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@master - - name: Get sample .apk for test purposes - run: wget --output-document ApiDemos-debug.apk https://github.com/appium/appium/blob/906350fd335f9485376214fdd17c7cdb6c9ff26b/sample-code/apps/ApiDemos-debug.apk?raw=true - - name: (Should fail) Upload artifact without token - uses: ./ - with: - appName: ${{ secrets.APP_NAME }} - group: Collaborators - file: ApiDemos-debug.apk - releaseNotes: New bugs - - name: Create file 'JOB_FAILED.TXT' and write 'true' into it - if: ${{ failure() }} - run: echo 'true' > JOB_FAILED.TXT - - name: Upload file 'JOB_FAILED.TXT' as an artifact - if: ${{ failure() }} - uses: actions/upload-artifact@v2 - with: - name: pass_file - path: JOB_FAILED.TXT - check-failure: - needs: [ should-fail ] - runs-on: ubuntu-latest - steps: - - name: Download file 'JOB_FAILED.TXT' from artifact - uses: actions/download-artifact@v2 - with: - name: pass_file - path: pass_file - - id: set_output - name: Read file 'JOB_FAILED.TXT' and set output parameter - run: echo "::set-output name=JOB_FAILED::$( Date: Mon, 7 Sep 2020 14:20:04 +0200 Subject: [PATCH 3/4] Add ability to upload mappings/symbols file --- .github/workflows/main.yml | 35 +++++++++++++++++++++++++---- Dockerfile | 15 ++++++++----- README.md | 46 ++++++++++++++++++++++++++++++++++++-- action.yml | 8 ++++++- entrypoint.sh | 38 +++++++++++++++++++++++-------- 5 files changed, 120 insertions(+), 22 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 575f83c..9225c0a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,13 +1,15 @@ name: Sample workflow for App Center action on: [push, pull_request, workflow_dispatch, pull_request_target] jobs: - run: + android: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - name: Get sample .apk for test purposes - run: wget --output-document ApiDemos-debug.apk https://github.com/appium/appium/blob/906350fd335f9485376214fdd17c7cdb6c9ff26b/sample-code/apps/ApiDemos-debug.apk?raw=true + run: wget https://github.com/appium/appium/blob/906350fd335f9485376214fdd17c7cdb6c9ff26b/sample-code/apps/ApiDemos-debug.apk?raw=true -O ApiDemos-debug.apk + - name: Get sample mappings.txt file for test purposes + run: wget https://gist.githubusercontent.com/loopj/43a4a3231f32c17ab9e3/raw/2181ad9ae926cd3d46ee9becabcb0cce668ef9c0/mapping.txt -O mappings.txt - name: Upload artifact with provided release notes uses: ./ with: @@ -47,4 +49,29 @@ jobs: group: Collaborators file: ApiDemos-debug.apk debug: true - + - name: Upload apk artifact with mappings file + uses: ./ + with: + appName: ${{ secrets.APP_NAME }} + token: ${{ secrets.API_TOKEN }} + group: Collaborators + file: ApiDemos-debug.apk + mappings: mappings.txt + releaseNotes: Has mappings + debug: true + ios: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Get sample .ipa file for test purposes + run: wget https://github.com/bitbar/test-samples/blob/master/apps/ios/bitbar-ios-sample.ipa?raw=true -O sample-ios-app.ipa + - name: Upload ipa artifact with symbols file + uses: ./ + with: + appName: ${{ secrets.IOS_APP_NAME }} + token: ${{ secrets.IOS_API_TOKEN }} + group: Collaborators + file: sample-ios-app.ipa + releaseNotes: Has symbols + debug: true diff --git a/Dockerfile b/Dockerfile index 23b1f27..8a22cd9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,17 @@ -FROM node:12.10.0-alpine +FROM node:14 WORKDIR /app COPY . /app -RUN npm install -g appcenter-cli@2.7.3 \ - && apk update \ - && apk add git \ - && apk add bash +RUN npm install -g appcenter-cli@2.7.3 + +RUN mkdir -p /usr/local/lib/aapt/ +RUN wget -q "https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/4.0.1-6197926/aapt2-4.0.1-6197926-linux.jar" -O aapt2-all.jar \ + && mv aapt2-all.jar /usr/local/lib/aapt/aapt2-all.jar \ + && cd /usr/local/lib/aapt \ + && unzip -qq aapt2-all.jar \ + && ln -s /usr/local/lib/aapt/aapt2 /usr/local/bin/aapt2 RUN chmod +x /app/entrypoint.sh ENTRYPOINT [ "/app/entrypoint.sh" ] - diff --git a/README.md b/README.md index 034db0b..f8aff47 100644 --- a/README.md +++ b/README.md @@ -24,14 +24,24 @@ This action uploads artifacts (.apk or .ipa) to Visual Studio App Center. **Required** Artifact to upload (.apk or .ipa) ### `buildVersion` + Build version parameter required for .zip, .msi, .pkg and .dmg files -### buildNumber +### `buildNumber` + Build number parameter required for macOS .pkg and .dmg files +### `mappings` + +Android mappings.txt file location. See [the documentation](https://developer.android.com/studio/build/shrink-code) for details + +### `symbols` + +iOS debug symbol file (.dSYM) location. See [the documentation](https://docs.microsoft.com/en-us/appcenter/diagnostics/ios-symbolication) for details + ### `releaseNotes` -Release notes visible on release page +Release notes visible on App Center's Release page ### `gitReleaseNotes` @@ -52,6 +62,7 @@ See Github Actions [documentation](https://docs.github.com/en/actions/creating-a ## Sample usage +Android: ``` name: Build, code quality, tests @@ -77,6 +88,37 @@ jobs: token: ${{secrets.APP_CENTER_TOKEN}} group: Testers file: app/build/outputs/apk/release/app-release-unsigned.apk + mappings: app/build/outputs/mappings/release/mappings.txt notifyTesters: true debug: false ``` + +iOS +``` +name: Build, code quality, tests + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: build release + run: ./gradlew assembleRelease + - name: upload artefact to App Center + uses: wzieba/AppCenter-Github-Action@v1 + with: + appName: wzieba/Sample-App + token: ${{secrets.APP_CENTER_TOKEN}} + group: Testers + file: path/to/iOS.ipa + symbols: path/to/crash_symbols.dSYM + notifyTesters: true +``` diff --git a/action.yml b/action.yml index 9aad221..7033508 100644 --- a/action.yml +++ b/action.yml @@ -3,7 +3,7 @@ description: "GitHub Action that uploads artefacts for Visual Studio App Center" author: "Wojciech Zięba <@wzieba>" inputs: appName: - description: "App name followed by username e.g. wzieba/Sample-App" + description: "App name preceded by the App Center's username e.g. wzieba/Sample-App" required: true token: description: "Upload token - you can get one from appcenter.ms/settings" @@ -29,6 +29,12 @@ inputs: notifyTesters: description: "If true, send an email notification to the distribution group" required: false + mappings: + description: "Android mappings.txt file location" + required: false + symbols: + description: "iOS debug symbol file (.dSYM) location." + required: false debug: description: "If true, shows additional information from the action execution" required: false diff --git a/entrypoint.sh b/entrypoint.sh index 25775bb..0b1af9c 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,9 +7,9 @@ params=() [ "${INPUT_NOTIFYTESTERS}" != true ] && params+=(--silent) [ "${INPUT_DEBUG}" == true ] && params+=(--debug) if [ -n "${INPUT_RELEASENOTES}" ]; then - RELEASE_NOTES=${INPUT_RELEASENOTES} + RELEASE_NOTES=${INPUT_RELEASENOTES} elif [ $INPUT_GITRELEASENOTES ]; then - RELEASE_NOTES="$(git log -1 --pretty=short)" + RELEASE_NOTES="$(git log -1 --pretty=short)" fi if [ -n "${INPUT_BUILDVERSION}" ]; then @@ -21,11 +21,31 @@ if [ -n "${INPUT_BUILDNUMBER}" ]; then fi for group in $INPUT_GROUP; do - if ${isFirst} ; then - isFirst=false - appcenter distribute release --token "$INPUT_TOKEN" --app "$INPUT_APPNAME" --group $group --file "$INPUT_FILE" --release-notes "$RELEASE_NOTES" "${params[@]}" - releaseId=$(appcenter distribute releases list --token "$INPUT_TOKEN" --app "$INPUT_APPNAME" | grep ID | tr -s ' ' | cut -f2 -d ' ' | sort -n -r | head -1) - else - appcenter distribute releases add-destination --token "$INPUT_TOKEN" -d $group -t group -r $releaseId --app "$INPUT_APPNAME" "${params[@]}" - fi + if ${isFirst}; then + isFirst=false + appcenter distribute release --token "$INPUT_TOKEN" --app "$INPUT_APPNAME" --group $group --file "$INPUT_FILE" --release-notes "$RELEASE_NOTES" "${params[@]}" + releaseId=$(appcenter distribute releases list --token "$INPUT_TOKEN" --app "$INPUT_APPNAME" | grep ID | tr -s ' ' | cut -f2 -d ' ' | sort -n -r | head -1) + else + appcenter distribute releases add-destination --token "$INPUT_TOKEN" -d $group -t group -r $releaseId --app "$INPUT_APPNAME" "${params[@]}" + fi done + +crashUploadParams=() +[ "${INPUT_DEBUG}" == true ] && crashUploadParams+=(--debug) + +if [ "$INPUT_MAPPINGS" ]; then + APP_VERSION_NAME=$(/usr/local/bin/aapt2 dump badging "$INPUT_FILE" | grep "versionName=" | sed -e "s/.*versionName='//" -e "s/' .*//") + APP_VERSION_CODE=$(/usr/local/bin/aapt2 dump badging "$INPUT_FILE" | grep "versionCode=" | sed -e "s/.*versionCode='//" -e "s/' .*//") + if ($INPUT_DEBUG); then + echo "Upload mappings $INPUT_MAPPINGS -> $APP_VERSION_NAME -> $APP_VERSION_CODE" + fi + + appcenter crashes upload-mappings --token "$INPUT_TOKEN" --app "$INPUT_APPNAME" --mapping "$INPUT_MAPPINGS" --version-name "$APP_VERSION_NAME" --version-code "$APP_VERSION_CODE" "${crashUploadParams[@]}" +fi + +if [ "$INPUT_SYMBOLS" ]; then + if ($INPUT_DEBUG); then + echo "Upload symbols $INPUT_SYMBOLS" + fi + appcenter crashes upload-symbols --token "$INPUT_TOKEN" --app "$INPUT_APPNAME" --symbol "$INPUT_SYMBOLS" "${crashUploadParams[@]}" +fi From a827de53db7501fc30429423f9e3072021e929f9 Mon Sep 17 00:00:00 2001 From: Wojciech Zieba Date: Sun, 3 Apr 2022 21:22:49 +0200 Subject: [PATCH 4/4] Update CI envirnoments names --- .github/workflows/main.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9225c0a..201921a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ jobs: - name: Upload artifact with provided release notes uses: ./ with: - appName: ${{secrets.APP_NAME}} + appName: ${{secrets.ANDROID_APP_NAME}} token: ${{secrets.API_TOKEN}} group: Collaborators file: ApiDemos-debug.apk @@ -21,14 +21,14 @@ jobs: - name: Upload artifact with empty release notes uses: ./ with: - appName: ${{secrets.APP_NAME}} + appName: ${{secrets.ANDROID_APP_NAME}} token: ${{secrets.API_TOKEN}} group: Collaborators file: ApiDemos-debug.apk - name: Upload artifact with Git generated release notes uses: ./ with: - appName: ${{secrets.APP_NAME}} + appName: ${{secrets.ANDROID_APP_NAME}} token: ${{secrets.API_TOKEN}} group: Collaborators file: ApiDemos-debug.apk @@ -36,7 +36,7 @@ jobs: - name: Upload artifact and notify testers uses: ./ with: - appName: ${{secrets.APP_NAME}} + appName: ${{secrets.ANDROID_APP_NAME}} token: ${{secrets.API_TOKEN}} group: Collaborators file: ApiDemos-debug.apk @@ -44,7 +44,7 @@ jobs: - name: Upload artifact with a debug flag uses: ./ with: - appName: ${{secrets.APP_NAME}} + appName: ${{secrets.ANDROID_APP_NAME}} token: ${{secrets.API_TOKEN}} group: Collaborators file: ApiDemos-debug.apk @@ -52,7 +52,7 @@ jobs: - name: Upload apk artifact with mappings file uses: ./ with: - appName: ${{ secrets.APP_NAME }} + appName: ${{ secrets.ANDROID_APP_NAME }} token: ${{ secrets.API_TOKEN }} group: Collaborators file: ApiDemos-debug.apk @@ -70,7 +70,7 @@ jobs: uses: ./ with: appName: ${{ secrets.IOS_APP_NAME }} - token: ${{ secrets.IOS_API_TOKEN }} + token: ${{ secrets.API_TOKEN }} group: Collaborators file: sample-ios-app.ipa releaseNotes: Has symbols