Skip to content

Commit

Permalink
Merge pull request #66 from alvarorichard/ipc
Browse files Browse the repository at this point in the history
Ipc
  • Loading branch information
alvarorichard authored Nov 24, 2024
2 parents 091038f + 0f638ff commit 5bef3b2
Show file tree
Hide file tree
Showing 18 changed files with 1,672 additions and 380 deletions.
54 changes: 3 additions & 51 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,12 @@
#
#name: GoAnime CI
#
#on:
# push:
# branches: [ main, dev ]
# pull_request:
# branches: [ main, dev ]
# schedule:
# - cron: '0 0 * * *'
#
#jobs:
# build:
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# os: [ ubuntu-latest, windows-latest, macOS-latest ] # Added macOS target operating systems
# go-version: [ '1.22.0' ] # You can add more versions to test against multiple Go versions
# steps:
# - name: Set up Go
# uses: actions/setup-go@v3
# with:
# go-version: ${{ matrix.go-version }}
#
# - name: Check out code
# uses: actions/checkout@v3
#
# - name: Install dependencies (Linux)
# if: runner.os == 'Linux'
# run: |
# sudo apt update
# sudo apt install -y mpv yt-dlp
#
# - name: Install dependencies (Windows)
# if: runner.os == 'Windows'
# run: |
# choco install mpv
# choco install yt-dlp
#
# - name: Install dependencies (macOS)
# if: runner.os == 'macOS'
# run: |
# brew install mpv yt-dlp
#
# - name: Get dependencies
# run: go get -v -t -d ./...
#
# - name: Run tests
# run: go test -v ./...


name: GoAnime CI

on:
push:
branches: [ main, dev ]
branches: [ main, dev, ipc ]
pull_request:
branches: [ main, dev ]
branches: [ main, dev, ipc ]
schedule:
- cron: '0 0 * * *'

Expand Down
53 changes: 53 additions & 0 deletions build/buildlinux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@



#!/bin/bash

# Exit immediately if a command exits with a non-zero status
set -e

# Variables
OUTPUT_DIR="../build" # Adjusted to place the binary in the build directory
BINARY_NAME="goanime-linux"
BINARY_PATH="$OUTPUT_DIR/$BINARY_NAME"
TARBALL_NAME="$BINARY_NAME.tar.gz"
TARBALL_PATH="$OUTPUT_DIR/$TARBALL_NAME"
CHECKSUM_FILE="$TARBALL_PATH.sha256"
MAIN_PACKAGE="../cmd/goanime"

# Create the output directory if it doesn't exist
mkdir -p "$OUTPUT_DIR"

echo "Building the goanime binary for Linux..."
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "$BINARY_PATH" -ldflags="-s -w" -trimpath "$MAIN_PACKAGE"

echo "Build completed: $BINARY_PATH"

# Check if UPX is installed
if command -v upx >/dev/null 2>&1; then
echo "Compressing the binary with UPX..."
upx --best --ultra-brute "$BINARY_PATH"
echo "Compression completed."
else
echo "UPX not found. Skipping compression."
fi

# Create tarball
echo "Creating tarball..."
tar -czf "$TARBALL_PATH" -C "$OUTPUT_DIR" "$BINARY_NAME"
echo "Tarball created: $TARBALL_PATH"

# Generate SHA256 checksum for the tarball
echo "Generating SHA256 checksum for the tarball..."
# Check if sha256sum exists, else use shasum
if command -v sha256sum >/dev/null 2>&1; then
sha256sum "$TARBALL_PATH" > "$CHECKSUM_FILE"
elif command -v shasum >/dev/null 2>&1; then
shasum -a 256 "$TARBALL_PATH" > "$CHECKSUM_FILE"
else
echo "Neither sha256sum nor shasum is available. Cannot generate checksum."
exit 1
fi
echo "Checksum generated: $CHECKSUM_FILE"

echo "Build script completed successfully."
53 changes: 53 additions & 0 deletions build/buildmacos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@




#!/bin/bash

# Exit immediately if a command exits with a non-zero status
set -e

# Variables
OUTPUT_DIR="../build" # Adjusted to place the binary in the build directory
BINARY_NAME="goanime-apple-darwin"
BINARY_PATH="$OUTPUT_DIR/$BINARY_NAME"
TARBALL_NAME="$BINARY_NAME.tar.gz"
TARBALL_PATH="$OUTPUT_DIR/$TARBALL_NAME"
CHECKSUM_FILE="$TARBALL_PATH.sha256"
MAIN_PACKAGE="../cmd/goanime"

# Create the output directory if it doesn't exist
mkdir -p "$OUTPUT_DIR"

echo "Building the goanime binary for macOS..."
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o "$BINARY_PATH" -ldflags="-s -w" -trimpath "$MAIN_PACKAGE"

echo "Build completed: $BINARY_PATH"

# Check if UPX is installed
if command -v upx >/dev/null 2>&1; then
echo "Compressing the binary with UPX..."
upx --best --ultra-brute "$BINARY_PATH"
echo "Compression completed."
else
echo "UPX not found. Skipping compression."
fi

