-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Update build script to create tar.gz archive for the output file
- Loading branch information
Showing
5 changed files
with
198 additions
and
34 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: Build and Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' # Matches tags like v1.0.0, v2.1.3, etc. | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out the repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: 1.16 | ||
|
||
- name: Run build script | ||
run: ./build.sh | ||
|
||
- name: Upload build artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: build-artifacts | ||
path: build/*.tar.gz | ||
|
||
release: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Download build artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: build-artifacts | ||
path: build | ||
|
||
- name: Create GitHub Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Upload Release Assets for amd64 | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: build/fly-linux-amd64.tar.gz | ||
asset_name: fly-linux-amd64.tar.gz | ||
asset_content_type: application/gzip | ||
|
||
- name: Upload Release Assets for arm64 | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: build/fly-linux-arm64.tar.gz | ||
asset_name: fly-linux-arm64.tar.gz | ||
asset_content_type: application/gzip |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,96 @@ | ||
# server-cli | ||
CLI tool for servers managed by FlyWP | ||
|
||
## Commands | ||
Easy CLI tool for servers managed by FlyWP. | ||
|
||
### WP-CLI | ||
## Installation | ||
|
||
**wp-cli**: To access the `wp-cli`, you can use the following command from anywhere in the website folder, and the CLI will find the appropriate WordPress folder to execute the `wp` command. | ||
### Prerequisites | ||
|
||
```bash | ||
fly wp | ||
``` | ||
- [Docker](https://www.docker.com/get-started) | ||
- [Docker Compose](https://docs.docker.com/compose/install/) | ||
|
||
**Any site**: | ||
### Quick Install | ||
|
||
You can easily install the `fly` CLI tool using the following command. This will download and run the `install.sh` script, which will automatically detect your operating system and architecture, download the latest release, and install it to `/usr/local/bin`: | ||
|
||
```bash | ||
fly site <website> wp | ||
curl -sL https://raw.githubusercontent.com/flywp/server-cli/main/install.sh | bash | ||
``` | ||
|
||
In-case you want to run a `wp` command in a specific webwebsite, you could run like this. | ||
### Manual Installation | ||
|
||
### Site Operations | ||
If you prefer to manually download and install the binary, follow these steps: | ||
|
||
1. Download the precompiled binaries from the [Releases](https://github.com/flywp/server-cli/releases) page. Choose the version suitable for your operating system and architecture. | ||
|
||
Website names should *preferably* be autocompleted. | ||
#### Linux | ||
|
||
1. Download the tarball: | ||
```bash | ||
wget https://github.com/flywp/server-cli/releases/download/latest/fly-linux-amd64.tar.gz | ||
``` | ||
|
||
2. Extract the tarball: | ||
```bash | ||
tar -xzf fly-linux-amd64.tar.gz | ||
``` | ||
|
||
3. Move the binary to a directory in your PATH: | ||
```bash | ||
sudo mv fly-linux-amd64 /usr/local/bin/fly | ||
``` | ||
|
||
4. Verify the installation: | ||
```bash | ||
fly --version | ||
``` | ||
|
||
## Usage | ||
|
||
### Base Docker Compose | ||
|
||
FlyWP has a base Docker Compose configuration for running MySQL, Redis, Ofelia, and Nginx Proxy that are shared for all sites hosted on the server. The base Docker Compose must be started before a site can be created. | ||
|
||
```bash | ||
fly site <website> up | ||
fly site <website> down | ||
fly site <website> restart | ||
fly site <website> logs <container> | ||
fly site <website> restart <container> | ||
fly site <website> exec <container> | ||
fly base start # starts the base services (mysql, redis, nginx-proxy) | ||
fly base stop # stops the base services | ||
fly base restart # restarts the base services | ||
``` | ||
|
||
From anywhere inside a site folder: | ||
### Site Operations | ||
|
||
From anywhere inside a site folder, you can run the following commands that will be executed on a per-site basis. | ||
|
||
```bash | ||
fly up | ||
fly down | ||
fly restart | ||
fly logs <container> | ||
fly restart <container> | ||
fly exec <container> | ||
fly start # starts the website (via Docker Compose) | ||
fly stop # stops the website (via Docker Compose) | ||
fly restart # restarts the website (via Docker Compose) | ||
fly wp # execute WP-CLI commands | ||
fly logs <container> # view logs from all containers or a single one | ||
fly restart <container> # restart a container | ||
fly exec <container> # execute commands inside a container. Default: "php" | ||
``` | ||
|
||
### Base Docker Compose | ||
### WP-CLI | ||
|
||
**wp-cli**: To access `wp-cli`, use the following command from anywhere in the website folder. The CLI will find the appropriate WordPress folder to execute the `wp` command. | ||
|
||
```bash | ||
fly base stop | ||
fly base start | ||
fly base restart | ||
fly wp | ||
``` | ||
|
||
### Global Commands | ||
|
||
A few helper commands to debug the server installation and start/stop all sites. | ||
|
||
```bash | ||
fly status | ||
fly sites stop | ||
fly sites start | ||
fly sites restart | ||
fly status # shows the status of the system | ||
fly sites start # starts all sites | ||
fly sites stop # stops all sites | ||
fly sites restart # stops and starts all sites | ||
``` | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. | ||
``` |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Determine OS and architecture | ||
OS=$(uname -s | tr '[:upper:]' '[:lower:]') | ||
ARCH=$(uname -m) | ||
|
||
if [ "$ARCH" == "x86_64" ]; then | ||
ARCH="amd64" | ||
elif [[ "$ARCH" == "armv7l" || "$ARCH" == "armv6l" ]]; then | ||
ARCH="arm" | ||
elif [[ "$ARCH" == "aarch64" || "$ARCH" == "arm64" ]]; then | ||
ARCH="arm64" | ||
else | ||
echo "Unsupported architecture: $ARCH" | ||
exit 1 | ||
fi | ||
|
||
# Get latest release from GitHub API | ||
LATEST_RELEASE=$(curl -s https://api.github.com/repos/flywp/server-cli/releases/latest) | ||
TAG_NAME=$(echo "$LATEST_RELEASE" | grep -oP '"tag_name": "\K(.*)(?=")') | ||
DOWNLOAD_URL=$(echo "$LATEST_RELEASE" | grep -oP '"browser_download_url": "\K(.*'${OS}'-'${ARCH}'.tar.gz)(?=")') | ||
|
||
if [ -z "$DOWNLOAD_URL" ]; then | ||
echo "No suitable binary found for OS: $OS and architecture: $ARCH" | ||
exit 1 | ||
fi | ||
|
||
# Download the latest release | ||
TEMP_DIR=$(mktemp -d) | ||
DOWNLOAD_FILE="$TEMP_DIR/fly-$OS-$ARCH.tar.gz" | ||
|
||
echo "Downloading $DOWNLOAD_URL..." | ||
curl -L -o "$DOWNLOAD_FILE" "$DOWNLOAD_URL" | ||
|
||
# Extract and install | ||
echo "Extracting $DOWNLOAD_FILE..." | ||
tar -xzf "$DOWNLOAD_FILE" -C "$TEMP_DIR" | ||
|
||
echo "Installing to /usr/local/bin/fly..." | ||
sudo mv "$TEMP_DIR/fly-$OS-$ARCH" /usr/local/bin/fly | ||
sudo chmod +x /usr/local/bin/fly | ||
|
||
# Clean up | ||
rm -rf "$TEMP_DIR" | ||
|
||
echo "Installation completed! Verify with 'fly version'." |