Skip to content

teste 10$

teste 10$ #9

name: Build and Release (Desktop)
on:
push:
branches:
- linux-release
tags: [ "*" ]
paths:
- 'DocViewerDesktop/**'
workflow_dispatch:
env:
VERSION: ${{ github.ref_type == 'tag' && github.ref_name || format('dev-{0}', github.run_number) }}
jobs:
build-linux:
name: Build Linux
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r DocViewerDesktop/requirements.txt
pip install pyinstaller
- name: Build with PyInstaller (Linux)
run: |
pyinstaller --noconsole --name DocViewer \
--icon="DocViewerDesktop/resources/icons_svg/doc_icon.ico" \
--add-data "DocViewerDesktop/ui/dark-high-v0.qss:ui" \
--add-data "DocViewerDesktop/resources/icons_svg/*:resources/icons_svg" \
--hidden-import="ui.ui_utils" \
--hidden-import="editor.editor_core" \
--hidden-import="editor.actions.file_actions" \
--hidden-import="editor.actions.edit_actions" \
DocViewerDesktop/main.py
- name: Build .deb package
run: |
sudo apt-get update
sudo apt-get install -y ruby ruby-dev build-essential
sudo gem install --no-document fpm
mkdir -p package/opt/docviewer
mkdir -p package/usr/share/applications
mkdir -p package/usr/share/icons/hicolor/256x256/apps
cp -r dist/DocViewer/* package/opt/docviewer/
chmod +x package/opt/docviewer/DocViewer
cp DocViewerDesktop/resources/icons_svg/doc_icon.png \
package/usr/share/icons/hicolor/256x256/apps/docviewer.png
cat <<EOF > package/usr/share/applications/docviewer.desktop
[Desktop Entry]
Type=Application
Name=DocViewer
Exec=/opt/docviewer/DocViewer
Icon=docviewer
Terminal=false
Categories=Utility;Office;
EOF
fpm -s dir -t deb \
-n docviewer \
-v "$VERSION" \
--architecture amd64 \
package/
mkdir -p artifacts
mv docviewer_${VERSION}_amd64.deb artifacts/
- name: Upload Linux artifact
uses: actions/upload-artifact@v4
with:
name: linux-deb
path: artifacts/*.deb
build-windows:
name: Build Windows
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r DocViewerDesktop/requirements.txt
pip install pyinstaller
- name: Build with PyInstaller (Windows)
shell: bash
run: |
pyinstaller --noconsole --name DocViewer \
--icon="DocViewerDesktop/resources/icons_svg/doc_icon.ico" \
--add-data "DocViewerDesktop/ui/dark-high-v0.qss;ui" \
--add-data "DocViewerDesktop/resources/icons_svg/*;resources/icons_svg" \
--hidden-import="ui.ui_utils" \
--hidden-import="editor.editor_core" \
--hidden-import="editor.actions.file_actions" \
--hidden-import="editor.actions.edit_actions" \
DocViewerDesktop/main.py
- name: Zip Windows build
shell: pwsh
run: |
mkdir artifacts
Compress-Archive -Path dist\DocViewer -DestinationPath artifacts\docviewer-windows.zip
- name: Upload Windows artifact
uses: actions/upload-artifact@v4
with:
name: windows-zip
path: artifacts/docviewer-windows.zip
release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [build-linux, build-windows]
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Create Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ env.VERSION }}
release_name: "DocViewer ${{ env.VERSION }}"
draft: false
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Linux .deb
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: linux-deb/docviewer_${{ env.VERSION }}_amd64.deb
asset_name: docviewer-linux.deb
asset_content_type: application/vnd.debian.binary-package
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Windows ZIP
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: windows-zip/docviewer-windows.zip
asset_name: docviewer-windows.zip
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}