Skip to content

Build props (on schedule) #46

Build props (on schedule)

Build props (on schedule) #46

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: [comet, komodo, caiman, tokay, akita, husky, shiba, cheetah, raven, redfin]
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install APT packages
run: |
sudo apt install -y dos2unix
- name: Activate venv
run: |
python3.12 -m venv .venv/
. .venv/bin/activate
echo PATH=$PATH >> "$GITHUB_ENV"
- name: Install payload_dumper
run: pip install ./payload_dumper/
- 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: Check if module build ID already exists
id: check_build_id
run: |
BASENAME="${{ steps.extract_and_build.outputs.module_base_name }}"
BUILD_ID="${{ steps.extract_and_build.outputs.device_build_id }}"
EXISTING_RELEASE_NOTES=$(curl --silent "https://api.github.com/repos/$GITHUB_REPOSITORY/releases" | jq '.[].body')
if echo "$EXISTING_RELEASE_NOTES" | grep -q "${BASENAME}_${BUILD_ID}"; then
echo "BUILD_EXISTS=true" >> $GITHUB_OUTPUT
else
echo "BUILD_EXISTS=false" >> $GITHUB_OUTPUT
fi
- 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
if: steps.check_build_id.outputs.BUILD_EXISTS == 'false'
- 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_codename }})
#### Module
- File name: `${{ steps.extract_and_build.outputs.module_base_name }}.zip`
- File hash (SHA256): `${{ steps.extract_and_build.outputs.module_hash }}`
#### Firmware
- Build Description: `${{ steps.extract_and_build.outputs.device_build_description }}`
if: steps.check_build_id.outputs.BUILD_EXISTS == 'false'
- name: Send to Telegram
run: |
{
echo '${{ steps.extract_and_build.outputs.device_name }} - ${{ steps.extract_and_build.outputs.device_codename }}';
echo '${{ steps.extract_and_build.outputs.device_build_description }}'
} > .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)"
if: steps.check_build_id.outputs.BUILD_EXISTS == 'false'