Skip to content

Commit 0459a4e

Browse files
committed
chore: Update build script to create tar.gz archive for the output file
1 parent 4a1aaf5 commit 0459a4e

File tree

5 files changed

+198
-34
lines changed

5 files changed

+198
-34
lines changed

.github/workflows/build.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*' # Matches tags like v1.0.0, v2.1.3, etc.
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Check out the repository
14+
uses: actions/checkout@v3
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@v4
18+
with:
19+
go-version: 1.16
20+
21+
- name: Run build script
22+
run: ./build.sh
23+
24+
- name: Upload build artifacts
25+
uses: actions/upload-artifact@v3
26+
with:
27+
name: build-artifacts
28+
path: build/*.tar.gz
29+
30+
release:
31+
needs: build
32+
runs-on: ubuntu-latest
33+
34+
steps:
35+
- name: Download build artifacts
36+
uses: actions/download-artifact@v3
37+
with:
38+
name: build-artifacts
39+
path: build
40+
41+
- name: Create GitHub Release
42+
id: create_release
43+
uses: actions/create-release@v1
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
with:
47+
tag_name: ${{ github.ref }}
48+
release_name: Release ${{ github.ref }}
49+
draft: false
50+
prerelease: false
51+
52+
- name: Upload Release Assets for amd64
53+
uses: actions/upload-release-asset@v1
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
with:
57+
upload_url: ${{ steps.create_release.outputs.upload_url }}
58+
asset_path: build/fly-linux-amd64.tar.gz
59+
asset_name: fly-linux-amd64.tar.gz
60+
asset_content_type: application/gzip
61+
62+
- name: Upload Release Assets for arm64
63+
uses: actions/upload-release-asset@v1
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
with:
67+
upload_url: ${{ steps.create_release.outputs.upload_url }}
68+
asset_path: build/fly-linux-arm64.tar.gz
69+
asset_name: fly-linux-arm64.tar.gz
70+
asset_content_type: application/gzip

README.md

Lines changed: 68 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,96 @@
11
# server-cli
2-
CLI tool for servers managed by FlyWP
32

4-
## Commands
3+
Easy CLI tool for servers managed by FlyWP.
54

6-
### WP-CLI
5+
## Installation
76

8-
**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.
7+
### Prerequisites
98

10-
```bash
11-
fly wp
12-
```
9+
- [Docker](https://www.docker.com/get-started)
10+
- [Docker Compose](https://docs.docker.com/compose/install/)
1311

14-
**Any site**:
12+
### Quick Install
13+
14+
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`:
1515

1616
```bash
17-
fly site <website> wp
17+
curl -sL https://raw.githubusercontent.com/flywp/server-cli/main/install.sh | bash
1818
```
1919

20-
In-case you want to run a `wp` command in a specific webwebsite, you could run like this.
20+
### Manual Installation
2121

22-
### Site Operations
22+
If you prefer to manually download and install the binary, follow these steps:
23+
24+
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.
2325

24-
Website names should *preferably* be autocompleted.
26+
#### Linux
27+
28+
1. Download the tarball:
29+
```bash
30+
wget https://github.com/flywp/server-cli/releases/download/latest/fly-linux-amd64.tar.gz
31+
```
32+
33+
2. Extract the tarball:
34+
```bash
35+
tar -xzf fly-linux-amd64.tar.gz
36+
```
37+
38+
3. Move the binary to a directory in your PATH:
39+
```bash
40+
sudo mv fly-linux-amd64 /usr/local/bin/fly
41+
```
42+
43+
4. Verify the installation:
44+
```bash
45+
fly --version
46+
```
47+
48+
## Usage
49+
50+
### Base Docker Compose
51+
52+
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.
2553

2654
```bash
27-
fly site <website> up
28-
fly site <website> down
29-
fly site <website> restart
30-
fly site <website> logs <container>
31-
fly site <website> restart <container>
32-
fly site <website> exec <container>
55+
fly base start # starts the base services (mysql, redis, nginx-proxy)
56+
fly base stop # stops the base services
57+
fly base restart # restarts the base services
3358
```
3459

35-
From anywhere inside a site folder:
60+
### Site Operations
61+
62+
From anywhere inside a site folder, you can run the following commands that will be executed on a per-site basis.
3663

3764
```bash
38-
fly up
39-
fly down
40-
fly restart
41-
fly logs <container>
42-
fly restart <container>
43-
fly exec <container>
65+
fly start # starts the website (via Docker Compose)
66+
fly stop # stops the website (via Docker Compose)
67+
fly restart # restarts the website (via Docker Compose)
68+
fly wp # execute WP-CLI commands
69+
fly logs <container> # view logs from all containers or a single one
70+
fly restart <container> # restart a container
71+
fly exec <container> # execute commands inside a container. Default: "php"
4472
```
4573

46-
### Base Docker Compose
74+
### WP-CLI
75+
76+
**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.
4777

4878
```bash
49-
fly base stop
50-
fly base start
51-
fly base restart
79+
fly wp
5280
```
5381

5482
### Global Commands
5583

84+
A few helper commands to debug the server installation and start/stop all sites.
85+
5686
```bash
57-
fly status
58-
fly sites stop
59-
fly sites start
60-
fly sites restart
87+
fly status # shows the status of the system
88+
fly sites start # starts all sites
89+
fly sites stop # stops all sites
90+
fly sites restart # stops and starts all sites
91+
```
92+
93+
## License
94+
95+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
6196
```

build.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ build() {
1919
echo "Building for ${GOOS}/${GOARCH}..."
2020
GOOS=${GOOS} GOARCH=${GOARCH} go build -ldflags "${LDFLAGS}" -o "build/${OUTPUT}" .
2121
echo "Done building ${OUTPUT}"
22+
23+
create_archive "${OUTPUT}"
24+
}
25+
26+
# Create tar.gz archive function
27+
create_archive() {
28+
local OUTPUT=$1
29+
30+
echo "Creating archive for ${OUTPUT}..."
31+
tar -czvf "build/${OUTPUT}.tar.gz" -C build "${OUTPUT}"
32+
echo "Done creating archive ${OUTPUT}.tar.gz"
2233
}
2334

2435
# Clean build directory

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ func init() {
3737

3838
// Cobra also supports local flags, which will only run
3939
// when this action is called directly.
40-
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
40+
// rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
4141
}

install.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Determine OS and architecture
6+
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
7+
ARCH=$(uname -m)
8+
9+
if [ "$ARCH" == "x86_64" ]; then
10+
ARCH="amd64"
11+
elif [[ "$ARCH" == "armv7l" || "$ARCH" == "armv6l" ]]; then
12+
ARCH="arm"
13+
elif [[ "$ARCH" == "aarch64" || "$ARCH" == "arm64" ]]; then
14+
ARCH="arm64"
15+
else
16+
echo "Unsupported architecture: $ARCH"
17+
exit 1
18+
fi
19+
20+
# Get latest release from GitHub API
21+
LATEST_RELEASE=$(curl -s https://api.github.com/repos/flywp/server-cli/releases/latest)
22+
TAG_NAME=$(echo "$LATEST_RELEASE" | grep -oP '"tag_name": "\K(.*)(?=")')
23+
DOWNLOAD_URL=$(echo "$LATEST_RELEASE" | grep -oP '"browser_download_url": "\K(.*'${OS}'-'${ARCH}'.tar.gz)(?=")')
24+
25+
if [ -z "$DOWNLOAD_URL" ]; then
26+
echo "No suitable binary found for OS: $OS and architecture: $ARCH"
27+
exit 1
28+
fi
29+
30+
# Download the latest release
31+
TEMP_DIR=$(mktemp -d)
32+
DOWNLOAD_FILE="$TEMP_DIR/fly-$OS-$ARCH.tar.gz"
33+
34+
echo "Downloading $DOWNLOAD_URL..."
35+
curl -L -o "$DOWNLOAD_FILE" "$DOWNLOAD_URL"
36+
37+
# Extract and install
38+
echo "Extracting $DOWNLOAD_FILE..."
39+
tar -xzf "$DOWNLOAD_FILE" -C "$TEMP_DIR"
40+
41+
echo "Installing to /usr/local/bin/fly..."
42+
sudo mv "$TEMP_DIR/fly-$OS-$ARCH" /usr/local/bin/fly
43+
sudo chmod +x /usr/local/bin/fly
44+
45+
# Clean up
46+
rm -rf "$TEMP_DIR"
47+
48+
echo "Installation completed! Verify with 'fly version'."

0 commit comments

Comments
 (0)