diff --git a/.goreleaser.yml b/.goreleaser.yml index 4893946..ee6ac0e 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -31,6 +31,11 @@ builds: goarch: amd64 - goos: windows goarch: arm64 + hooks: + post: + - cmd: ./scripts/gen-winget-manifest.sh "{{ .Path }}" "{{ .Version }}" + env: + - TARGET={{ .Os }}_{{ .Arch }} archives: - formats: [binary] @@ -53,3 +58,5 @@ changelog: release: draft: false prerelease: auto + extra_files: + - glob: ./dist/winget-manifest.yaml diff --git a/README.md b/README.md index c847287..5aecc92 100644 --- a/README.md +++ b/README.md @@ -13,13 +13,44 @@ ## インストール -Go 1.26 以降: +### Linux / macOS + +[gh](https://cli.github.com/) コマンドを使って最新リリースからバイナリを取得: + +```sh +mkdir -p ~/.local/bin + +# Linux (amd64) +gh release download --repo pepabo/xpoint-cli --pattern '*_linux_amd64' -O xp +chmod +x xp && mv xp ~/.local/bin/ + +# macOS (arm64) +gh release download --repo pepabo/xpoint-cli --pattern '*_darwin_arm64' -O xp +chmod +x xp && xattr -d com.apple.quarantine xp && mv xp ~/.local/bin/ +``` + +[mise](https://mise.jdx.dev/) を使う場合: ```sh -go install github.com/pepabo/xpoint-cli@latest +mise use -g github:pepabo/xpoint-cli@latest ``` -または [GitHub Releases](https://github.com/pepabo/xpoint-cli/releases) からバイナリを取得。 +### Windows + +PowerShell で最新リリースの `winget-manifest.yaml` をダウンロードし、`winget install --manifest` でインストール: + +```powershell +Invoke-WebRequest -Uri https://github.com/pepabo/xpoint-cli/releases/latest/download/winget-manifest.yaml -OutFile winget-manifest.yaml +winget install --manifest winget-manifest.yaml +``` + +> [!NOTE] +> `--manifest` を使うには `winget settings` でローカルマニフェストを有効化する必要があります。 +> 管理者権限の PowerShell で `winget settings --enable LocalManifestFiles` を実行してください。 + +### バイナリを直接ダウンロード + +[GitHub Releases](https://github.com/pepabo/xpoint-cli/releases) から対応するバイナリを取得してください。 ## 認証 diff --git a/scripts/gen-winget-manifest.sh b/scripts/gen-winget-manifest.sh new file mode 100755 index 0000000..df7f5e3 --- /dev/null +++ b/scripts/gen-winget-manifest.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [[ "${TARGET:-}" != "windows_amd64" ]]; then + exit 0 +fi + +binary_path="${1:?binary path required}" +version="${2:?version required}" +output="${3:-dist/winget-manifest.yaml}" + +checksum=$(sha256sum "$binary_path" | awk '{print $1}') + +mkdir -p "$(dirname "$output")" + +cat > "$output" <