# Create tarball
echo "Creating tarball..."
tar -czf "$TARBALL_PATH" -C "$OUTPUT_DIR" "$BINARY_NAME"
echo "Tarball created: $TARBALL_PATH"

# Generate SHA256 checksum for the tarball
echo "Generating SHA256 checksum for the tarball..."
if command -v shasum >/dev/null 2>&1; then
shasum -a 256 "$TARBALL_PATH" > "$CHECKSUM_FILE"
elif command -v openssl >/dev/null 2>&1; then
openssl dgst -sha256 "$TARBALL_PATH" | awk '{print $2}' > "$CHECKSUM_FILE"
else
echo "Neither shasum nor openssl is available. Cannot generate checksum."
exit 1
fi
echo "Checksum generated: $CHECKSUM_FILE"

echo "Build script completed successfully."
64 changes: 64 additions & 0 deletions build/buildwindows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@


#!/bin/bash

# Sai imediatamente se um comando falhar
set -e

# Variáveis
OUTPUT_DIR="../build" # Diretório de saída para o binário e checksum
BINARY_NAME="goanime.exe" # Nome do binário para Windows
BINARY_PATH="$OUTPUT_DIR/$BINARY_NAME"
ZIP_NAME="goanime-windows.zip"
ZIP_PATH="$OUTPUT_DIR/$ZIP_NAME"
CHECKSUM_FILE="$ZIP_PATH.sha256"
MAIN_PACKAGE="../cmd/goanime"

# Detecta a arquitetura
ARCH=$(uname -m)
if [ "$ARCH" == "x86_64" ]; then
GOARCH=amd64
elif [ "$ARCH" == "arm64" ]; then
GOARCH=arm64
else
echo "Arquitetura não suportada: $ARCH"
exit 1
fi

# Cria o diretório de saída se não existir
mkdir -p "$OUTPUT_DIR"

echo "Compilando o binário goanime para Windows ($GOARCH)..."
CGO_ENABLED=0 GOOS=windows GOARCH=$GOARCH go build -o "$BINARY_PATH" -ldflags="-s -w" -trimpath "$MAIN_PACKAGE"

echo "Compilação concluída: $BINARY_PATH"

# Verifica se o UPX está instalado
if command -v upx >/dev/null 2>&1; then
echo "Comprimindo o binário com UPX..."
upx --best --ultra-brute "$BINARY_PATH"
echo "Compressão concluída."
else
echo "UPX não encontrado. Pulando compressão."
fi

# Cria arquivo ZIP
echo "Criando arquivo ZIP..."
zip -j "$ZIP_PATH" "$BINARY_PATH"
echo "Arquivo ZIP criado: $ZIP_PATH"

# Gera o checksum SHA256 para o arquivo ZIP
echo "Gerando checksum SHA256 para o arquivo ZIP..."
if command -v sha256sum >/dev/null 2>&1; then
sha256sum "$ZIP_PATH" > "$CHECKSUM_FILE"
elif command -v shasum >/dev/null 2>&1; then
shasum -a 256 "$ZIP_PATH" > "$CHECKSUM_FILE"
elif command -v openssl >/dev/null 2>&1; then
openssl dgst -sha256 "$ZIP_PATH" | awk '{print $2}' > "$CHECKSUM_FILE"
else
echo "Nem sha256sum, shasum ou openssl estão disponíveis. Não é possível gerar o checksum."
exit 1
fi
echo "Checksum gerado: $CHECKSUM_FILE"

echo "Script de build concluído com sucesso."
32 changes: 32 additions & 0 deletions build/install.iss
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[Setup]
AppName=GoAnime Installer
AppVersion=1.0.8
DefaultDirName={pf}\GoAnime
DefaultGroupName=GoAnime
AllowNoIcons=yes
OutputBaseFilename=GoAnimeInstaller
UsePreviousAppDir=yes
Compression=lzma2
SolidCompression=yes

[Tasks]
Name: "desktopicon"; Description: "Create a &desktop shortcut"; GroupDescription: "Additional Options";

[Files]
; Copia o executável principal do GoAnime
Source: "C:\Users\krone\Documents\GoAnime\build\goanime.exe"; DestDir: "{app}"; Flags: ignoreversion

; Copia os binários de mpv e yt-dlp para a pasta bin dentro do diretório de instalação
Source: "C:\Users\krone\Documents\GoAnime\build\mpv.exe"; DestDir: "{app}\bin"; Flags: ignoreversion
Source: "C:\Users\krone\Documents\GoAnime\build\yt-dlp.exe"; DestDir: "{app}\bin"; Flags: ignoreversion

[Icons]
; Cria o atalho no Menu Iniciar
Name: "{group}\GoAnime"; Filename: "{app}\goanime.exe"

; Cria o atalho na área de trabalho, se o usuário selecionar essa opção
Name: "{userdesktop}\GoAnime"; Filename: "{app}\goanime.exe"; Tasks: desktopicon

[Run]
; Adiciona mpv e yt-dlp ao PATH do usuário
Filename: "{cmd}"; Parameters: "/C setx PATH ""{app}\bin;%PATH%"""; Flags: runhidden runascurrentuser
Loading

0 comments on commit 5bef3b2

Please sign in to comment.