Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Linux
on:
push:
branches: [ main ]
tags:
- 'v*' # Triggers on any tag starting with 'v' (e.g., v1.0.0)
- '*' # Triggers on any tag name
pull_request:
branches: [ main ]
workflow_dispatch:
Expand Down Expand Up @@ -38,7 +41,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version-file: src/go.mod
go-version-file: go.mod

- name: Create new environment variables
working-directory: ${{env.GITHUB_WORKSPACE}}
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/build_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: macOS
on:
push:
branches: [ main ]
tags:
- 'v*' # Triggers on any tag starting with 'v' (e.g., v1.0.0)
- '*' # Triggers on any tag name
pull_request:
branches: [ main ]
workflow_dispatch:
Expand Down Expand Up @@ -38,7 +41,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version-file: src/go.mod
go-version-file: go.mod

- name: Create new environment variables
working-directory: ${{env.GITHUB_WORKSPACE}}
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Windows
on:
push:
branches: [ main ]
tags:
- 'v*' # Triggers on any tag starting with 'v' (e.g., v1.0.0)
- '*' # Triggers on any tag name
pull_request:
branches: [ main ]
workflow_dispatch:
Expand Down Expand Up @@ -36,7 +39,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version-file: src/go.mod
go-version-file: go.mod

- name: Create new environment variables
working-directory: ${{env.GITHUB_WORKSPACE}}
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ go.work.sum
# .idea/
# .vscode/

# Disposable copy of src/testdata used by the .vscode/launch.json debug configurations.
# Disposable copy of testdata used by the .vscode/launch.json debug configurations.
.debug-sandbox/

