Skip to content

Build props (on schedule) #3

Build props (on schedule)

Build props (on schedule) #3

name: Build props (on schedule)
on:
workflow_dispatch:
schedule:
- cron: "37 13 7 * *" # At 13:37 on day-of-month 7. (UTC)
jobs:
prepare_build:
name: Create release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
id: ${{ steps.create_release.outputs.id }}
steps:
- name: Determine tag name
id: get_tag_name
run: |
echo "tag_name=$(date '+%Y%m%d')" >> $GITHUB_OUTPUT
echo "friendly_tag_name=$(date '+%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Create a release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_tag_name.outputs.tag_name }}
release_name: ${{ steps.get_tag_name.outputs.friendly_tag_name }}
draft: false
prerelease: false
build:
name: Build props
needs: prepare_build
strategy:
matrix:
# Devices to build props for
device_name: [cheetah, raven, redfin]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install APT packages
uses: daaku/gh-action-apt-install@v4
with:
packages: dos2unix python3 python3-pip zip
- name: Install protobuf
run: |
pip install --upgrade pip
pip3 install -Iv protobuf==3.20.3
- name: Make all scripts executable
run: chmod +x *.sh
- name: Download latest OTA build for ${{ matrix.device_name }}
run: ./download_latest_ota_build.sh ${{ matrix.device_name }}
- name: Extract images and build
id: extract_and_build
run: ./extract_images.sh
- name: Upload files to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.prepare_build.outputs.upload_url }}
asset_path: ./${{ steps.extract_and_build.outputs.module_base_name }}.zip
asset_name: ${{ steps.extract_and_build.outputs.module_base_name }}.zip
asset_content_type: application/zip
- name: Add information to release
uses: irongut/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
id: ${{ needs.prepare_build.outputs.id }}
replacebody: false
body: |
## ${{ steps.extract_and_build.outputs.device_name }} (${{ steps.extract_and_build.outputs.device_code_name_title }})
#### Module
- File name: `${{ steps.extract_and_build.outputs.module_base_name }}.zip`
- File hash (SHA256): `${{ steps.extract_and_build.outputs.module_hash }}`
#### Firmware
- Build ID: `${{ steps.extract_and_build.outputs.device_build_id }}`
- Android version: `${{ steps.extract_and_build.outputs.device_build_android_version }}`
- Security patch: `${{ steps.extract_and_build.outputs.device_build_security_patch }}`
- name: Send to Telegram
run: |
{
echo '${{ steps.extract_and_build.outputs.device_name }} - ${{ steps.extract_and_build.outputs.device_code_name_title }}';
echo 'Security Patch: `${{ steps.extract_and_build.outputs.device_build_security_patch }}`';
echo 'ID: `${{ steps.extract_and_build.outputs.device_build_id }}`';
} > .tg_caption
curl -X POST "https://api.telegram.org/bot${{ secrets.BOT_TOKEN }}/sendDocument" \
-H "Content-Type: multipart/form-data" \
-F "chat_id=${{ secrets.CHANNEL_ID }}" \
-F "document=@${{ steps.extract_and_build.outputs.module_base_name }}.zip;type=application/zip" \
-F "caption=$(cat .tg_caption)"