Skip to content

Commit

Permalink
multiplatform release build
Browse files Browse the repository at this point in the history
  • Loading branch information
parMaster committed Sep 5, 2023
1 parent 770eef9 commit dbb40d6
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 70 deletions.
69 changes: 0 additions & 69 deletions .goreleaser.yml

This file was deleted.

4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ release:
@echo " \n\n +++ +++ +++ +++ +++ config.yml +++ +++ +++ +++ +++ \n\n "
cat dist/config.yml | sed 's/:/:\x1b[31m/g; s/#.*//' | awk '{print "\x1b[0m"$$0}'
@echo " \n\n "
goreleaser --snapshot --skip-publish --clean
cd dist && ./multibuild.sh $(GITREV)
cd ..
ls -l dist/release


.PHONY: build buildsvc dbg test run info status deploy start stop cli release
36 changes: 36 additions & 0 deletions dist/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This file is part of the zoomrs project: https://github.com/parmaster/zoomrs

# get current user name
USER=$(shell whoami)
# get current user group
GROUP=$(shell id -gn)

run:
./zoomrs

status:
sudo systemctl status zoomrs.service

stop:
sudo systemctl stop zoomrs.service

start:
sudo systemctl start zoomrs.service

deploy:
sudo systemctl stop zoomrs.service || true
sudo cp zoomrs /usr/bin/
sudo chown $(USER):$(GROUP) /usr/bin/zoomrs
sed -i "s/%USER%/$(USER)/g" zoomrs.service
sudo cp zoomrs.service /etc/systemd/system/
sudo mkdir -p /etc/zoomrs
sudo chown $(USER):$(GROUP) /etc/zoomrs
cp config.yml /etc/zoomrs/
sudo systemctl daemon-reload
sudo systemctl enable zoomrs.service
sudo systemctl start zoomrs.service

cli:
./zoomrs-cli --config ./config_cli.yml

.PHONY: build buildsvc dbg test run info status deploy start stop cli
41 changes: 41 additions & 0 deletions dist/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Zoomrs - Zoom meetings recordings download service

### This is a binary distribution of Zoomrs project, a very brief description follows. For more information please refer to the [README](https://github.com/parmaster/zoomrs#readme) in main repository.

## Configuration
Example self-documented configuration file `config.yml` included.

## Running the service

### Foreground mode
Plain and simple `./zoomrs` should load a default `config.yml` file and launch if everything is configured correctly:

./zoomrs

or specify config file and debug mode:

./zoomrs --config custom_config.yml --dbg

To stop the service press `Ctrl+C` (or send `SIGINT`, `SIGTERM` signal to the process)

### Systemd service
1. Configure the service and make sure it runs in foreground mode (see above).
2. Run `make deploy` to build the binary and copy everything where it belongs (see `Makefile` and `zoomrs.service` for details), enable and run the service

make deploy

3. Run `make status` to check the status of the service

make status

Log files are located at `/var/log/zoomrs.log` and `/var/log/zoomrs.err` by default.

### CLI Tool
CLI tool command example:

./zoomrs-cli --cmd check --config config.yml

Refer to the [README](https://github.com/parmaster/zoomrs#readme) in main repository to learn more about the CLI tool and its commands.

## Responsibility
The author of this project is not responsible for any damage caused by the use of this software. Use it at your own risk.
46 changes: 46 additions & 0 deletions dist/multibuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

# Define the arrays of OS and architecture
os=("linux" "darwin" "windows")
arch=("amd64" "arm64")

# Define the ignore list
ignore=("windows/arm64")

# apps is a map of app name to the source directory
declare -A apps
apps["zoomrs"]="../cmd/service"
apps["zoomrs-cli"]="../cmd/cli"

# version is passed in as an argument
version=$1

# Loop through the OS and architecture arrays
for o in "${os[@]}"; do
for a in "${arch[@]}"; do
# Check if the current combination is in the ignore list
combination="$o/$a"
if [[ " ${ignore[*]} " == *" $combination "* ]]; then
echo "Ignoring $combination"
else
# Build the application for the current combination
for app in "${!apps[@]}"; do
source="${apps[$app]}"
out_dir="release/zoomrs_${o}_${a}_${version}"
mkdir -p $out_dir
echo "Building $app for $combination into $out_dir"
if [ "$o" == "windows" ]; then
app="$app.exe"
fi
GOOS="$o" GOARCH="$a" go build -o "$out_dir/$app" "$source"
done
cp ./README.md "$out_dir/"
cp ../LICENSE "$out_dir/"
cp ./Makefile "$out_dir/"
cp ./config.yml "$out_dir/"
cp ./zoomrs.service "$out_dir/"
tar -czvf "$out_dir.tar.gz" -C "$out_dir" .
rm -rf "$out_dir"
fi
done
done

0 comments on commit dbb40d6

Please sign in to comment.