Skip to content

Commit

Permalink
Update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ChienNM3 committed Jan 31, 2024
1 parent c806ea9 commit 32ecd80
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 27 deletions.
48 changes: 26 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
fail-fast: true
matrix:
build:
# - { name: 'TorPlayer-darwin', os: 'macos-latest' }
# - { name: 'TorPlayer-linux', os: 'ubuntu-latest' }
- { name: 'TorPlayer-windows', os: 'windows-latest' }
- { name: 'TorPlayer', os: 'macos-latest' }
- { name: 'TorPlayer', os: 'ubuntu-latest' }
- { name: 'TorPlayer', os: 'windows-latest' }

runs-on: ${{ matrix.build.os }}
steps:
Expand All @@ -32,46 +32,50 @@ jobs:
- run: go version
shell: bash

## MacOS
# ---- MacOS-------
# Build MacOS
- name: Build MacOS
if: runner.os == 'macOS'
run: |
mkdir -p ./build/bin/TorPlayer.app/Contents/MacOS
mkdir -p ./build/bin/TorPlayer.app/Contents/Resources
cp ./build/darwin/Info.plist ./build/bin/TorPlayer.app/Contents
cp ./build/darwin/iconfile.icns ./build/bin/TorPlayer.app/Contents/Resources
go build -o build/bin/TorPlayer.app/Contents/MacOS/TorPlayer
chmod +x build/bin/*/Contents/MacOS/*
./build/build-macos.sh ${{github.ref_name}}
shell: bash
# ---- End MacOS --------

# Package MacOS
- name: Package MacOS
if: runner.os == 'macOS'
run: |
productbuild --component ./build/bin/TorPlayer.app ./build/bin/TorPlayer.pkg
shell: bash

## Windows
# ------ Windows --------
# Build Windows
- name: Build Windows
if: runner.os == 'Windows'
run: |
go build -ldflags -H=windowsgui -o build/bin/TorPlayer.exe
.\build\build-windows.bat ${{github.ref_name}}
shell: powershell
# ------ End Windows -------

# ----- Linux --------
- name: Install dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install gcc libgtk-3-dev libayatana-appindicator3-dev
shell: bash
# Build Linux
- name: Build Linux
if: runner.os == 'Linux'
run: |
./build/build-linux.sh ${{github.ref_name}}
shell: bash
# ----- End Linux -------

# Upload build assets
- uses: actions/upload-artifact@v4
with:
name: Build ${{matrix.build.name}} ${{runner.os}}
path: |
*/bin/*.pkg
*/bin/*.deb
*\bin\*.exe
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
*/bin/*.{pkg,exe}
*/bin/*.{pkg,exe,deb}
43 changes: 43 additions & 0 deletions build/build-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh

SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"

readonly VERSION="${1:-0.0.1}"
readonly APP=TorPlayer
readonly APPDIR=build/bin/${APP}_${VERSION}


mkdir -p "$APPDIR/usr/bin"
mkdir -p "$APPDIR/usr/share/applications"
mkdir -p "$APPDIR/usr/share/icons/hicolor/1024x1024/apps"
mkdir -p "$APPDIR/usr/share/icons/hicolor/256x256/apps"
mkdir -p "$APPDIR/DEBIAN"

go build -o "$APPDIR/usr/bin/$APP"
chmod +x "$APPDIR/usr/bin/$APP"

cp "$SCRIPT_DIR/icons/icon.png" "$APPDIR/usr/share/icons/hicolor/1024x1024/apps/${APP}.png"
cp "$SCRIPT_DIR/icons/icon.png" "$APPDIR/usr/share/icons/hicolor/256x256/apps/${APP}.png"

cat > "$APPDIR/usr/share/applications/${APP}.desktop" << EOF
[Desktop Entry]
Version=1.0
Type=Application
Name=$APP
Exec=$APP
Icon=$APP
Terminal=false
StartupWMClass=TorPlayer
EOF

cat > "$APPDIR/DEBIAN/control" << EOF
Package: ${APP}
Version: 1.0-0
Section: base
Priority: optional
Architecture: amd64
Maintainer: Chien Nguyen
Description: TorPlayer is a simple video player from the torrent network.
EOF

dpkg-deb --build "$APPDIR"
29 changes: 24 additions & 5 deletions build/darwin/Info.plist → build/build-macos.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
#!/bin/sh

SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"

readonly VERSION="${1:-0.0.1}"
readonly APPDIR="build/bin/TorPlayer_${VERSION}.app"


mkdir -p $APPDIR/Contents/{MacOS,Resources}

go build -o $APPDIR/Contents/MacOS/TorPlayer
chmod +x $APPDIR/Contents/MacOS/*

cat > $APPDIR/Contents/Info.plist << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
Expand All @@ -10,20 +25,24 @@
<key>CFBundleIdentifier</key>
<string>com.TorPlayer</string>
<key>CFBundleVersion</key>
<string>1.0.0</string>
<string>$VERSION</string>
<key>CFBundleGetInfoString</key>
<string>Built using Go</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<string>$VERSION</string>
<key>CFBundleIconFile</key>
<string>iconfile</string>
<string>icon.icns</string>
<key>LSMinimumSystemVersion</key>
<string>10.13.0</string>
<key>NSHighResolutionCapable</key>
<string>true</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright.........</string>


</dict>
</plist>
EOF

cp $SCRIPT_DIR/icons/icon.icns $APPDIR/Contents/Resources/icon.icns
find $APPDIR

productbuild --component $APPDIR ./build/bin/TorPlayer_${VERSION}.pkg
3 changes: 3 additions & 0 deletions build/build-windows.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

go build -ldflags "-H windowsgui" -o build\bin\TorPlayer.exe
File renamed without changes.
Binary file added build/icons/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 32ecd80

Please # to comment.