Skip to content

Commit f49e75c

Browse files
committed
ci: publish branch container images to ghcr
1 parent 2c532fd commit f49e75c

5 files changed

Lines changed: 177 additions & 5 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Branch Container (GHCR)
2+
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
tags-ignore:
8+
- "v*"
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
packages: write
14+
15+
jobs:
16+
build-and-push:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Log in to GHCR
26+
uses: docker/login-action@v3
27+
with:
28+
registry: ghcr.io
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Generate image metadata
33+
id: meta
34+
uses: docker/metadata-action@v5
35+
with:
36+
images: ghcr.io/${{ github.repository_owner }}/cdidx
37+
tags: |
38+
type=ref,event=branch
39+
type=sha,prefix=sha-
40+
41+
- name: Build and push
42+
uses: docker/build-push-action@v6
43+
with:
44+
context: .
45+
file: ./Dockerfile
46+
push: true
47+
tags: ${{ steps.meta.outputs.tags }}
48+
labels: ${{ steps.meta.outputs.labels }}

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
99

1010
### [Unreleased]
1111

12+
#### Changed
13+
- **README Option A PATH troubleshooting for container/cloud shells** — Added explicit `~/.local/bin` PATH recovery steps (temporary + persistent bash example) to the one-liner installer sections in both English and Japanese so `cdidx: command not found` is easier to fix in minimal environments. Affected: `README.md`.
14+
- **Installer supports mirror endpoints for restricted AI containers**`install.sh` now accepts `CDIDX_GITHUB_API_URL` and `CDIDX_RELEASE_BASE_URL` so users can route version lookup and release downloads through internal mirrors when direct GitHub access is blocked. Error messages now include concrete fallback commands (pin version, set mirror URLs). README Option A (EN/JP) now documents this flow and clarifies that PATH fixes apply after a successful install. Affected: `install.sh`, `README.md`.
15+
- **Branch container publishing to GHCR** — Added a branch-triggered GitHub Actions workflow that builds and pushes `cdidx` container images to GHCR (`ghcr.io/<owner>/cdidx:<branch>` and `:sha-<commit>`). Added a `Dockerfile` that builds `cdidx` from source and sets `cdidx --version` as the default command. README now documents opening a container directly from a branch image for AI workflows. Affected: `.github/workflows/container-branch.yml`, `Dockerfile`, `README.md`.
16+
1217
### [1.8.0] - 2026-04-12
1318

1419
#### Added
@@ -559,6 +564,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
559564

560565
### [Unreleased]
561566

567+
#### 変更
568+
- **README 方法Aに PATH トラブルシュートを追記(コンテナ/クラウド向け)** — ワンライナーインストーラー節(英語・日本語)に、`~/.local/bin``PATH` にない環境での復旧手順(一時設定 + bash 永続化例)を追加。`cdidx: command not found` の初回つまずきを減らす。対象: `README.md`
569+
- **制限付きAIコンテナ向けにインストーラーのミラー対応を追加**`install.sh``CDIDX_GITHUB_API_URL``CDIDX_RELEASE_BASE_URL` を受け付けるようになり、GitHub 直アクセスがブロックされた環境でも内部ミラー経由でバージョン解決とリリース取得を行えるようになった。エラーメッセージに固定バージョン指定とミラー設定の具体例を追加。README 方法A(英日)にも反映し、PATH 対処は「インストール成功後」の手順であることを明確化。対象: `install.sh``README.md`
570+
- **ブランチ起点のGHCRコンテナ公開を追加** — ブランチ push をトリガーに `cdidx` コンテナを GHCR(`ghcr.io/<owner>/cdidx:<branch>``:sha-<commit>`)へ公開する GitHub Actions ワークフローを追加。ソースから `cdidx` をビルドし、デフォルト実行を `cdidx --version` にした `Dockerfile` を追加。README に、AIワークフロー向けにブランチイメージを直接指定してコンテナを開く手順を追記。対象: `.github/workflows/container-branch.yml``Dockerfile``README.md`
571+
562572
### [1.8.0] - 2026-04-12
563573

