Skip to content

Sync, Build, and Release #446

Sync, Build, and Release

Sync, Build, and Release #446

Workflow file for this run

name: Sync, Build, and Release
on:
schedule:
- cron: '0 * * * *' # Запуск каждый час
workflow_dispatch: # Возможность ручного запуска
jobs:
sync:
runs-on: ubuntu-latest
outputs:
run_build: ${{ steps.sync_upstream.outputs.run_build }}
timestamp: ${{ steps.generate_timestamp.outputs.timestamp }}
steps:
# 1. Генерируем TIMESTAMP
- name: Generate Timestamp
id: generate_timestamp
run: |
TIMESTAMP=$(date +"%Y%m%d-%H%M")
echo "timestamp=$TIMESTAMP" >> $GITHUB_OUTPUT
# 2. Клонируем форк
- name: Checkout Fork
uses: actions/checkout@v3
with:
repository: nix155/qdomyos-zwift
token: ${{ secrets.PAT_TOKEN }}
fetch-depth: 0
# 2. Настраиваем Upstream и синхронизируем с оригиналом
- name: Sync with Upstream
id: sync_upstream
run: |
git remote add upstream https://github.com/cagnulein/qdomyos-zwift.git
git fetch upstream
if git diff --quiet HEAD upstream/master; then
echo "run_build=false" >> $GITHUB_OUTPUT
else
echo "run_build=true" >> $GITHUB_OUTPUT
git merge upstream/master --no-edit
git push origin master
fi
# echo "run_build=false" >> $GITHUB_OUTPUT
# if ! git diff --quiet HEAD upstream/master; then
# if ! git diff --quiet HEAD upstream/master -- src; then
# echo "run_build=true" >> $GITHUB_OUTPUT
# fi
# git merge upstream/master --no-edit
# git push origin master
# fi
build:
runs-on: ubuntu-latest
needs: sync
if: ${{ needs.sync.outputs.run_build == 'true' }}
steps:
# 1. Клонируем оригинал
- name: Checkout Original Repository
uses: actions/checkout@v3
with:
repository: cagnulein/qdomyos-zwift
fetch-depth: 0
# 2. Устанавливаем зависимости
- name: Install Dependencies
run: |
sudo apt update -y
sudo apt install --no-install-recommends -y \
git \
ca-certificates \
qtquickcontrols2-5-dev \
qtconnectivity5-dev \
qtbase5-private-dev \
qtpositioning5-dev \
libqt5charts5-dev \
libqt5networkauth5-dev \
libqt5websockets5-dev \
qml-module* \
libqt5texttospeech5-dev \
qtlocation5-dev \
qtmultimedia5-dev \
g++ \
make \
wget \
unzip
# 3. Обновляем подмодули и компилируем проект
- name: Build Binary
run: |
git submodule update --init src/smtpclient/
git submodule update --init src/qmdnsengine/
git submodule update --init tst/googletest/
pushd src
qmake qdomyos-zwift.pro
make -j$(nproc)
popd
# 4. Упаковываем бинарник с добавлением даты
- name: Package Binary
run: |
mkdir -p dist
BIN_NAME="qdomyos-zwift-${{ needs.sync.outputs.timestamp }}.tar.gz"
ARC_PATH="dist/$BIN_NAME"
echo "BIN_NAME=$BIN_NAME" >> $GITHUB_ENV
echo "ARC_PATH=$ARC_PATH" >> $GITHUB_ENV
tar -czvf "$ARC_PATH" -C src qdomyos-zwift
echo "ls -lah src/" && ls -lah src/
echo "ls -lah dist/" && ls -lah dist/
# 5. Создаём релиз и публикуем упакованный бинарник
- name: Create Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ needs.sync.outputs.timestamp }}
release_name: "Release ${{ needs.sync.outputs.timestamp }}"
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
# 6. Загружаем артефакт в релиз
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.ARC_PATH }}
asset_name: ${{ env.BIN_NAME }}
asset_content_type: application/gzip
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
build-push-dh-webgl:
needs: sync
if: ${{ needs.sync.outputs.run_build == 'never' }}
uses: ./.github/workflows/build-push-dh.yml
with:
repository: cagnulein/qdomyos-zwift
dockerfile: docker/linux_webgl/Dockerfile
image_name: qdomyos-zwift-webgl
timestamp: ${{ needs.sync.outputs.timestamp }}
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_NAMESPACE: ${{ secrets.DOCKER_NAMESPACE }}
build-push-dh-gui-vnc:
needs: sync
if: ${{ needs.sync.outputs.run_build == 'never' }}
uses: ./.github/workflows/build-push-dh.yml
with:
repository: cagnulein/qdomyos-zwift
dockerfile: docker/linux_gui_vnc/Dockerfile
image_name: qdomyos-zwift-gui-vnc
timestamp: ${{ needs.sync.outputs.timestamp }}
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_NAMESPACE: ${{ secrets.DOCKER_NAMESPACE }}
build-push-gh-webgl:
needs: sync
if: ${{ needs.sync.outputs.run_build == 'true' }}
uses: ./.github/workflows/build-push-gh.yml
with:
repository: cagnulein/qdomyos-zwift
dockerfile: docker/linux_webgl/Dockerfile
image_name: qdomyos-zwift-webgl
timestamp: ${{ needs.sync.outputs.timestamp }}
secrets:
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
build-push-gh-gui-vnc:
needs: sync
if: ${{ needs.sync.outputs.run_build == 'true' }}
uses: ./.github/workflows/build-push-gh.yml
with:
repository: cagnulein/qdomyos-zwift
dockerfile: docker/linux_gui_vnc/Dockerfile
image_name: qdomyos-zwift-gui-vnc
timestamp: ${{ needs.sync.outputs.timestamp }}
secrets:
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
notify:
runs-on: ubuntu-latest
needs: sync
if: ${{ needs.sync.outputs.run_build == 'true' }}
steps:
- name: Send Telegram Notification
run: |
curl -X POST https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendMessage \
-d chat_id=${{ secrets.TELEGRAM_CHAT_ID }} \
-d text="Новая сборка ${{ needs.sync.outputs.timestamp }} в репозитории ${{ github.repository }}"
# build-push-dh-webgl:
# runs-on: ubuntu-latest
# if: ${{ needs.sync.outputs.run_build == 'never' }}
# needs: sync
# steps:
# # 1. Клонируем оригинал
# - name: Checkout Original Repository
# uses: actions/checkout@v3
# with:
# repository: cagnulein/qdomyos-zwift
# fetch-depth: 0
# # 2. Логинимся в DockerHub
# - name: Log in to DockerHub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
# # 3. Сборка и пуш WebGL-образа
# - name: Build and Push WebGL Image
# run: |
# TIMESTAMP=${{ needs.sync.outputs.timestamp }}
# IMAGE_NAME="${{ secrets.DOCKER_NAMESPACE }}/qdomyos-zwift-webgl"
# docker build -t $IMAGE_NAME:latest -t $IMAGE_NAME:$TIMESTAMP -f docker/linux_webgl/Dockerfile .
# docker push $IMAGE_NAME:latest
# docker push $IMAGE_NAME:$TIMESTAMP
# build-push-dh-gui-vnc:
# runs-on: ubuntu-latest
# if: ${{ needs.sync.outputs.run_build == 'never' }}
# needs: sync
# steps:
# # 1. Клонируем оригинал
# - name: Checkout Original Repository
# uses: actions/checkout@v3
# with:
# repository: cagnulein/qdomyos-zwift
# fetch-depth: 0
# # 2. Логинимся в DockerHub
# - name: Log in to DockerHub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
# # 3. Сборка и пуш GUI VNC-образа
# - name: Build and Push GUI VNC Image
# run: |
# TIMESTAMP=${{ needs.sync.outputs.timestamp }}
# IMAGE_NAME="${{ secrets.DOCKER_NAMESPACE }}/qdomyos-zwift-gui-vnc"
# docker build -t $IMAGE_NAME:latest -t $IMAGE_NAME:$TIMESTAMP -f docker/linux_gui_vnc/Dockerfile .
# docker push $IMAGE_NAME:latest
# docker push $IMAGE_NAME:$TIMESTAMP
# build-push-gh-webgl:
# runs-on: ubuntu-latest
# if: ${{ needs.sync.outputs.run_build == 'true' }}
# needs: sync
# permissions: write-all
# steps:
# # 1. Клонируем оригинал
# - name: Checkout Original Repository
# uses: actions/checkout@v3
# with:
# repository: cagnulein/qdomyos-zwift
# fetch-depth: 0
# # 2. Логинимся в GHCR
# - name: Log in to GitHub Container Registry
# run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
# # 3. Сборка и пуш WebGL-образа
# - name: Build and Push WebGL Image
# run: |
# TIMESTAMP=${{ needs.sync.outputs.timestamp }}
# IMAGE_NAME="ghcr.io/${{ github.repository_owner }}/qdomyos-zwift-webgl"
# docker build -t $IMAGE_NAME:latest -t $IMAGE_NAME:$TIMESTAMP -f docker/linux_webgl/Dockerfile .
# docker push $IMAGE_NAME:latest
# docker push $IMAGE_NAME:$TIMESTAMP
# build-push-gh-gui-vnc:
# runs-on: ubuntu-latest
# if: ${{ needs.sync.outputs.run_build == 'true' }}
# needs: sync
# permissions: write-all
# steps:
# # 1. Клонируем оригинал
# - name: Checkout Original Repository
# uses: actions/checkout@v3
# with:
# repository: cagnulein/qdomyos-zwift
# fetch-depth: 0
# # 2. Логинимся в GHCR
# - name: Log in to GitHub Container Registry
# run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
# # 3. Сборка и пуш GUI VNC-образа
# - name: Build and Push GUI VNC Image
# run: |
# TIMESTAMP=${{ needs.sync.outputs.timestamp }}
# IMAGE_NAME="ghcr.io/${{ github.repository_owner }}/qdomyos-zwift-gui-vnc"
# docker build -t $IMAGE_NAME:latest -t $IMAGE_NAME:$TIMESTAMP -f docker/linux_gui_vnc/Dockerfile .
# docker push $IMAGE_NAME:latest
# docker push $IMAGE_NAME:$TIMESTAMP