Skip to content

Commit 5bef3b2

Browse files
Merge pull request #66 from alvarorichard/ipc
Ipc
2 parents 091038f + 0f638ff commit 5bef3b2

18 files changed

+1672
-380
lines changed

.github/workflows/ci.yml

+3-51
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,12 @@
1-
#
2-
#name: GoAnime CI
3-
#
4-
#on:
5-
# push:
6-
# branches: [ main, dev ]
7-
# pull_request:
8-
# branches: [ main, dev ]
9-
# schedule:
10-
# - cron: '0 0 * * *'
11-
#
12-
#jobs:
13-
# build:
14-
# runs-on: ${{ matrix.os }}
15-
# strategy:
16-
# matrix:
17-
# os: [ ubuntu-latest, windows-latest, macOS-latest ] # Added macOS target operating systems
18-
# go-version: [ '1.22.0' ] # You can add more versions to test against multiple Go versions
19-
# steps:
20-
# - name: Set up Go
21-
# uses: actions/setup-go@v3
22-
# with:
23-
# go-version: ${{ matrix.go-version }}
24-
#
25-
# - name: Check out code
26-
# uses: actions/checkout@v3
27-
#
28-
# - name: Install dependencies (Linux)
29-
# if: runner.os == 'Linux'
30-
# run: |
31-
# sudo apt update
32-
# sudo apt install -y mpv yt-dlp
33-
#
34-
# - name: Install dependencies (Windows)
35-
# if: runner.os == 'Windows'
36-
# run: |
37-
# choco install mpv
38-
# choco install yt-dlp
39-
#
40-
# - name: Install dependencies (macOS)
41-
# if: runner.os == 'macOS'
42-
# run: |
43-
# brew install mpv yt-dlp
44-
#
45-
# - name: Get dependencies
46-
# run: go get -v -t -d ./...
47-
#
48-
# - name: Run tests
49-
# run: go test -v ./...
1+
502

513
name: GoAnime CI
524

535
on:
546
push:
55-
branches: [ main, dev ]
7+
branches: [ main, dev, ipc ]
568
pull_request:
57-
branches: [ main, dev ]
9+
branches: [ main, dev, ipc ]
5810
schedule:
5911
- cron: '0 0 * * *'
6012

build/buildlinux.sh

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
3+
4+
#!/bin/bash
5+
6+
# Exit immediately if a command exits with a non-zero status
7+
set -e
8+
9+
# Variables
10+
OUTPUT_DIR="../build" # Adjusted to place the binary in the build directory
11+
BINARY_NAME="goanime-linux"
12+
BINARY_PATH="$OUTPUT_DIR/$BINARY_NAME"
13+
TARBALL_NAME="$BINARY_NAME.tar.gz"
14+
TARBALL_PATH="$OUTPUT_DIR/$TARBALL_NAME"
15+
CHECKSUM_FILE="$TARBALL_PATH.sha256"
16+
MAIN_PACKAGE="../cmd/goanime"
17+
18+
# Create the output directory if it doesn't exist
19+
mkdir -p "$OUTPUT_DIR"
20+
21+
echo "Building the goanime binary for Linux..."
22+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "$BINARY_PATH" -ldflags="-s -w" -trimpath "$MAIN_PACKAGE"
23+
24+
echo "Build completed: $BINARY_PATH"
25+
26+
# Check if UPX is installed
27+
if command -v upx >/dev/null 2>&1; then
28+
echo "Compressing the binary with UPX..."
29+
upx --best --ultra-brute "$BINARY_PATH"
30+
echo "Compression completed."
31+
else
32+
echo "UPX not found. Skipping compression."
33+
fi
34+
35+
# Create tarball
36+
echo "Creating tarball..."
37+
tar -czf "$TARBALL_PATH" -C "$OUTPUT_DIR" "$BINARY_NAME"
38+
echo "Tarball created: $TARBALL_PATH"
39+
40+
# Generate SHA256 checksum for the tarball
41+
echo "Generating SHA256 checksum for the tarball..."
42+
# Check if sha256sum exists, else use shasum
43+
if command -v sha256sum >/dev/null 2>&1; then
44+
sha256sum "$TARBALL_PATH" > "$CHECKSUM_FILE"
45+
elif command -v shasum >/dev/null 2>&1; then
46+
shasum -a 256 "$TARBALL_PATH" > "$CHECKSUM_FILE"
47+
else
48+
echo "Neither sha256sum nor shasum is available. Cannot generate checksum."
49+
exit 1
50+
fi
51+
echo "Checksum generated: $CHECKSUM_FILE"
52+
53+
echo "Build script completed successfully."

