Update README.md #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish update | |
on: | |
push: | |
branches: "release" | |
env: | |
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
RELEASE_SIGN_KEY_ALIAS: ${{ secrets.RELEASE_SIGN_KEY_ALIAS }} | |
RELEASE_SIGN_KEY_PASSWORD: ${{ secrets.RELEASE_SIGN_KEY_PASSWORD }} | |
jobs: | |
build-apk: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: release | |
- name: set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: gradle | |
- name: Create google-services.json | |
run: cat /home/runner/work/che-zadali-app/che-zadali-app/app/google-services.json | base64 | |
- name: Putting data into google-services.json | |
env: | |
DATA: ${{ secrets.GOOGLE_SERVICES_JSON }} | |
run: echo $DATA > /home/runner/work/che-zadali-app/che-zadali-app/app/google-services.json | |
- name: Decode Keystore | |
env: | |
ENCODED_STRING: ${{ secrets.KEYSTORE_FILE }} | |
run: | | |
TMP_KEYSTORE_FILE_PATH=/home/runner/work/che-zadali-app/che-zadali-app/app/keystore | |
mkdir "${TMP_KEYSTORE_FILE_PATH}" | |
echo $ENCODED_STRING | base64 -di > "${TMP_KEYSTORE_FILE_PATH}"/mezhendosina_key.jks | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
run: ./gradlew assembleRelease --stacktrace | |
- name: Get built APK | |
uses: actions/upload-artifact@v3 | |
with: | |
name: SGO app.apk | |
path: /home/runner/work/che-zadali-app/che-zadali-app/app/build/outputs/apk/release/app-release.apk | |
get-apk-version: | |
needs: build-apk | |
runs-on: ubuntu-latest | |
outputs: | |
apk-version-name: ${{ steps.apk-info.outputs.version-name }} | |
steps: | |
- name: Get APK | |
uses: actions/download-artifact@v3 | |
with: | |
name: SGO app.apk | |
path: ./ | |
- name: Get apk info | |
id: apk-info | |
uses: mezhendosina/apk-info-action@0.0.1 | |
with: | |
apk-path: /home/runner/work/che-zadali-app/che-zadali-app/app-release.apk | |
prepare-release-notes: | |
needs: get-apk-version | |
runs-on: ubuntu-latest | |
outputs: | |
release-notes-with-header: "*Доступна новая версия приложения*: _${{ needs.get-apk-version.outputs.apk-version-name }}_ | |
${{ env.release }}" | |
release-notes: "${{ env.release }}" | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: release | |
- name: Read RELEASE.md file | |
id: getRelease | |
run: | | |
echo "release<<EOF" >> $GITHUB_ENV | |
echo -e $(cat /home/runner/work/che-zadali-app/che-zadali-app/RELEASE_NOTES.md) >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
get-last-release-version: | |
needs: get-apk-version | |
runs-on: ubuntu-latest | |
outputs: | |
is-update: ${{ steps.check-release-tag.outputs.is_update }} | |
steps: | |
- name: Fetch Latest Release | |
id: fetch-latest-release | |
uses: gregziegan/fetch-latest-release@v2.0.0 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get release tag | |
id: get-release-tag | |
run: echo last_tag=${{ steps.fetch-latest-release.outputs.tag_name }} << $GITHUB_OUTPUT | |
- name: Check release tag | |
id: check-release-tag | |
run: echo is_update=${{ steps.get-release-tag.outputs.last_tag }} != ${{ needs.get-apk-version.outputs.apk-version-name }} << $GITHUB_OUTPUT | |
send-to-channel: | |
needs: [ prepare-release-notes, get-apk-version ] | |
# if: ${{ needs.get-last-release-version.outputs.is-update }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get APK | |
uses: actions/download-artifact@v3 | |
with: | |
name: SGO app.apk | |
path: ./ | |
- name: rename APK | |
run: mv /home/runner/work/che-zadali-app/che-zadali-app/app-release.apk /home/runner/work/che-zadali-app/che-zadali-app/che-zadali-app-v${{ needs.get-apk-version.outputs.apk-version-name }}.apk | |
- name: Send release notes to Telegram channel | |
run: curl -F chat_id=-1001621609379 -F parse_mode=Markdown -F text="${{ needs.prepare-release-notes.outputs.release-notes-with-header }}" https://api.telegram.org/bot${{ secrets.TELEGRAM_API_TOKEN }}/sendMessage | |
- name: Send file to Telegram channel | |
run: curl -F document=@"/home/runner/work/che-zadali-app/che-zadali-app/che-zadali-app-v${{ needs.get-apk-version.outputs.apk-version-name }}.apk" https://api.telegram.org/bot${{ secrets.TELEGRAM_API_TOKEN }}/sendDocument?chat_id=-1001621609379 | |
create-release: | |
needs: [ prepare-release-notes, get-apk-version ] | |
# if: ${{ needs.get-last-release-version.outputs.is-update }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get APK | |
uses: actions/download-artifact@v3 | |
with: | |
name: SGO app.apk | |
path: ./ | |
- name: rename APK | |
run: mv /home/runner/work/che-zadali-app/che-zadali-app/app-release.apk /home/runner/work/che-zadali-app/che-zadali-app/che-zadali-app.apk | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ needs.get-apk-version.outputs.apk-version-name }} | |
release_name: ${{ needs.get-apk-version.outputs.apk-version-name }} | |
body: ${{ needs.prepare-release-notes.outputs.release-notes }} | |
- name: Upload APK | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: /home/runner/work/che-zadali-app/che-zadali-app/che-zadali-app.apk | |
asset_name: che-zadali-app.apk | |
asset_content_type: application/vnd.android.package-archive |