diff --git a/.github/actions/go-checks/action.yml b/.github/actions/go-checks/action.yml index 7f68824b6..135783a8a 100644 --- a/.github/actions/go-checks/action.yml +++ b/.github/actions/go-checks/action.yml @@ -7,6 +7,9 @@ runs: - name: Generate code run: go generate ./... shell: bash + - name: Verify generated output is clean + run: git diff --exit-code + shell: bash - name: Run Go tests run: go test -race ./... shell: bash diff --git a/.github/scripts/release-notes.sh b/.github/scripts/release-notes.sh index d5cfc789e..9c0dfa122 100755 --- a/.github/scripts/release-notes.sh +++ b/.github/scripts/release-notes.sh @@ -10,12 +10,6 @@ repository="${GITHUB_REPOSITORY:-}" commit_sha="${GITHUB_SHA:-}" ref_name="${GITHUB_REF_NAME:-}" datafiles_archive="${DATAFILES_ARCHIVE:-gomud-ALL-datafiles.zip}" -checksums_file="${CHECKSUMS_FILE:-SHA256SUMS.txt}" -downloads="$( - DATAFILES_ARCHIVE="$datafiles_archive" \ - CHECKSUMS_FILE="$checksums_file" \ - .github/scripts/release-assets.sh downloads-markdown -)" require_env() { local name="$1" @@ -104,26 +98,62 @@ ${overview} ${summary} -## Downloads +## Install GoMud -${downloads} +### Requirements -## Install From Source +- Go 1.24 or newer +- Optional: Docker (for container-based runs) -Clone the repository, check out this release tag or commit, install the Go -toolchain from \`go.mod\`, and run \`make build\`. +### Quick Install (Recommended) -## Manual Binary Install +- The fastest way to get GoMud running. +- These scripts install Go and Git (if needed), clone the GoMud repo, and build the server binary automatically. -Download the binary for your operating system and CPU architecture, download -\`${datafiles_archive}\`, unpack the datafiles next to the binary, and make the -binary executable on Unix-like systems. +**Linux / macOS:** -## Verify Provenance +Open a Terminal and run: -Download \`${checksums_file}\` and run \`sha256sum -c ${checksums_file}\` in the -directory containing the release assets. Verify build provenance with -\`gh attestation verify --repo ${repository}\`. +\`\`\`shell +curl -fsSL https://raw.githubusercontent.com/GoMudEngine/GoMud/master/scripts/install.sh | sh +\`\`\` + +**Windows:** + +Open a \`Powershell\` window and run: + +\`\`\`powershell +irm https://raw.githubusercontent.com/GoMudEngine/GoMud/master/scripts/install.ps1 | iex +\`\`\` + +- Both scripts install GoMud to \`~/GoMud\` by default. +- Set the \`GOMUD_DIR\` environment variable before running to choose a different location. + +### Alternative: Manual Binary Install + +- Go to the GoMud [Release Page](https://github.com/${repository}/releases/tag/${release_tag}) +- Scroll down to the **Assets** section and expand it +- Download the datafiles (needed by all operating systems): + - **\`${datafiles_archive}\`** + - Extract this zip file into the same folder as the GoMud binary +- Download the GoMud binary/executable specific for your operating system, based on the table below: + +**Most common:** + +| Filename | Operating System | CPU Architecture | Typical Devices | +|------------|------------------|------------------|-----------------| +| gomud-darwin_arm64 | macOS | ARM64 (Apple Silicon) | Apple M1, M2, M3, M4 Macs | +| gomud-linux_x64 | Linux | x86_64 (Intel/AMD 64-bit) | Most modern desktop/server Linux systems | +| gomud-windows_x64.exe | Windows | x86_64 (Intel/AMD 64-bit) | Most modern Windows PCs | + +**Other options:** + +| Filename | Operating System | CPU Architecture | Typical Devices | +|------------|------------------|------------------|-----------------| +| gomud-darwin_x64 | macOS | x86_64 (Intel 64-bit) | Older Intel-based Macs | +| gomud-windows_arm64.exe | Windows | ARM64 | Surface Pro X, Snapdragon X Elite laptops, Windows on ARM +| gomud-linux_arm64 | Linux | ARM64 (AArch64) | Linux systems using ARM-based CPUs | +| gomud-linux_armv7 | Linux | ARMv7 (32-bit) | Raspberry Pi 2/3 running 32-bit OS | ## Changes diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0da952dd8..7f8a45333 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,6 @@ name: CI # - Go format/vet # - conditional JS lint # - Go race tests -# - Release cross-compile check "on": push: @@ -36,6 +35,8 @@ jobs: outputs: js_lint: >- ${{ steps.filter.outputs.js_lint }} + runtime_build: >- + ${{ steps.filter.outputs.runtime_build }} steps: # Full history is needed so push and pull request events can diff against # the actual base commit instead of whatever shallow checkout provides. @@ -46,7 +47,7 @@ jobs: persist-credentials: false - id: filter - name: Detect JavaScript lint inputs + name: Detect relevant inputs env: BASE_REF: >- ${{ github.event.pull_request.base.sha || github.event.before }} @@ -69,10 +70,24 @@ jobs: echo "js_lint=false" >> "$GITHUB_OUTPUT" fi + go_re='(^|/)[^/]+\.go$' + go_re="${go_re}|^(go\.mod|go\.sum|Makefile)$" + go_re="${go_re}|^\.github/actions/(go-checks|setup-go)/" + go_re="${go_re}|^\.github/workflows/ci\.yml" + + if printf '%s\n' "${changed_files}" | grep -Eq "${go_re}"; then + echo "runtime_build=true" >> "$GITHUB_OUTPUT" + else + echo "runtime_build=false" >> "$GITHUB_OUTPUT" + fi + go-lint: name: Go Format And Vet runs-on: ubuntu-24.04 timeout-minutes: 20 + needs: detect-changes + if: >- + needs.detect-changes.outputs.runtime_build == 'true' steps: # actions/checkout v6.0.2 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd @@ -89,7 +104,6 @@ jobs: runs-on: ubuntu-24.04 timeout-minutes: 10 needs: detect-changes - # The web client JavaScript is linted only when related files change. if: >- needs.detect-changes.outputs.js_lint == 'true' steps: @@ -108,9 +122,12 @@ jobs: run: make js-lint test: - name: Go Tests And Release Cross-Compile + name: Go Tests runs-on: ubuntu-24.04 timeout-minutes: 30 + needs: detect-changes + if: >- + needs.detect-changes.outputs.runtime_build == 'true' steps: # actions/checkout v6.0.2 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd @@ -120,11 +137,3 @@ jobs: - uses: ./.github/actions/setup-go - uses: ./.github/actions/go-checks - - - name: Cross-compile release targets - if: >- - github.event_name == 'push' && - github.ref == 'refs/heads/master' - env: - RELEASE_DIST_DIR: ${{ runner.temp }}/release-cross-compile - run: .github/scripts/build-release-binaries.sh diff --git a/.github/workflows/docker-package.yml b/.github/workflows/docker-package.yml index ba47af57c..2cd41a6a8 100644 --- a/.github/workflows/docker-package.yml +++ b/.github/workflows/docker-package.yml @@ -15,14 +15,70 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: false +permissions: + contents: read + env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} jobs: + detect-changes: + name: Detect Docker Build Inputs + runs-on: ubuntu-24.04 + timeout-minutes: 5 + outputs: + docker_build: >- + ${{ steps.filter.outputs.docker_build }} + steps: + # Full history is needed so push and pull request events can diff against + # the actual base commit instead of whatever shallow checkout provides. + # actions/checkout v6.0.2 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd + with: + fetch-depth: 0 + persist-credentials: false + + - id: filter + name: Detect Docker build inputs + env: + BASE_REF: >- + ${{ github.event.pull_request.base.sha || github.event.before }} + HEAD_REF: ${{ github.sha }} + run: | + set -eu + + if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ]; then + echo "docker_build=true" >> "$GITHUB_OUTPUT" + exit 0 + fi + + if [ -z "${BASE_REF}" ] || \ + [ "${BASE_REF}" = "0000000000000000000000000000000000000000" ]; then + BASE_REF="$(git rev-parse HEAD^)" + fi + + changed_files="$(git diff --name-only "${BASE_REF}" "${HEAD_REF}")" + printf '%s\n' "${changed_files}" + + docker_re='(^|/)[^/]+\.go$' + docker_re="${docker_re}|^(\.dockerignore|go\.mod|go\.sum|Makefile|_datafiles/)" + docker_re="${docker_re}|^(modules/|cmd/|internal/|scripts/)" + docker_re="${docker_re}|^(provisioning/|compose\.yml)" + docker_re="${docker_re}|^\.github/workflows/docker-package\.yml" + + if printf '%s\n' "${changed_files}" | grep -Eq "${docker_re}"; then + echo "docker_build=true" >> "$GITHUB_OUTPUT" + else + echo "docker_build=false" >> "$GITHUB_OUTPUT" + fi + package: runs-on: ubuntu-24.04 timeout-minutes: 60 + needs: detect-changes + if: >- + needs.detect-changes.outputs.docker_build == 'true' permissions: contents: read packages: write @@ -45,6 +101,7 @@ jobs: uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd - name: Log in to the Container registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' # docker/login-action v4.1.0 uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 with: diff --git a/.github/workflows/stable-release.yml b/.github/workflows/stable-release.yml index bd05988f4..c712711b6 100644 --- a/.github/workflows/stable-release.yml +++ b/.github/workflows/stable-release.yml @@ -45,6 +45,11 @@ jobs: run: | set -euo pipefail + if [ "${GITHUB_REF}" != "refs/heads/master" ]; then + echo "Stable releases must be run from the master branch." >&2 + exit 1 + fi + semver_re='^v(0|[1-9][0-9]*)\.' semver_re="${semver_re}(0|[1-9][0-9]*)\." semver_re="${semver_re}(0|[1-9][0-9]*)$" diff --git a/scripts/install.sh b/scripts/install.sh index ffff8ea9f..e29ca6881 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -102,7 +102,8 @@ For Windows, use the PowerShell installer: case "$raw_arch" in x86_64) GO_ARCH="amd64" ;; aarch64 | arm64) GO_ARCH="arm64" ;; - armv6l) GO_ARCH="armv6l" ;; + # Go distributes 32-bit Linux ARM toolchains as linux-armv6l. + armv6l | armv7l | armv8l) GO_ARCH="armv6l" ;; i386 | i686) GO_ARCH="386" ;; *) fatal "Unsupported architecture: $raw_arch." ;; esac @@ -197,6 +198,7 @@ install_go() { maybe_sudo tar -C /usr/local -xzf "$archive_path" # Persist PATH update to ~/.profile if not already present. + # shellcheck disable=SC2016 profile_line='export PATH=$PATH:/usr/local/go/bin' if [ -f "$HOME/.profile" ] && grep -qF '/usr/local/go/bin' "$HOME/.profile"; then : # already present