build/buildmacos.sh

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
3+
4+
5+
#!/bin/bash
6+
7+
# Exit immediately if a command exits with a non-zero status
8+
set -e
9+
10+
# Variables
11+
OUTPUT_DIR="../build" # Adjusted to place the binary in the build directory
12+
BINARY_NAME="goanime-apple-darwin"
13+
BINARY_PATH="$OUTPUT_DIR/$BINARY_NAME"
14+
TARBALL_NAME="$BINARY_NAME.tar.gz"
15+
TARBALL_PATH="$OUTPUT_DIR/$TARBALL_NAME"
16+
CHECKSUM_FILE="$TARBALL_PATH.sha256"
17+
MAIN_PACKAGE="../cmd/goanime"
18+
19+
# Create the output directory if it doesn't exist
20+
mkdir -p "$OUTPUT_DIR"
21+
22+
echo "Building the goanime binary for macOS..."
23+
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o "$BINARY_PATH" -ldflags="-s -w" -trimpath "$MAIN_PACKAGE"
24+
25+
echo "Build completed: $BINARY_PATH"
26+
27+
# Check if UPX is installed
28+
if command -v upx >/dev/null 2>&1; then
29+
echo "Compressing the binary with UPX..."
30+
upx --best --ultra-brute "$BINARY_PATH"
31+
echo "Compression completed."
32+
else
33+
echo "UPX not found. Skipping compression."
34+
fi
35+
36+
# Create tarball
37+
echo "Creating tarball..."
38+
tar -czf "$TARBALL_PATH" -C "$OUTPUT_DIR" "$BINARY_NAME"
39+
echo "Tarball created: $TARBALL_PATH"
40+
41+
# Generate SHA256 checksum for the tarball
42+
echo "Generating SHA256 checksum for the tarball..."
43+
if command -v shasum >/dev/null 2>&1; then
44+
shasum -a 256 "$TARBALL_PATH" > "$CHECKSUM_FILE"
45+
elif command -v openssl >/dev/null 2>&1; then
46+
openssl dgst -sha256 "$TARBALL_PATH" | awk '{print $2}' > "$CHECKSUM_FILE"
47+
else
48+
echo "Neither shasum nor openssl is available. Cannot generate checksum."
49+
exit 1
50+
fi
51+
echo "Checksum generated: $CHECKSUM_FILE"
52+
53+
echo "Build script completed successfully."

