Skip to content

Update github-actions-builder.yml #30

Update github-actions-builder.yml

Update github-actions-builder.yml #30

name: Github Actions Builder
on:
push:
tags:
- "V[0-9]+.*" # Build for both Linux, Windows and macOS
- "VW[0-9]+.*" # Build for Windows only
- "VL[0-9]+.*" # Build for Linux only
- "VM[0-9]+.*" # Build for macOS only
jobs:
prepare:
runs-on: ubuntu-latest
steps:
- name: Test if the tag is valid
run: |
if [[ ! ${{ github.ref }} =~ ^refs/tags/V[0-9]+\..* ]]; then
echo "Invalid tag format. Please use the format Vx.x.x"
exit 1
fi
build-linux:
runs-on: ubuntu-latest
needs: prepare
if: startsWith(github.ref, 'refs/tags/VL') || startsWith(github.ref, 'refs/tags/V')
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y python3-tk
pip install customtkinter pyinstaller pillow requests
- name: Build with PyInstaller
run: |
pyinstaller --onefile ./main.py --name Firefox-Theme-Installer-Linux --hidden-import='PIL._tkinter_finder' --add-data="../Firefox-Theme-Installer/assets:assets" --add-data="../Firefox-Theme-Installer/language:language" --add-data="../Firefox-Theme-Installer/data/local:data/local" --hidden-import='PIL._tkinter_finder' --noconsole
- name: Upload Linux executable
uses: actions/upload-artifact@v3
with:
name: linux-executable
path: dist/Firefox-Theme-Installer-Linux
- name: Upload firefox icon
uses: actions/upload-artifact@v3
with:
name: firefox.png
path: assets/firefox.png
package-to-appimage:
runs-on: ubuntu-latest
needs: build-linux
if: startsWith(github.ref, 'refs/tags/VL') || startsWith(github.ref, 'refs/tags/V')
steps:
- name: Download Linux executable
uses: actions/download-artifact@v3
with:
name: linux-executable
- name: Download firefox icon
uses: actions/download-artifact@v3
with:
name: firefox.png
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y patchelf libfuse2
- name: Package into AppImage
run: |
mkdir -p Firefox-Theme-Installer.AppDir/usr/bin
cp Firefox-Theme-Installer-Linux Firefox-Theme-Installer.AppDir/usr/bin/
cp firefox.png Firefox-Theme-Installer.AppDir/
cat << 'EOF' > Firefox-Theme-Installer.AppDir/AppRun
#!/bin/bash
SELF=$(readlink -f "$0")
HERE=${SELF%/*}
EXEC="${HERE}/usr/bin/start_app.sh"
exec "${EXEC}"
EOF
chmod +x Firefox-Theme-Installer.AppDir/AppRun
cat << 'EOF' > Firefox-Theme-Installer.AppDir/Firefox-Theme-Installer.desktop
[Desktop Entry]
Type=Application
Name=Firefox Theme Installer
Exec=start_app.sh
Icon=firefox
Comment=Firefox Theme Installer
Categories=Utility;
EOF
chmod +x Firefox-Theme-Installer.AppDir/Firefox-Theme-Installer.desktop
cat << 'EOF' > Firefox-Theme-Installer.AppDir/usr/bin/start_app.sh
#!/bin/bash
APPIMAGE_DIR=$(dirname "$(realpath "$0")")
APP_EXECUTABLE="${APPIMAGE_DIR}/Firefox-Theme-Installer-Linux"
if [ ! -f "$APP_EXECUTABLE" ]; then
echo "Error: App executable not found: $APP_EXECUTABLE"
exit 1
fi
env DISPLAY="$DISPLAY" XAUTHORITY="$XAUTHORITY" "$APP_EXECUTABLE" "$@"
EOF
chmod +x Firefox-Theme-Installer.AppDir/usr/bin/start_app.sh
wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
chmod +x ./appimagetool-x86_64.AppImage
ARCH=x86_64 ./appimagetool-x86_64.AppImage Firefox-Theme-Installer.AppDir Firefox-Theme-Installer.AppImage
shell: bash
- name: Upload AppImage
uses: actions/upload-artifact@v3
with:
name: Firefox-Theme-Installer.AppImage
path: Firefox-Theme-Installer.AppImage
build-windows:
runs-on: windows-latest
needs: prepare
if: startsWith(github.ref, 'refs/tags/VW') || startsWith(github.ref, 'refs/tags/V')
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install customtkinter tk pillow requests pyinstaller
- name: Build with PyInstaller
run: |
pyinstaller --onefile .\main.py --name Firefox-Theme-Installer --icon=../Firefox-Theme-Installer/assets/firefox.ico --add-data "..\Firefox-Theme-Installer\assets:assets" --add-data "..\Firefox-Theme-Installer\language:language" --add-data "..\Firefox-Theme-Installer\data\local:data\local" --noconsole
- name: Create self-signed certificate
run: |
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes -subj "/CN=Firefox-Theme-Installer"
openssl pkcs12 -export -out cert.pfx -inkey key.pem -in cert.pem -passout pass:password
- name: Install Windows SDK
run: |
choco install windows-sdk-10.0 --confirm
shell: powershell
- name: Sign the executable
run: |
$env:PATH += ";C:\Program Files (x86)\Windows Kits\10\bin\x64"
signtool sign /f cert.pfx /p password /fd SHA256 /tr http://timestamp.digicert.com /td SHA256 dist\Firefox-Theme-Installer.exe
shell: powershell
- name: Upload signed executable
uses: actions/upload-artifact@v3
with:
name: Firefox-Theme-Installer.exe
path: dist\Firefox-Theme-Installer.exe
# build-macos:
# runs-on: macos-latest
# needs: prepare
# if: startsWith(github.ref, 'refs/tags/VM') || startsWith(github.ref, 'refs/tags/V')
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
# - name: Set up Python
# uses: actions/setup-python@v4
# with:
# python-version: "3.x"
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install customtkinter tk pillow requests pyinstaller
# - name: Build with PyInstaller
# run: |
# pyinstaller --onefile ./main.py --name Firefox-Theme-Installer-MacOS --hidden-import='PIL._tkinter_finder' --add-data="../Firefox-Theme-Installer/assets:assets" --add-data="../Firefox-Theme-Installer/language:language" --add-data="../Firefox-Theme-Installer/data/local:data/local" --noconsole
# - name: Upload macOS executable
# uses: actions/upload-artifact@v3
# with:
# name: theme-installer-macos
# path: dist/Firefox-Theme-Installer-MacOS
# package-to-dmg:
# runs-on: macos-latest
# needs: build-macos
# if: startsWith(github.ref, 'refs/tags/VM') || startsWith(github.ref, 'refs/tags/V')
# steps:
# - name: Download macOS executable
# uses: actions/download-artifact@v3
# with:
# name: theme-installer-macos
# - name: Install dependencies
# run: |
# brew install create-dmg
# - name: Package into DMG
# run: |
# create-dmg dist/Firefox-Theme-Installer-MacOS Firefox-Theme-Installer-MacOS.dmg
# shell: bash
# - name: Upload DMG
# uses: actions/upload-artifact@v3
# with:
# name: Firefox-Theme-Installer-MacOS.dmg
# path: Firefox-Theme-Installer-MacOS.dmg
create-release:
runs-on: ubuntu-latest
needs: [
build-linux,
package-to-appimage,
build-windows
# build-macos,
# package-to-dmg
]
steps:
- name: Download Linux AppImage
uses: actions/download-artifact@v3
with:
name: Firefox-Theme-Installer.AppImage
path: ./
- name: Download Windows Executable
uses: actions/download-artifact@v3
with:
name: Firefox-Theme-Installer.exe
path: ./
- name: Read info
id: tags
shell: bash
run: |
echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/}
echo ::set-output name=TAG::${GITHUB_REF/refs\/tags\//}
- name: Create Release
id: create_release
uses: actions/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.RFGITHUB_TOKEN }}
with:
tag_name: ${{ steps.tags.outputs.TAG }}
release_name: Release ${{ steps.tags.outputs.TAG }}
body: |
Release ${{ steps.tags.outputs.tag }}
draft: false
prerelease: false
- name: Upload Linux AppImage
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.RFGITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./Firefox-Theme-Installer.AppImage
asset_name: Firefox-Theme-Installer-Linux.AppImage
asset_content_type: application/x-executable
- name: Upload Windows Executable
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.RFGITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./Firefox-Theme-Installer.exe
asset_name: Firefox-Theme-Installer.exe
asset_content_type: application/x-msdownload
# - name: Upload macOS DMG
# uses: softprops/action-gh-release@v1
# with:
# tag: ${{ github.ref }}
# files: |
# /home/runner/work/Firefox-Theme-Installer/Firefox-Theme-Installer/Firefox-Theme-Installer-MacOS.dmg
# env:
# GITHUB_TOKEN: ${{ secrets.RFGITHUB_TOKEN }}