diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e96f795..e4f53a7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -64,6 +64,12 @@ jobs: cache: 'pnpm' cache-dependency-path: './frontend/pnpm-lock.yaml' + # Get the version from the common/.version file and set it as an environment variable + - name: Set SPINUP_VERSION + id: get_version + run: echo "SPINUP_VERSION=$(cat ./common/.version | sed 's/^v//')" >> $GITHUB_ENV + shell: bash + # install Wails - name: Install Wails run: go install github.com/wailsapp/wails/v2/cmd/wails@latest @@ -87,18 +93,16 @@ jobs: if: runner.os == 'Linux' working-directory: ${{ env.WORKING_DIRECTORY }} run: | - SPINUP_VERSION=$(cat ./common/.version | sed 's/^v//') - sed -i.bak "s/{{version}}/${SPINUP_VERSION}/g" wails.json && rm wails.json.bak + sed -i.bak "s/{{version}}/${{ env.SPINUP_VERSION }}/g" wails.json && rm wails.json.bak - wails build --platform ${{ matrix.build.platform }} -webview2 ${{ env.WEBVIEW2 }} -o ${{ matrix.build.name }}-${SPINUP_VERSION} -tags webkit2_40 - wails build --platform ${{ matrix.build.platform }} -webview2 ${{ env.WEBVIEW2 }} -o ${{ matrix.build.name }}-${SPINUP_VERSION}-ubuntu24.04 -tags webkit2_41 + wails build --platform ${{ matrix.build.platform }} -webview2 ${{ env.WEBVIEW2 }} -o ${{ matrix.build.name }}-${{ env.SPINUP_VERSION }} -tags webkit2_40 + wails build --platform ${{ matrix.build.platform }} -webview2 ${{ env.WEBVIEW2 }} -o ${{ matrix.build.name }}-${{ env.SPINUP_VERSION }}-ubuntu24.04 -tags webkit2_41 shell: bash - name: Build macOs App if: runner.os == 'macOS' working-directory: ${{ env.WORKING_DIRECTORY }} run: | - SPINUP_VERSION=$(cat ./common/.version | sed 's/^v//') - sed -i.bak "s/{{version}}/${SPINUP_VERSION}/g" wails.json && rm wails.json.bak + sed -i.bak "s/{{version}}/${{ env.SPINUP_VERSION }}/g" wails.json && rm wails.json.bak wails build --platform ${{ matrix.build.platform }} -webview2 ${{ env.WEBVIEW2 }} -o ${{ matrix.build.name }} shell: bash @@ -106,10 +110,9 @@ jobs: if: runner.os == 'Windows' working-directory: ${{ env.WORKING_DIRECTORY }} run: | - SPINUP_VERSION=$(cat ./common/.version | sed 's/^v//') - sed -i "s/{{version}}/${SPINUP_VERSION}/g" wails.json + sed -i "s/{{version}}/${{ env.SPINUP_VERSION }}/g" wails.json - wails build --platform ${{ matrix.build.platform }} -webview2 ${{ env.WEBVIEW2 }} -nsis -o ${{ matrix.build.name }}-${SPINUP_VERSION} + wails build --platform ${{ matrix.build.platform }} -webview2 ${{ env.WEBVIEW2 }} -nsis -o ${{ matrix.build.name }}-${{ env.SPINUP_VERSION }} shell: bash # Add permissions to the binary @@ -133,8 +136,8 @@ jobs: with: key: ${{ runner.os }}-icons-${{ hashFiles('images/icon-large.png') }} path: | - build/unix/usr/share/icons - build/unix/usr/share/pixmaps + packaging/unix/usr/share/icons + packaging/unix/usr/share/pixmaps - name: Generate icons # if: (runner.os == 'Linux' || runner.os == 'macOS') && steps.cache-icons.outputs.cache-hit != 'true' if: runner.os == 'Linux' && steps.cache-icons.outputs.cache-hit != 'true' @@ -160,6 +163,28 @@ jobs: working-directory: ${{ env.WORKING_DIRECTORY }} run: bash ./scripts/release/package-rpm.sh + # Check if Ubuntu deb installs correctly + - name: Check if Ubuntu deb installs correctly + if: runner.os == 'Linux' + working-directory: ${{ env.WORKING_DIRECTORY }} + run: | + sudo apt-get install -y libgtk-3-0 libwebkit2gtk-4.1-dev nginx dnsmasq + sudo dpkg -i ./deb/spinup-${{ env.SPINUP_VERSION }}-ubuntu24.04.deb + spinup --version + shell: bash + + # Check if macOS zip installs correctly + - name: Check if macOS zip installs correctly + if: runner.os == 'macOS' + working-directory: ${{ env.WORKING_DIRECTORY }} + run: | + brew install nginx dnsmasq + unzip -q -o ./spinup-${{ env.SPINUP_VERSION }}-macos.zip -d /tmp/spinup + cd /tmp/spinup/ + sudo bash ./install.sh + spinup --version + shell: bash + # Upload build assets - uses: actions/upload-artifact@v4 with: diff --git a/README.md b/README.md index 6229832..b8e2549 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,14 @@ Quickly spin up your multi command projects. To install the required packages on a debian based system you can use the following command: ```bash -sudo apt install nginx dnsmasq +sudo apt install libgtk-3-0 libwebkit2gtk-4.0-dev nginx dnsmasq ``` -Download a `.deb` package from the releases. There is a separate version for Ubuntu 24.04 since it uses a different version of the `libwebkit2gtk` package. +> **Note** +> +> For Ubuntu 24.04 and up, you should install `libwebkit2gtk-4.1-dev` instead of `libwebkit2gtk-4.0-dev`. + +Download the `.deb` package from the releases. There is a separate version for Ubuntu 24.04 due to the different `libwebkit2gtk` package version being used. To install the package run the following command where `{{version}}` is the version of the package: ```bash @@ -59,19 +63,9 @@ Download the `spinup-{{version}}-macos.zip` archive from the releases and unzip unzip spinup-{{version}}-macos.zip ``` -Then move the `usr/share/spinup` folder to `/usr/share/spinup`: -```bash -sudo mv -R ./spinup-{{version}}-macos/usr/share/spinup /usr/share -``` - -The same for the sudoers file: -```bash -sudo mv -R ./spinup-{{version}}-macos/etc/sudoers.d/spinup /etc/sudoers.d/spinup -``` - -To complete the installation run the post install script: +Run the installation script: ```bash -sudo ./spinup-{{version}}-macos/postinstall.sh +sudo ./spinup-{{version}}-macos/install.sh ``` This will create the required directories and files. diff --git a/build/DEBIAN/control b/packaging/DEBIAN/control similarity index 100% rename from build/DEBIAN/control rename to packaging/DEBIAN/control diff --git a/build/DEBIAN/postinst b/packaging/DEBIAN/postinst similarity index 97% rename from build/DEBIAN/postinst rename to packaging/DEBIAN/postinst index 2ce1dae..08266bf 100755 --- a/build/DEBIAN/postinst +++ b/packaging/DEBIAN/postinst @@ -39,9 +39,6 @@ fi if [ ! -f /etc/dnsmasq.d/spinup.conf ]; then # Link the dnsmasq configuration file for spinup to the dnsmasq.d directory if it doesn't exist ln -s /usr/share/spinup/config/dnsmasq.conf /etc/dnsmasq.d/spinup.conf - - # Restart the dnsmasq service - systemctl restart dnsmasq fi ############# @@ -53,6 +50,7 @@ SPINUP_NGINX_DIR="/usr/share/spinup/config/nginx" # Create the user's spinup nginx directory if it doesn't exist mkdir -p $USER_SPINUP_NGINX_DIR +chown -R $SUDO_USER:$SUDO_USER $USER_HOME/.config/spinup if [ ! -d $SPINUP_NGINX_DIR ]; then # Link the user's spinup nginx directory to the spinup config directory if it doesn't exist diff --git a/build/DEBIAN/postrm b/packaging/DEBIAN/postrm similarity index 100% rename from build/DEBIAN/postrm rename to packaging/DEBIAN/postrm diff --git a/packaging/macos/install.sh b/packaging/macos/install.sh new file mode 100644 index 0000000..457763b --- /dev/null +++ b/packaging/macos/install.sh @@ -0,0 +1,107 @@ +#!/usr/bin/env bash + +# Make sure the script is being run as root +if [ "$(id -u)" -ne 0 ]; then + echo "This script must be run as root" >&2 + exit 1 +fi + +# Check if the SUDO_USER environment variable is set +if [ -z "$SUDO_USER" ]; then + echo "The SUDO_USER environment variable is not set" >&2 + exit 1 +fi + +# Get the home directory of the user that ran the script +USER_HOME="/Users/$SUDO_USER" + +# Make sure the user's home directory exists +if [ ! -d "$USER_HOME" ]; then + echo "The user's home directory does not exist" >&2 + exit 1 +fi + +SPINUP_SHARE_DIR="/usr/local/share/spinup" + +##################### +### General setup ### +##################### + +# Copy over the /usr/local/share/spinup directory to the correct location +cp -r ./usr/local/share/spinup /usr/local/share + +# Remove the old symlink if it exists and create a new one +rm -f /usr/local/bin/spinup +ln -s $SPINUP_SHARE_DIR/bin/spinup /usr/local/bin/spinup + +# Set the correct permissions on the spinup directory +chown -R root:wheel $SPINUP_SHARE_DIR + +############### +### Dnsmasq ### +############### + +if [ ! -d /etc/dnsmasq.d ]; then + # Create the dnsmasq.d directory if it doesn't exist + mkdir /etc/dnsmasq.d +fi + +# Check if the spinup.conf already exists in the dnsmasq.d directory +if [ ! -f /etc/dnsmasq.d/spinup.conf ]; then + # Link the dnsmasq configuration file for spinup to the dnsmasq.d directory if it doesn't exist + ln -s $SPINUP_SHARE_DIR/config/dnsmasq.conf /etc/dnsmasq.d/spinup.conf + + # Restart the dnsmasq service + brew services restart dnsmasq +fi + +############# +### Nginx ### +############# + +USER_SPINUP_NGINX_DIR="$USER_HOME/.config/spinup/nginx" +SPINUP_NGINX_DIR="/usr/local/share/spinup/config/nginx" +BREW_NGINX_DIR="/opt/homebrew/etc/nginx" + +# Create the user's spinup nginx directory if it doesn't exist +mkdir -p $USER_SPINUP_NGINX_DIR + +if [ ! -d $SPINUP_NGINX_DIR ]; then + # Link the user's spinup nginx directory to the spinup config directory if it doesn't exist + ln -s $USER_SPINUP_NGINX_DIR $SPINUP_NGINX_DIR +fi + +# Add the user's spinup nginx directory to the nginx configuration +if ! grep -q "include ${SPINUP_NGINX_DIR}/\*.conf;" $BREW_NGINX_DIR/nginx.conf; then + # Make a backup of the nginx configuration file + cp $BREW_NGINX_DIR/nginx.conf $BREW_NGINX_DIR/nginx.conf.bak + + # Add the include directive to the bottom of the http section in the nginx configuration file + sed -i '/http {/!b; :a; N; /}/!ba; s/}/\tinclude '"${SPINUP_NGINX_DIR//\//\\/}"'\/\*.conf;\n}/' $BREW_NGINX_DIR/nginx.conf +fi + +# Restart the nginx service +brew services restart nginx + +############### +### Sudoers ### +############### + +# Add an include for the sudoers.d directory to the sudoers file if it doesn't already exist +if ! grep -q "^@includedir /etc/sudoers.d[[:space:]]*$" /etc/sudoers; then + # Make a backup of the sudoers file + cp /etc/sudoers /etc/sudoers.bak + + # Add the include directive to the sudoers file + echo "@includedir /etc/sudoers.d" | visudo -c -f - &>/dev/null && echo "@includedir /etc/sudoers.d" | EDITOR='tee -a' visudo &>/dev/null +fi + +SUDOERS_FILE=/etc/sudoers.d/spinup + +# Move the spinup sudoers file to the /etc/sudoers.d directory +mv .$SUDOERS_FILE $SUDOERS_FILE +chmod 440 $SUDOERS_FILE +chown root:wheel $SUDOERS_FILE + +# Set the correct permissions on the user's spinup .config directory +chown -R $SUDO_USER:staff $USER_HOME/.config/spinup diff --git a/build/rpmbuild/BUILD/.gitkeep b/packaging/rpmbuild/BUILD/.gitkeep similarity index 100% rename from build/rpmbuild/BUILD/.gitkeep rename to packaging/rpmbuild/BUILD/.gitkeep diff --git a/build/rpmbuild/BUILDROOT/.gitkeep b/packaging/rpmbuild/BUILDROOT/.gitkeep similarity index 100% rename from build/rpmbuild/BUILDROOT/.gitkeep rename to packaging/rpmbuild/BUILDROOT/.gitkeep diff --git a/build/rpmbuild/RPMS/.gitkeep b/packaging/rpmbuild/RPMS/.gitkeep similarity index 100% rename from build/rpmbuild/RPMS/.gitkeep rename to packaging/rpmbuild/RPMS/.gitkeep diff --git a/build/rpmbuild/SOURCES/.gitkeep b/packaging/rpmbuild/SOURCES/.gitkeep similarity index 100% rename from build/rpmbuild/SOURCES/.gitkeep rename to packaging/rpmbuild/SOURCES/.gitkeep diff --git a/build/rpmbuild/SPECS/spinup.spec b/packaging/rpmbuild/SPECS/spinup.spec similarity index 100% rename from build/rpmbuild/SPECS/spinup.spec rename to packaging/rpmbuild/SPECS/spinup.spec diff --git a/build/rpmbuild/SRPMS/.gitkeep b/packaging/rpmbuild/SRPMS/.gitkeep similarity index 100% rename from build/rpmbuild/SRPMS/.gitkeep rename to packaging/rpmbuild/SRPMS/.gitkeep diff --git a/build/unix/etc/sudoers.d/spinup b/packaging/unix/etc/sudoers.d/spinup similarity index 100% rename from build/unix/etc/sudoers.d/spinup rename to packaging/unix/etc/sudoers.d/spinup diff --git a/build/unix/usr/share/applications/spinup-app.desktop b/packaging/unix/usr/share/applications/spinup-app.desktop similarity index 100% rename from build/unix/usr/share/applications/spinup-app.desktop rename to packaging/unix/usr/share/applications/spinup-app.desktop diff --git a/build/unix/usr/share/spinup/config/dnsmasq.conf b/packaging/unix/usr/share/spinup/config/dnsmasq.conf similarity index 100% rename from build/unix/usr/share/spinup/config/dnsmasq.conf rename to packaging/unix/usr/share/spinup/config/dnsmasq.conf diff --git a/scripts/generate-icons.sh b/scripts/generate-icons.sh index 3c54e6c..bcbf2e3 100755 --- a/scripts/generate-icons.sh +++ b/scripts/generate-icons.sh @@ -2,7 +2,7 @@ SOURCE="./images/icon-large.png" SIZES=(1024 512 256 128 64 32 16) -SHARE_DIR="./build/unix/usr/share" +SHARE_DIR="./packaging/unix/usr/share" PIXMAPS_DIR="$SHARE_DIR/pixmaps" mkdir -p $SHARE_DIR/icons/hicolor diff --git a/scripts/release/package-deb.sh b/scripts/release/package-deb.sh index 1267aff..c45fa74 100755 --- a/scripts/release/package-deb.sh +++ b/scripts/release/package-deb.sh @@ -9,17 +9,17 @@ for os_version in "" "-ubuntu24.04"; do # Copy the necessary files to the .deb package directory cp build/bin/spinup-${SPINUP_VERSION}${os_version} deb/spinup-${SPINUP_VERSION}${os_version}/usr/share/spinup/bin/spinup - cp build/DEBIAN/* deb/spinup-${SPINUP_VERSION}${os_version}/DEBIAN - cp -r build/unix/usr deb/spinup-${SPINUP_VERSION}${os_version} + cp packaging/DEBIAN/* deb/spinup-${SPINUP_VERSION}${os_version}/DEBIAN + cp -r packaging/unix/usr deb/spinup-${SPINUP_VERSION}${os_version} # Update the control file with the current version number echo -e "\nVersion: $SPINUP_VERSION" >> deb/spinup-${SPINUP_VERSION}${os_version}/DEBIAN/control # Add the dependencies for the .deb package - if [ "$os_version" -eq "" ]; then - echo "Depends: dnsmasq, libgtk-3-0, libwebkit2gtk-4.0-dev, nginx" >> deb/spinup-${SPINUP_VERSION}${os_version}/DEBIAN/control + if [ "$os_version" = "" ]; then + echo "Depends: libgtk-3-0, libwebkit2gtk-4.0-dev, nginx, dnsmasq" >> deb/spinup-${SPINUP_VERSION}${os_version}/DEBIAN/control else - echo "Depends: dnsmasq, libgtk-3-0, libwebkit2gtk-4.1-dev, nginx" >> deb/spinup-${SPINUP_VERSION}${os_version}/DEBIAN/control + echo "Depends: libgtk-3-0, libwebkit2gtk-4.1-dev, nginx, dnsmasq" >> deb/spinup-${SPINUP_VERSION}${os_version}/DEBIAN/control fi # Set the permissions for the .deb package files diff --git a/scripts/release/package-macos-zip.sh b/scripts/release/package-macos-zip.sh index 41b4781..3690b1a 100755 --- a/scripts/release/package-macos-zip.sh +++ b/scripts/release/package-macos-zip.sh @@ -2,7 +2,8 @@ SPINUP_VERSION=$(cat ./common/.version | sed 's/^v//') -MAC_OS_DIR="./build/macos" +MAC_OS_DIR="./packaging/macos" +SPINUP_SHARE_DIR="/usr/local/share/spinup" # Define the path to the binary file BIN_FILE="./build/bin/Spinup.app/Contents/MacOS/spinup" @@ -10,16 +11,17 @@ BIN_FILE="./build/bin/Spinup.app/Contents/MacOS/spinup" # Create the mac os directory mkdir -p $MAC_OS_DIR +# Create the MacOS directory structure +mkdir -p "$MAC_OS_DIR/etc" +mkdir -p "$MAC_OS_DIR$SPINUP_SHARE_DIR" + # Copy the contents of the build/unix directory to the MacOS directory -cp -r "./build/unix/." $MAC_OS_DIR +cp -r "./packaging/unix/etc/." $MAC_OS_DIR/etc +cp -r "./packaging/unix/usr/share/spinup/." $MAC_OS_DIR$SPINUP_SHARE_DIR # Copy the binary file to the MacOS directory -mkdir -p "$MAC_OS_DIR/usr/share/spinup/bin" -cp $BIN_FILE "$MAC_OS_DIR/usr/share/spinup/bin" - -# Copy postinstall script to the MacOS directory -cp "./build/DEBIAN/postinst" $MAC_OS_DIR -mv "$MAC_OS_DIR/postinst" "$MAC_OS_DIR/postinstall.sh" +mkdir -p "$MAC_OS_DIR$SPINUP_SHARE_DIR/bin" +cp $BIN_FILE "$MAC_OS_DIR$SPINUP_SHARE_DIR/bin" # Create a zip file containing the contents of the MacOS directory (cd $MAC_OS_DIR && zip -r "../../spinup-${SPINUP_VERSION}-macos.zip" .) diff --git a/scripts/release/package-rpm.sh b/scripts/release/package-rpm.sh index 91fc0a5..73d762b 100755 --- a/scripts/release/package-rpm.sh +++ b/scripts/release/package-rpm.sh @@ -1,10 +1,10 @@ #!/usr/bin/env bash SPINUP_VERSION=$(cat ./common/.version | sed 's/^v//') -SOURCES_DIR=./build/rpmbuild/SOURCES +SOURCES_DIR=./packaging/rpmbuild/SOURCES # Add the version number to the spec file -sed -i "s/{{version}}/${SPINUP_VERSION}/g" build/rpmbuild/SPECS/spinup.spec +sed -i "s/{{version}}/${SPINUP_VERSION}/g" packaging/rpmbuild/SPECS/spinup.spec # Create the directory structure for the .rpm package mkdir -p $SOURCES_DIR/spinup-${SPINUP_VERSION} @@ -12,10 +12,10 @@ cp build/bin/spinup-${SPINUP_VERSION} $SOURCES_DIR/spinup-${SPINUP_VERSION}/ mv $SOURCES_DIR/spinup-${SPINUP_VERSION}/spinup-${SPINUP_VERSION} $SOURCES_DIR/spinup-${SPINUP_VERSION}/spinup # Add the contents of the build/unix directory to the rpm sources -cp -r build/unix/. $SOURCES_DIR/spinup-${SPINUP_VERSION}/ +cp -r packaging/unix/. $SOURCES_DIR/spinup-${SPINUP_VERSION}/ # Add the postinstall script to the rpm sources -cp build/DEBIAN/postinst $SOURCES_DIR/spinup-${SPINUP_VERSION}/ +cp packaging/DEBIAN/postinst $SOURCES_DIR/spinup-${SPINUP_VERSION}/ # Set the permissions for the .rpm package files sudo chown -R root:root $SOURCES_DIR/spinup-${SPINUP_VERSION} @@ -27,7 +27,7 @@ cd ../../.. # Remove the existing rpmbuild directory and copy the new one rm -rf ~/rpmbuild -cp -r build/rpmbuild ~/ +cp -r packaging/rpmbuild ~/ # Build the .rpm package rpmbuild -bb ~/rpmbuild/SPECS/spinup.spec