# Test report & badge files
Expand Down
32 changes: 16 additions & 16 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/src/cmd/bedrock_helper",
"program": "${workspaceFolder}/cmd/bedrock_helper",
"cwd": "${workspaceFolder}",
"args": [
]
Expand All @@ -26,7 +26,7 @@
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/src/cmd/bedrock_helper",
"program": "${workspaceFolder}/cmd/bedrock_helper",
"cwd": "${workspaceFolder}",
"args": [
"--version"
Expand All @@ -37,7 +37,7 @@
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/src/cmd/bedrock_helper",
"program": "${workspaceFolder}/cmd/bedrock_helper",
"cwd": "${workspaceFolder}",
"args": [
"--help"
Expand All @@ -48,7 +48,7 @@
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/src/cmd/bedrock_helper",
"program": "${workspaceFolder}/cmd/bedrock_helper",
"cwd": "${workspaceFolder}",
"args": [
"-help"
Expand All @@ -59,7 +59,7 @@
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/src/cmd/bedrock_helper",
"program": "${workspaceFolder}/cmd/bedrock_helper",
"cwd": "${workspaceFolder}",
"args": [
"help"
Expand All @@ -70,7 +70,7 @@
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/src/cmd/bedrock_helper",
"program": "${workspaceFolder}/cmd/bedrock_helper",
"cwd": "${workspaceFolder}",
"args": [
"-h"
Expand All @@ -81,7 +81,7 @@
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/src/cmd/bedrock_helper",
"program": "${workspaceFolder}/cmd/bedrock_helper",
"cwd": "${workspaceFolder}",
"preLaunchTask": "debug: reset sandbox",
"args": [
Expand All @@ -93,7 +93,7 @@
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/src/cmd/bedrock_helper",
"program": "${workspaceFolder}/cmd/bedrock_helper",
"cwd": "${workspaceFolder}",
"preLaunchTask": "debug: reset sandbox",
"args": [
Expand All @@ -105,7 +105,7 @@
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/src/cmd/bedrock_helper",
"program": "${workspaceFolder}/cmd/bedrock_helper",
"cwd": "${workspaceFolder}",
"preLaunchTask": "debug: reset sandbox",
"args": [
Expand All @@ -120,7 +120,7 @@
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/src/cmd/bedrock_helper",
"program": "${workspaceFolder}/cmd/bedrock_helper",
"cwd": "${workspaceFolder}",
"preLaunchTask": "debug: reset sandbox",
"args": [
Expand All @@ -135,7 +135,7 @@
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/src/cmd/bedrock_helper",
"program": "${workspaceFolder}/cmd/bedrock_helper",
"cwd": "${workspaceFolder}",
"preLaunchTask": "debug: reset sandbox",
"args": [
Expand All @@ -150,7 +150,7 @@
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/src/cmd/bedrock_helper",
"program": "${workspaceFolder}/cmd/bedrock_helper",
"cwd": "${workspaceFolder}",
"preLaunchTask": "debug: reset sandbox",
"args": [
Expand All @@ -163,7 +163,7 @@
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/src/cmd/bedrock_helper",
"program": "${workspaceFolder}/cmd/bedrock_helper",
"cwd": "${workspaceFolder}",
"preLaunchTask": "debug: reset sandbox",
"args": [
Expand All @@ -177,7 +177,7 @@
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/src/cmd/bedrock_helper",
"program": "${workspaceFolder}/cmd/bedrock_helper",
"cwd": "${workspaceFolder}",
"preLaunchTask": "debug: reset sandbox",
"args": [
Expand All @@ -192,7 +192,7 @@
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/src/cmd/bedrock_helper",
"program": "${workspaceFolder}/cmd/bedrock_helper",
"cwd": "${workspaceFolder}",
"preLaunchTask": "debug: reset sandbox",
"args": [
Expand All @@ -206,7 +206,7 @@
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/src/cmd/bedrock_helper",
"program": "${workspaceFolder}/cmd/bedrock_helper",
"cwd": "${workspaceFolder}",
"preLaunchTask": "debug: reset sandbox",
"args": [
Expand Down
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
},
{
"label": "debug: reset sandbox",
"detail": "Refreshes .debug-sandbox/ from src/testdata/ so the launch.json debug configurations always start from a clean, known state.",
"detail": "Refreshes .debug-sandbox/ from testdata/ so the launch.json debug configurations always start from a clean, known state.",
"type": "shell",
"options": {
"cwd": "${workspaceFolder}"
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ clean:

# tidy: Format code and clean up dependencies
tidy:
cd src && go fmt ./...
cd src && go mod tidy
go fmt ./...
go mod tidy

# install: Install the binary to the user's bin directory
install: build
Expand Down
65 changes: 56 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# BedrockHelper

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![Go version](https://img.shields.io/github/go-mod/go-version/end2endzone/BedrockHelper?filename=src%2Fgo.mod)](src/go.mod)
[![Go version](https://img.shields.io/github/go-mod/go-version/end2endzone/BedrockHelper?filename=go.mod)](go.mod)
[![Github Releases](https://img.shields.io/github/release/end2endzone/BedrockHelper.svg)](https://github.com/end2endzone/BedrockHelper/releases)

`bedrock_helper` is a command line tool for installing, uninstalling and inspecting Minecraft Bedrock Edition add-on packs (`.mcaddon` / `.mcpack`) on a Minecraft Bedrock Dedicated Server (BDS).
Expand Down Expand Up @@ -63,11 +63,14 @@ This is tedious, error-prone, and hard to automate. `bedrock_helper` does all of

## Installation

### Download pre-build binaries from github.com

You can install *BedrockHelper* by downloading the right binary from its [latest release page](https://github.com/end2endzone/BedrockHelper/releases/latest/).
There are binaries for *Linux*, *macOS* and *Windows*. Binaries for all major operating systems are also available for ***AMD64*** and ***ARM64*** cpu architectures.

You can also install with a command such as the following:


#### Linux / macOS:

```bash
Expand Down Expand Up @@ -96,20 +99,61 @@ Invoke-WebRequest -Uri $url -OutFile "bedrock_helper.exe"
```


### Build from source
### Build via *go install* command

BedrockHelper can be installed cia `go install` command:

```
go install github.com/end2endzone/BedrockHelper/cmd/bedrock_helper@latest
```

This will install bedrock_helper executable the bin directory of your GOPATH directory. The get the path of your Go bin directory, you can run `go env GOPATH`. The `bin` directory will be located under the given directory.

For example:
* `$HOME/go/bin/bedrock_helper` (linux)
* `%USERPROFILE%\go\bin\bedrock_helper.exe` (Windows)

If `GOBIN` environment variable is set: the binary goes into `$GOBIN` (or `$env:GOBIN`, `%GOBIN%`).


#### Update your *PATH*

After installation, if typing `bedrock_helper` (or `bedrock_helper.exe`) returns `command not found`, your system's `PATH` environment variable does not include the Go binary directory yet.

On Linux / macOS:

Add `$(go env GOPATH)/bin` to your `~/.bashrc`, `~/.zshrc`, or `~/.bash_profile`:

```bash
export PATH=$PATH:$(go env GOPATH)/bin
```

Then reload your shell: `source ~/.bashrc` (or open a new terminal window).

On Windows (PowerShell):

Run this command to temporarily add Go binary directory to your current session:

```powershell
$env:Path += ";$env:USERPROFILE\go\bin"
```

or add `%USERPROFILE%\go\bin` to your `Path` environment variable.


### Build manually from source

Prerequisites:

- [Go](https://go.dev/dl/). Minimum version required is [![Go version](https://img.shields.io/github/go-mod/go-version/end2endzone/BedrockHelper?filename=src%2Fgo.mod)](src/go.mod).
- [Go](https://go.dev/dl/). Minimum version required is [![Go version](https://img.shields.io/github/go-mod/go-version/end2endzone/BedrockHelper?filename=go.mod)](go.mod).
- *Git*


Commands:
You can also manually clone the repo and build the application:

```console
git clone https://github.com/end2endzone/BedrockHelper.git
cd BedrockHelper/src
go build -o bedrock_helper ./cmd/bedrock_helper
cd BedrockHelper
go build -o bin/bedrock_helper ./cmd/bedrock_helper
```

This produces a single `bedrock_helper` (or `bedrock_helper.exe` on Windows) executable with no runtime dependencies. Copy it anywhere on your `PATH`.
Expand Down Expand Up @@ -143,6 +187,8 @@ Windows (PowerShell or Command Prompt):

When building on a CI/CD server, the output file name is changed to `bedrock_helper-{os}-{cpuarch}`. For example `bedrock_helper-darwin-amd64` or `bedrock_helper-windows-amd64.exe`, etc. `CI=true` can be set beforehand to simulate building on a CI/CD server.



## Usage

```
Expand Down Expand Up @@ -173,6 +219,7 @@ Only one command may be specified per invocation.
| `--version` | Show the product version. |
| `--help` | Show the usage message. |


### Example - installing an add-on

```console
Expand Down Expand Up @@ -274,7 +321,7 @@ Windows (PowerShell or Command Prompt):
.\ci\windows\test.bat
```

The tests use [testify](https://github.com/stretchr/testify)'s `assert`/`require` packages and a set of fixture add-ons and fake server directories under `src/testdata/`, so they don't touch a real Minecraft installation.
The tests use [testify](https://github.com/stretchr/testify)'s `assert`/`require` packages and a set of fixture add-ons and fake server directories under `testdata/`, so they don't touch a real Minecraft installation.


### Debugging in VS Code
Expand All @@ -289,7 +336,7 @@ The tests use [testify](https://github.com/stretchr/testify)'s `assert`/`require
* `--install-all`
* `--uninstall-all`

Configurations that install or uninstall packs run against a disposable copy of `src/testdata` under `.debug-sandbox/` (refreshed automatically before every run by the `debug: reset sandbox` task), so debugging never modifies the checked-in test fixtures.
Configurations that install or uninstall packs run against a disposable copy of `testdata` under `.debug-sandbox/` (refreshed automatically before every run by the `debug: reset sandbox` task), so debugging never modifies the checked-in test fixtures.


## Platform support
Expand Down
8 changes: 4 additions & 4 deletions ci/linux/build-debug-sandbox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ cd $PROJECTROOT

rm -rf .debug-sandbox
mkdir -p .debug-sandbox
cp -r src/testdata .debug-sandbox
cp src/testdata/addons/foobar.mcaddon .debug-sandbox/testdata/servers/server_with_multiple_packs/foobar.mcaddon
cp -r testdata .debug-sandbox
cp testdata/addons/foobar.mcaddon .debug-sandbox/testdata/servers/server_with_multiple_packs/foobar.mcaddon

# Testing installing multiple addon at once
cp -r src/testdata/servers/server_empty .debug-sandbox/testdata/servers/server_with_uninstalled_addons
cp -r src/testdata/addons .debug-sandbox/testdata/servers/server_with_uninstalled_addons/my-addons-collection
cp -r testdata/servers/server_empty .debug-sandbox/testdata/servers/server_with_uninstalled_addons
cp -r testdata/addons .debug-sandbox/testdata/servers/server_with_uninstalled_addons/my-addons-collection

echo "Sandbox ready!"
8 changes: 2 additions & 6 deletions ci/linux/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ set -e
# Get the projet's root directory
PROJECTROOT=$(cd "$(dirname "$0")/../.." && pwd)

cd $PROJECTROOT/src

VERSION=$(cat $PROJECTROOT/VERSION)
COMMIT=$(git rev-parse --short HEAD)
DATE=$(date +%F)
cd $PROJECTROOT

# GOOS
if [[ -n "${GOOS}" ]]; then
Expand Down Expand Up @@ -42,6 +38,6 @@ PKG="main"
echo "Building $(basename "$TARGET") version $VERSION..."

# Run build from the root, pointing to the main package directory
go build -ldflags "-X '${PKG}.Version=${VERSION}' -X '${PKG}.CommitHash=${COMMIT}' -X '${PKG}.BuildDate=${DATE}'" -o $TARGET ./cmd/bedrock_helper
go build -o $TARGET ./cmd/bedrock_helper

echo "Build complete!"
Loading