Add github actions #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
workflow_dispatch: | |
jobs: | |
build: | |
strategy: | |
fail-fast: true | |
matrix: | |
build: | |
# - { name: 'TorPlayer-darwin', os: 'macos-latest' } | |
# - { name: 'TorPlayer-linux', os: 'ubuntu-latest' } | |
- { name: 'TorPlayer-windows', os: 'windows-latest' } | |
runs-on: ${{ matrix.build.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# Setup Golang | |
- name: Setup Golang | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.21 | |
check-latest: true | |
- run: go version | |
shell: bash | |
## 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/* | |
shell: bash | |
# Package MacOS | |
- name: Package MacOS | |
if: runner.os == 'macOS' | |
run: | | |
productbuild --component ./build/bin/TorPlayer.app ./build/bin/TorPlayer.pkg | |
shell: bash | |
## Windows | |
# Build Windows | |
- name: Build Windows | |
if: runner.os == 'Windows' | |
run: | | |
go build -ldflags -H=windowsgui -o build/bin/TorPlayer.exe | |
shell: bash | |
# Upload build assets | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: Build ${{matrix.build.name}} ${{runner.os}} | |
path: | | |
*/bin/*.pkg | |
*\bin\*.exe | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
*/bin/*.{pkg,exe} | |