Files
zaprett/.github/workflows/workflow.yml
2026-02-17 22:27:53 +07:00

129 lines
4.1 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Build module
on:
workflow_dispatch:
inputs:
create_release:
description: 'Create GitHub release?'
required: false
default: 'false'
tag:
description: "Tag for the release (x.x.x)"
required: true
type: string
nfqws-version:
description: "Nfqws version (x.x)"
required: true
type: string
nfqws2-version:
description: "Nfqws2 version (x.x)"
required: true
type: string
version:
description: "Module version (x.x)"
required: true
type: string
version_code:
description: "Module version code (xx)"
required: true
type: string
release_name:
description: "Release Name"
required: true
type: string
release_changes:
description: "Release Changes"
required: true
type: string
jobs:
build:
runs-on: ubuntu-latest
env:
NFQWS_VERSION: ${{ inputs.nfqws-version }}
NFQWS2_VERSION: ${{ inputs.nfqws2-version }}
MODULE_VERSION: ${{ inputs.version }}
MODULE_VERSION_CODE: ${{ inputs.version_code }}
steps:
- uses: actions/checkout@v4
- name: Setup Git submodules
run: git submodule update --init --recursive
- name: Install dependencies
run: |
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install -y build-essential pkg-config just unzip libc6-dev-i386 gcc-multilib
- name: Make executable
run: chmod +x build-module.sh
- name: Build module
run: ./build-module.sh
- name: Create release
if: ${{ inputs.create_release == 'true' }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.tag }}
name: ${{ inputs.release_name }}
body: ${{ inputs.release_changes }}
files: out/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifact
if: ${{ inputs.create_release != 'true' }}
uses: actions/upload-artifact@v5.0.0
with:
name: zaprett
path: out/*
- name: Update changelog
if: ${{ inputs.create_release == 'true' }}
run: echo "${{ inputs.release_changes }}" > changelog.md
- name: Update update.json
if: ${{ inputs.create_release == 'true' }}
run: |
cat > update.json <<EOF
{
"version": "${{ inputs.version }}",
"versionCode": ${{ inputs.version_code }},
"zipUrl": "https://github.com/${{ github.repository }}/releases/download/${{ inputs.tag }}/zaprett.zip",
"changelog": "https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/main/changelog.md"
}
EOF
cat > update-hosts.json <<EOF
{
"version": "${{ inputs.version }}",
"versionCode": ${{ inputs.version_code }},
"zipUrl": "https://github.com/${{ github.repository }}/releases/download/${{ inputs.tag }}/zaprett-hosts.zip",
"changelog": "https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/main/changelog.md"
}
EOF
- name: Commit jsons and changelog
if: ${{ inputs.create_release == 'true' }}
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Update update's.json and changelog"
file_pattern: "update.json update-hosts.json changelog.md"
- name: Send bot post
env:
MESSAGE_TEXT: |
🔄 <b>Обновление модуля</b> ${{ inputs.version }}
📋 Изменения: ${{ inputs.release_changes }}
⬇️ <a href='https://github.com/egor-white/zaprett/releases/tag/${{ inputs.tag }}'>Скачать</a>
@zaprett_module <a href='mailru.pro'>[web]</a>
run: |
curl -X POST "https://api.telegram.org/bot${{ secrets.BOT_TOKEN }}/sendMessage" \
-d chat_id=-1002531270265 \
-d parse_mode=HTML \
-d disable_web_page_preview=true \
--data-urlencode "text=$MESSAGE_TEXT"