|
| 1 | +name: GLPI Android Inventory Agent Release |
| 2 | + |
| 3 | +env: |
| 4 | + module_app: app |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + tags: |
| 9 | + - '*' |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v3 |
| 16 | + with: |
| 17 | + ref: develop |
| 18 | + fetch-depth: 0 #To Fetch All Tags and Branches |
| 19 | + |
| 20 | + - name: Install Dependencies |
| 21 | + uses: php-actions/composer@v6 |
| 22 | + with: |
| 23 | + dev: no |
| 24 | + |
| 25 | + ################################ |
| 26 | + # Update Version Code # |
| 27 | + ################################ |
| 28 | + - name: Update Android Version code |
| 29 | + run: ./gradlew updateVersionCode |
| 30 | + |
| 31 | + - name: "Extract Current Tag Name" |
| 32 | + run: echo "tag_name=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV |
| 33 | + |
| 34 | + - name: "Update Release Version" |
| 35 | + run: echo "$(jq '.version = "${{ env.tag_name }}"' package.json)" > package.json |
| 36 | + |
| 37 | + - name: Extract App VersionCode |
| 38 | + run: echo "app_version_code=$(grep versionCode ./app/src/main/AndroidManifest.xml | cut -d\" -f2)" >> $GITHUB_ENV |
| 39 | + |
| 40 | + - name: Update About Data |
| 41 | + run : | |
| 42 | + echo "about.version=${{ env.tag_name }}" > ./app/src/main/assets/about.properties |
| 43 | + echo "about.build=${{ env.app_version_code }}" >> ./app/src/main/assets/about.properties |
| 44 | + echo "about.date=$(date "+%a %b %d %H:%M:%S %Y")" >> ./app/src/main/assets/about.properties |
| 45 | + echo "about.commit=$(git rev-parse --short "$GITHUB_SHA")" >> ./app/src/main/assets/about.properties |
| 46 | + echo "about.commitFull=$(git rev-parse "$GITHUB_SHA")" >> ./app/src/main/assets/about.properties |
| 47 | + echo "about.github=https://github.com/glpi-project/android-inventory-agent" >> ./app/src/main/assets/about.properties |
| 48 | +
|
| 49 | +
|
| 50 | + - name: "Extract Full ChangeLog (Conventional Commit)" |
| 51 | + run: | |
| 52 | + { |
| 53 | + echo 'full_change_log<<EOF' |
| 54 | + ./vendor/bin/robo build:log 0.9 HEAD |
| 55 | + echo EOF |
| 56 | + } >> "$GITHUB_ENV" |
| 57 | +
|
| 58 | + - name: "Update Full ChangeLog" |
| 59 | + run: echo "${{ env.full_change_log }}" > CHANGELOG.md |
| 60 | + |
| 61 | + - name: Push Update to repo |
| 62 | + uses: EndBug/add-and-commit@v9 |
| 63 | + with: |
| 64 | + default_author: github_actions |
| 65 | + message: "ci(release): release new version ${{ env.tag_name }}" |
| 66 | + |
| 67 | + - name: Merge develop -> master |
| 68 | + uses: devmasx/merge-branch@master |
| 69 | + with: |
| 70 | + type: now |
| 71 | + from_branch: develop |
| 72 | + target_branch: master |
| 73 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + |
| 75 | + ########################################## |
| 76 | + # Push / Pull translation files # |
| 77 | + ########################################## |
| 78 | + # Push Transifex |
| 79 | + - name: Push source file using transifex client |
| 80 | + uses: transifex/cli-action@v2 |
| 81 | + with: |
| 82 | + args: push |
| 83 | + token: ${{ secrets.TX_TOKEN }} |
| 84 | + |
| 85 | + # Clean Transifex CLI |
| 86 | + - name: Clean Transifex CLI |
| 87 | + run: rm -fr /tmp/tx |
| 88 | + |
| 89 | + # Pull from Transifex |
| 90 | + - name: Pull source file using transifex client |
| 91 | + uses: transifex/cli-action@v2 |
| 92 | + with: |
| 93 | + args: pull --force --all --minimum-perc=80 |
| 94 | + token: ${{ secrets.TX_TOKEN }} |
| 95 | + |
| 96 | + |
| 97 | + ############################### |
| 98 | + # Prepare / Build project # |
| 99 | + ############################### |
| 100 | + # Grant execute permission for gradlew |
| 101 | + - name: Grant Execute Permission For Gradlew |
| 102 | + run: chmod +x gradlew |
| 103 | + |
| 104 | + # assemble app |
| 105 | + - name: Build with Gradle |
| 106 | + run: ./gradlew assemble |
| 107 | + |
| 108 | + # Build app |
| 109 | + - name: Build with Gradle |
| 110 | + run: ./gradlew build |
| 111 | + |
| 112 | + - name: Sign app APK |
| 113 | + uses: r0adkll/sign-android-release@v1 |
| 114 | + # ID used to access action output |
| 115 | + id: sign_app |
| 116 | + with: |
| 117 | + releaseDirectory: app/build/outputs/apk/release |
| 118 | + signingKeyBase64: ${{ secrets.SIGN_APK_SIGNING_KEY }} |
| 119 | + alias: ${{ secrets.SIGN_APK_ALIAS }} |
| 120 | + keyStorePassword: ${{ secrets.SIGN_APP_STOREPASS }} |
| 121 | + keyPassword: ${{ secrets.SIGN_APP_KEYPASS }} |
| 122 | + env: |
| 123 | + # override default build-tools version (29.0.3) -- optional |
| 124 | + BUILD_TOOLS_VERSION: "30.0.2" |
| 125 | + |
| 126 | + - name: Push to google play |
| 127 | + uses: r0adkll/upload-google-play@v1 |
| 128 | + with: |
| 129 | + serviceAccountJsonPlainText: ${{ secrets.GOOGLE_PLAY_CONSOLE }} |
| 130 | + packageName: org.glpi.inventory.agent |
| 131 | + releaseFiles: app/build/outputs/apk/release/app-release-unsigned-signed.apk |
| 132 | + track: production |
| 133 | + changesNotSentForReview: true |
| 134 | + |
| 135 | + ##################### |
| 136 | + # Prepare release # |
| 137 | + ##################### |
| 138 | + - name: "Rename APK" |
| 139 | + run: mv app/build/outputs/apk/release/app-release-unsigned-signed.apk app/build/outputs/apk/release/android-inventory-agent-v${{ env.tag_name }}.apk |
| 140 | + |
| 141 | + - name: "Extract Clean Git Log (Conventional Commit)" |
| 142 | + run: | |
| 143 | + { |
| 144 | + echo 'release_body<<EOF' |
| 145 | + ./vendor/bin/robo build:log ${{ env.previous_tag_name }} HEAD 0 |
| 146 | + echo EOF |
| 147 | + } >> "$GITHUB_ENV" |
| 148 | +
|
| 149 | + - name: Create Release |
| 150 | + uses: softprops/action-gh-release@v1 |
| 151 | + if: startsWith(github.ref, 'refs/tags/') |
| 152 | + with: |
| 153 | + name : Android Inventory Agent v${{ env.tag_name }} |
| 154 | + draft : true |
| 155 | + body : ${{ env.release_body }} |
| 156 | + files: app/build/outputs/apk/release/android-inventory-agent-v${{ env.tag_name }}.apk |
0 commit comments