Big refactor

This commit is contained in:
Ben Sarmiento
2023-11-14 01:55:00 +01:00
parent 5e723a9e8a
commit 16505ec33f
26 changed files with 1602 additions and 453 deletions

View File

@@ -1,103 +0,0 @@
name: Build zurg-testing executable binary
on:
push:
branches:
- main
tags:
- v0*
- latest
jobs:
determine_version:
runs-on: ubuntu-latest
outputs:
build_version: ${{ steps.set_version.outputs.version }}
steps:
- id: set_version
run: |
CURRENT_DATE=$(date +'%Y%m%d%H%M')
echo "version=beta-${CURRENT_DATE}" >> $GITHUB_OUTPUT
build:
name: Build
runs-on: ubuntu-latest
needs: determine_version
strategy:
matrix:
goos: [windows, darwin, linux]
goarch: [386, amd64, arm, arm64]
exclude:
- goos: darwin
goarch: 386
- goos: darwin
goarch: arm
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 'stable'
- name: Build
run: |
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-s -w" -o zurg-${{ needs.determine_version.outputs.build_version }}-${{ matrix.goos }}-${{ matrix.goarch }} cmd/zurg/main.go
# Install and use UPX to compress the binary, but exclude specific combinations
- name: Install and Compress with UPX
if: (matrix.goos != 'windows' || matrix.goarch != 'arm') && (matrix.goos != 'windows' || matrix.goarch != 'arm64')
run: |
sudo apt-get update
sudo apt-get install -y upx-ucl
upx --best zurg-${{ needs.determine_version.outputs.build_version }}-${{ matrix.goos }}-${{ matrix.goarch }}
# Zip the binary
- name: Zip Binary
run: |
zip zurg-${{ needs.determine_version.outputs.build_version }}-${{ matrix.goos }}-${{ matrix.goarch }}.zip zurg-${{ needs.determine_version.outputs.build_version }}-${{ matrix.goos }}-${{ matrix.goarch }}
- name: List files
run: ls -alh
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: zurg-${{ needs.determine_version.outputs.build_version }}-${{ matrix.goos }}-${{ matrix.goarch }}.zip
path: zurg-${{ needs.determine_version.outputs.build_version }}-${{ matrix.goos }}-${{ matrix.goarch }}.zip
release:
needs:
- determine_version
- build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3
- name: Release
uses: softprops/action-gh-release@v1
with:
name: ${{ needs.determine_version.outputs.build_version }}
tag_name: ${{ needs.determine_version.outputs.build_version }}
generate_release_notes: true
files: |
./zurg-${{ needs.determine_version.outputs.build_version }}-darwin-amd64.zip
./zurg-${{ needs.determine_version.outputs.build_version }}-darwin-arm64.zip
./zurg-${{ needs.determine_version.outputs.build_version }}-linux-386.zip
./zurg-${{ needs.determine_version.outputs.build_version }}-linux-amd64.zip
./zurg-${{ needs.determine_version.outputs.build_version }}-linux-arm.zip
./zurg-${{ needs.determine_version.outputs.build_version }}-linux-arm64.zip
./zurg-${{ needs.determine_version.outputs.build_version }}-windows-386.zip
./zurg-${{ needs.determine_version.outputs.build_version }}-windows-amd64.zip
./zurg-${{ needs.determine_version.outputs.build_version }}-windows-arm.zip
./zurg-${{ needs.determine_version.outputs.build_version }}-windows-arm64.zip
token: ${{ secrets.PAT }}
env:
GITHUB_REPOSITORY: debridmediamanager/zurg-testing
- name: List files
run: ls -alh

40
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,40 @@
name: build
on:
push:
branches: [ '**' ]
pull_request:
branches: [ '**' ]
jobs:
build:
strategy:
matrix:
platform: [ubuntu-latest]
go-version: [1.21.3]
name: Build
runs-on: ${{ matrix.platform }}
steps:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: |
docker pull techknowlogick/xgo:latest
go install src.techknowlogick.com/xgo@latest
sudo apt install upx
- name: Build
run: |
bash build.sh dev
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: zurg
path: dist