build/buildwindows.sh

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
2+
3+
#!/bin/bash
4+
5+
# Sai imediatamente se um comando falhar
6+
set -e
7+
8+
# Variáveis
9+
OUTPUT_DIR="../build" # Diretório de saída para o binário e checksum
10+
BINARY_NAME="goanime.exe" # Nome do binário para Windows
11+
BINARY_PATH="$OUTPUT_DIR/$BINARY_NAME"
12+
ZIP_NAME="goanime-windows.zip"
13+
ZIP_PATH="$OUTPUT_DIR/$ZIP_NAME"
14+
CHECKSUM_FILE="$ZIP_PATH.sha256"
15+
MAIN_PACKAGE="../cmd/goanime"
16+
17+
# Detecta a arquitetura
18+
ARCH=$(uname -m)
19+
if [ "$ARCH" == "x86_64" ]; then
20+
GOARCH=amd64
21+
elif [ "$ARCH" == "arm64" ]; then
22+
GOARCH=arm64
23+
else
24+
echo "Arquitetura não suportada: $ARCH"
25+
exit 1
26+
fi
27+
28+
# Cria o diretório de saída se não existir
29+
mkdir -p "$OUTPUT_DIR"
30+
31+
echo "Compilando o binário goanime para Windows ($GOARCH)..."
32+
CGO_ENABLED=0 GOOS=windows GOARCH=$GOARCH go build -o "$BINARY_PATH" -ldflags="-s -w" -trimpath "$MAIN_PACKAGE"
33+
34+
echo "Compilação concluída: $BINARY_PATH"
35+
36+
# Verifica se o UPX está instalado
37+
if command -v upx >/dev/null 2>&1; then
38+
echo "Comprimindo o binário com UPX..."
39+
upx --best --ultra-brute "$BINARY_PATH"
40+
echo "Compressão concluída."
41+
else
42+
echo "UPX não encontrado. Pulando compressão."
43+
fi
44+
45+
# Cria arquivo ZIP
46+
echo "Criando arquivo ZIP..."
47+
zip -j "$ZIP_PATH" "$BINARY_PATH"
48+
echo "Arquivo ZIP criado: $ZIP_PATH"
49+
50+
# Gera o checksum SHA256 para o arquivo ZIP
51+
echo "Gerando checksum SHA256 para o arquivo ZIP..."
52+
if command -v sha256sum >/dev/null 2>&1; then
53+
sha256sum "$ZIP_PATH" > "$CHECKSUM_FILE"
54+
elif command -v shasum >/dev/null 2>&1; then
55+
shasum -a 256 "$ZIP_PATH" > "$CHECKSUM_FILE"
56+
elif command -v openssl >/dev/null 2>&1; then
57+
openssl dgst -sha256 "$ZIP_PATH" | awk '{print $2}' > "$CHECKSUM_FILE"
58+
else
59+
echo "Nem sha256sum, shasum ou openssl estão disponíveis. Não é possível gerar o checksum."
60+
exit 1
61+
fi
62+
echo "Checksum gerado: $CHECKSUM_FILE"
63+
64+
echo "Script de build concluído com sucesso."

build/install.iss

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[Setup]
2+
AppName=GoAnime Installer
3+
AppVersion=1.0.8
4+
DefaultDirName={pf}\GoAnime
5+
DefaultGroupName=GoAnime
6+
AllowNoIcons=yes
7+
OutputBaseFilename=GoAnimeInstaller
8+
UsePreviousAppDir=yes
9+
Compression=lzma2
10+
SolidCompression=yes
11+
12+
[Tasks]
13+
Name: "desktopicon"; Description: "Create a &desktop shortcut"; GroupDescription: "Additional Options";
14+
15+
[Files]
16+
; Copia o executável principal do GoAnime
17+
Source: "C:\Users\krone\Documents\GoAnime\build\goanime.exe"; DestDir: "{app}"; Flags: ignoreversion
18+
19+
; Copia os binários de mpv e yt-dlp para a pasta bin dentro do diretório de instalação
20+
Source: "C:\Users\krone\Documents\GoAnime\build\mpv.exe"; DestDir: "{app}\bin"; Flags: ignoreversion
21+
Source: "C:\Users\krone\Documents\GoAnime\build\yt-dlp.exe"; DestDir: "{app}\bin"; Flags: ignoreversion
22+
23+
[Icons]
24+
; Cria o atalho no Menu Iniciar
25+
Name: "{group}\GoAnime"; Filename: "{app}\goanime.exe"
26+
27+
; Cria o atalho na área de trabalho, se o usuário selecionar essa opção
28+
Name: "{userdesktop}\GoAnime"; Filename: "{app}\goanime.exe"; Tasks: desktopicon
29+
30+
[Run]
31+
; Adiciona mpv e yt-dlp ao PATH do usuário
32+
Filename: "{cmd}"; Parameters: "/C setx PATH ""{app}\bin;%PATH%"""; Flags: runhidden runascurrentuser

0 commit comments

Comments
 (0)