# 發行 ## 自己打包 ```sh make dist # 版本號取自 git tag(沒有就用 commit 編號) make dist VERSION=1.2.0 # 指定版本號 ``` | 在哪打包 | 產生 | |---|---| | Mac | `dist/AnyBot-<版本>-macos-arm64.zip`:AnyBot.app(含圖示,ad hoc 簽章) | | Linux | `dist/AnyBot-<版本>-ubuntu-<架構>.tar.gz`:有視窗的版本,`./install.sh` 安裝 | | | `dist/AnyBot-<版本>-headless-<架構>.tar.gz`:沒有螢幕的 Linux(手腳或大腦),附 `hands.sh` | | | `dist/AnyBot-<版本>-server-<架構>.tar.gz`:帳號伺服器+大腦+HTTPS,用已編好的程式建 Docker 映像,`deploy/server/setup.sh` | Linux 版要在 Ubuntu 22.04(glibc 2.35)上編譯,才能在較新的 Ubuntu、Debian 12 等直接跑;用 `deploy/ci/Dockerfile.linux` 這個環境就是。 打包腳本:`deploy/mac/bundle.sh`、`deploy/ci/package-linux.sh`。 ## 推 tag 自動建置(Gitea Actions) `.gitea/workflows/release.yml`:推一個 `v` 開頭的 tag,兩個 runner 各自建置,把檔案掛到那個 tag 的 Release 上(沒有 Release 會自動建立;重建時會換掉同名的檔案)。 ```sh git tag v1.2.0 git push origin v1.2.0 ``` | 工作 | runner 標籤 | 做什麼 | |---|---|---| | linux | `anybot-linux` | 在 `anybot-builder:22.04` 容器裡編譯、跑測試、打三個 Linux 包、上傳 | | macos | `macos-arm64` | 在 Mac 上直接編譯、做 AnyBot.app、上傳 | 上傳用 `secrets.RELEASE_TOKEN`;沒設時用 Gitea 自動給的 token。如果自動的 token 沒有建立 Release 的權限,到 repo › 設定 › Actions › Secrets 加一個 `RELEASE_TOKEN`(有這個 repo 寫入權限的 access token)。 ### 設定 Linux runner 在一台有 Docker 的 Linux(x86_64)上: 1. 在 Gitea 打開 Actions(管理員:`app.ini` 的 `[actions] ENABLED = true`),到 repo › 設定 › Actions › Runners › 建立新的 runner,複製註冊權杖。 2. 安裝 runner([gitea/runner](https://gitea.com/gitea/runner/releases),下載後核對 `.sha256`): ```sh V=5.3.0 curl -fsSLO https://gitea.com/gitea/runner/releases/download/v$V/gitea-runner-$V-linux-amd64.xz curl -fsSLO https://gitea.com/gitea/runner/releases/download/v$V/gitea-runner-$V-linux-amd64.xz.sha256 sha256sum -c gitea-runner-$V-linux-amd64.xz.sha256 && xz -d gitea-runner-$V-linux-amd64.xz install -m 755 gitea-runner-$V-linux-amd64 ~/.local/bin/gitea-runner ``` 3. 建好建置環境(只要一次;更新 Rust 時再建一次): ```sh docker build -t anybot-builder:22.04 -f deploy/ci/Dockerfile.linux deploy/ci ``` 4. 設定和註冊: ```sh mkdir -p ~/.config/gitea-runner cp deploy/ci/runner-linux.yaml ~/.config/gitea-runner/config.yaml # 檔案路徑裡的使用者名稱照你的改 cd ~/.config/gitea-runner gitea-runner register --no-interactive --instance https://你的-gitea --token 註冊權杖 \ --name anybot-linux --labels "anybot-linux:docker://anybot-builder:22.04" -c config.yaml ``` 5. 一直跑(systemd 使用者服務): ```ini # ~/.config/systemd/user/gitea-runner.service [Unit] Description=Gitea runner (AnyBot releases) After=network-online.target docker.service [Service] WorkingDirectory=%h/.config/gitea-runner ExecStart=%h/.local/bin/gitea-runner daemon -c %h/.config/gitea-runner/config.yaml Restart=always RestartSec=5 [Install] WantedBy=default.target ``` ```sh systemctl --user daemon-reload && systemctl --user enable --now gitea-runner sudo loginctl enable-linger $USER # 登出後也繼續跑 ``` `runner-linux.yaml` 用兩個 Docker 磁碟區保留下載的套件(`anybot-cargo-registry`)和編譯結果(`anybot-ci-target`),之後每次發行只重編有改的部分。 ### 設定 Mac runner Apple 的 App 只能在 Mac 上編譯。在一台裝好 Rust 和 Xcode Command Line Tools 的 Mac 上: ```sh V=5.3.0 curl -fsSLO https://gitea.com/gitea/runner/releases/download/v$V/gitea-runner-$V-darwin-arm64.xz curl -fsSLO https://gitea.com/gitea/runner/releases/download/v$V/gitea-runner-$V-darwin-arm64.xz.sha256 shasum -a 256 -c gitea-runner-$V-darwin-arm64.xz.sha256 && xz -d gitea-runner-$V-darwin-arm64.xz install -m 755 gitea-runner-$V-darwin-arm64 ~/.local/bin/gitea-runner mkdir -p ~/.config/gitea-runner && cd ~/.config/gitea-runner gitea-runner register --no-interactive --instance https://你的-gitea --token 註冊權杖 \ --name anybot-mac --labels "macos-arm64:host" gitea-runner daemon # 或做成 launchd 代理,開機自動執行 ``` `host` 表示工作直接在這台 Mac 上跑(不用容器)。編譯結果保留在工作資料夾旁的 `anybot-target/`。 ### 注意 - runner 要連得到 Gitea 的網址(HTTPS),也要能從 GitHub 下載 `actions/checkout`(Gitea 預設的 action 來源)。 - Mac 版用 ad hoc 簽章,沒有公證;使用者第一次打開要按右鍵 › 打開。要正式簽章和公證需要 Apple 開發者帳號。