564574
#### 追加

Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
2+
WORKDIR /src
3+
4+
COPY . .
5+
RUN dotnet publish src/CodeIndex/CodeIndex.csproj \
6+
-c Release \
7+
-r linux-x64 \
8+
--self-contained true \
9+
-p:PublishSingleFile=true \
10+
-p:PublishTrimmed=true \
11+
-o /out
12+
13+
FROM ubuntu:24.04
14+
RUN apt-get update \
15+
&& apt-get install -y --no-install-recommends ca-certificates git \
16+
&& rm -rf /var/lib/apt/lists/*
17+
18+
COPY --from=build /out/cdidx /usr/local/bin/cdidx
19+
WORKDIR /workspace
20+
21+
ENTRYPOINT ["cdidx"]
22+
CMD ["--version"]

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,27 @@ curl -fsSL https://raw.githubusercontent.com/Widthdom/CodeIndex/v1.5.0/install.s
8787

8888
Supported platforms: `linux-x64`, `linux-arm64`, `osx-arm64` (glibc-based Linux only; Alpine/musl is not supported). Installs to `~/.local/bin` by default (override with `CDIDX_INSTALL_DIR`).
8989

90+
If install fails with HTTP 403 in a managed container/proxy environment, GitHub endpoints may be blocked. Use a pinned version and mirror endpoints:
91+
92+
```bash
93+
export CDIDX_GITHUB_API_URL="https://<your-mirror>/repos/Widthdom/CodeIndex"
94+
export CDIDX_RELEASE_BASE_URL="https://<your-mirror>/releases/download"
95+
curl -fsSL https://raw.githubusercontent.com/Widthdom/CodeIndex/main/install.sh | bash -s -- v1.8.0
96+
```
97+
98+
If install succeeds but `cdidx` is still not found, your shell likely does not include `~/.local/bin` in `PATH` yet:
99+
100+
```bash
101+
export PATH="$HOME/.local/bin:$PATH"
102+
cdidx --version
103+
```
104+
105+
To make this permanent (bash):
106+
107+
```bash
108+
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
109+
```
110+
90111
**Dockerfile example:**
91112

92113
```dockerfile
@@ -159,6 +180,21 @@ if ($path -notlike '*C:\Tools*') {
159180

160181
Restart your terminal after adding to PATH.
161182

183+
### Option D: Use GHCR image from a branch
184+
185+
For AI/container workflows, you can open a container directly from a branch-built image on GHCR.
186+
187+
After pushing your branch, GitHub Actions publishes:
188+
189+
- `ghcr.io/<owner>/cdidx:<branch-name>`
190+
- `ghcr.io/<owner>/cdidx:sha-<commit>`
191+
192+
Example:
193+
194+
```bash
195+
docker run --rm ghcr.io/widthdom/cdidx:work --version
196+
```
197+
162198
### Verify
163199

164200
```bash
@@ -867,6 +903,27 @@ curl -fsSL https://raw.githubusercontent.com/Widthdom/CodeIndex/v1.5.0/install.s
867903

868904
対応プラットフォーム: `linux-x64`, `linux-arm64`, `osx-arm64`(glibc ベースの Linux のみ。Alpine/musl は非対応)。デフォルトで `~/.local/bin` にインストール(`CDIDX_INSTALL_DIR` で変更可)。
869905

906+
管理されたコンテナ/プロキシ環境でインストール時に HTTP 403 が出る場合、GitHub エンドポイントがブロックされている可能性があります。固定バージョン + ミラー URL を使用してください:
907+
908+
```bash
909+
export CDIDX_GITHUB_API_URL="https://<your-mirror>/repos/Widthdom/CodeIndex"
910+
export CDIDX_RELEASE_BASE_URL="https://<your-mirror>/releases/download"
911+
curl -fsSL https://raw.githubusercontent.com/Widthdom/CodeIndex/main/install.sh | bash -s -- v1.8.0
912+
```
913+
914+
インストール自体は成功しているのに `cdidx` が見つからない場合は、シェルの `PATH``~/.local/bin` が入っていない可能性があります:
915+
916+
```bash
917+
export PATH="$HOME/.local/bin:$PATH"
918+
cdidx --version
919+
```
920+
921+
永続化する場合(bash):
922+
923+
```bash
924+
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
925+
```
926+
870927
**Dockerfile の例:**
871928

872929
```dockerfile
@@ -939,6 +996,21 @@ if ($path -notlike '*C:\Tools*') {
939996

940997
PATH追加後はターミナルを再起動してください。
941998

999+
### 方法D: ブランチ由来のGHCRイメージを使う
1000+
1001+
AI/コンテナ用途では、ブランチからビルドされた GHCR イメージを直接指定してコンテナを開けます。
1002+
1003+
ブランチを push すると GitHub Actions が次を公開します:
1004+
1005+
- `ghcr.io/<owner>/cdidx:<branch-name>`
1006+
- `ghcr.io/<owner>/cdidx:sha-<commit>`
1007+
1008+
例:
1009+
1010+
```bash
1011+
docker run --rm ghcr.io/widthdom/cdidx:work --version
1012+
```
1013+
9421014
### 確認
9431015

9441016
```bash

install.sh

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ REPO="Widthdom/CodeIndex"
1313
INSTALL_DIR="${CDIDX_INSTALL_DIR:-$HOME/.local/bin}"
1414
BINARY_NAME="cdidx"
1515
TMPDIR_CLEANUP=""
16+
GITHUB_API_BASE="${CDIDX_GITHUB_API_URL:-https://api.github.com/repos/${REPO}}"
17+
RELEASE_BASE_URL="${CDIDX_RELEASE_BASE_URL:-https://github.com/${REPO}/releases/download}"
1618

1719
# --- Helpers / ヘルパー ---
1820

@@ -78,8 +80,21 @@ resolve_version() {
7880
info "Fetching latest release version..."
7981
need_cmd curl
8082
local api_response
81-
api_response="$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest")" \
82-
|| error "Failed to fetch latest release from GitHub API. Check your network connection."
83+
api_response="$(curl -fsSL "${GITHUB_API_BASE}/releases/latest")" || {
84+
error "Failed to fetch latest release metadata from ${GITHUB_API_BASE}/releases/latest.
85+
86+
Possible causes:
87+
- Network/proxy blocks GitHub API access (common in managed AI containers)
88+
- Temporary connectivity issue
89+
90+
Try one of these:
91+
1) Pin a version explicitly (skips latest API call):
92+
bash install.sh v1.8.0
93+
2) Use a mirror endpoint:
94+
export CDIDX_GITHUB_API_URL='https://<your-mirror>/repos/${REPO}'
95+
export CDIDX_RELEASE_BASE_URL='https://<your-mirror>/releases/download'
96+
bash install.sh v1.8.0"
97+
}
8398

8499
VERSION="$(printf '%s' "$api_response" | grep '"tag_name"' | head -1 | sed 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/')"
85100

@@ -118,7 +133,7 @@ download_and_install() {
118133
need_cmd mktemp
119134

120135
local archive_name="CodeIndex-${RID}.tar.gz"
121-
local base_url="https://github.com/${REPO}/releases/download/${VERSION}"
136+
local base_url="${RELEASE_BASE_URL}/${VERSION}"
122137
local archive_url="${base_url}/${archive_name}"
123138
local checksums_url="${base_url}/sha256sums.txt"
124139

@@ -128,11 +143,16 @@ download_and_install() {
128143

129144
info "Downloading ${archive_name}..."
130145
curl -fsSL -o "${tmpdir}/${archive_name}" "$archive_url" \
131-
|| error "Failed to download $archive_url. Check that version $VERSION exists and has a ${RID} binary."
146+
|| error "Failed to download ${archive_url}.
147+
148+
Check:
149+
- Version exists and publishes ${RID}: ${VERSION}
150+
- Network/proxy can access release assets
151+
- If needed, set CDIDX_RELEASE_BASE_URL to an internal mirror"
132152

133153
info "Downloading checksums..."
134154
curl -fsSL -o "${tmpdir}/sha256sums.txt" "$checksums_url" \
135-
|| error "Failed to download checksums from $checksums_url."
155+
|| error "Failed to download checksums from ${checksums_url}. If you use a mirror, ensure sha256sums.txt is also mirrored."
136156

137157
# Verify checksum / チェックサム検証
138158
info "Verifying checksum..."

0 commit comments

Comments
 (0)