Skip to content

Commit

Permalink
🐛 fix docker image ci
Browse files Browse the repository at this point in the history
  • Loading branch information
yanyongyu authored Dec 12, 2023
1 parent a43dfd3 commit 455a0fe
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 7 deletions.
51 changes: 44 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
tags:
- v*

env:
LATEST_PYTHON_VERSION: "3.11"

jobs:
release:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -45,9 +48,9 @@ jobs:
fail-fast: true
matrix:
python_version:
- 3.9
- 3.10
- 3.11
- "3.9"
- "3.10"
- "3.11"
python_variant:
- ""
- "-slim"
Expand Down Expand Up @@ -99,9 +102,9 @@ jobs:

- name: Export digest
run: |
mkdir -p /tmp/digests
mkdir -p /tmp/digests/${{ matrix.python_version }}${{ matrix.python_variant }}
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
touch "/tmp/digests/${{ matrix.python_version }}${{ matrix.python_variant }}/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v3
Expand All @@ -114,6 +117,15 @@ jobs:
push:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
python_version:
- "3.9"
- "3.10"
- "3.11"
python_variant:
- ""
- "-slim"

steps:
- name: Checkout
Expand Down Expand Up @@ -153,14 +165,39 @@ jobs:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
flavor: |
suffix=-py${{ matrix.python_version }}${{ matrix.python_variant }},onlatest=true
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Create manifest list and push
working-directory: /tmp/digests
working-directory: /tmp/digests/${{ matrix.python_version }}${{ matrix.python_variant }}
run: |
docker buildx imagetools create --dry-run $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ steps.image.outputs.IMAGE }}@sha256:%s ' *)
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ steps.image.outputs.IMAGE }}@sha256:%s ' *)
- name: Generate Tags
uses: docker/metadata-action@v5
id: metadata-latest
if: matrix.python_version == env.LATEST_PYTHON_VERSION
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
flavor: |
suffix=${{ matrix.python_variant }},onlatest=true
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Create manifest list and push for latest python version
if: matrix.python_version == env.LATEST_PYTHON_VERSION
working-directory: /tmp/digests/${{ matrix.python_version }}${{ matrix.python_variant }}
run: |
docker buildx imagetools create --dry-run $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ steps.image.outputs.IMAGE }}@sha256:%s ' *)
Expand Down
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,19 @@ _✨ NoneBot2 命令行工具 ✨_
pipx install nb-cli
```

使用 Docker 运行

```shell
docker pull nonebot/nb-cli:latest
```

Docker 镜像可以选择以下版本:

- `latest`, `latest-slim`:最新的稳定版本
- `latest-${python版本}`, `latest-${python版本}-slim`:指定 Python 版本的最新稳定版本
- `${cli版本}`, `${cli版本}-slim`:指定 CLI 版本的最新稳定版本
- `${cli版本}-${python版本}`, `${cli版本}-${python版本}-slim`:指定 CLI 和 Python 版本的最新稳定版本

### 命令行使用

```shell
Expand All @@ -93,12 +106,26 @@ nb --help
- `nb self` 管理 CLI 内部环境
- `nb <script>` 运行脚本

Docker 镜像使用

```shell
docker run --rm -it -v ./:/workspaces nonebot/nb-cli:latest --help
```

挂载当前目录到容器的 `/workspaces` 目录,然后在容器中运行 `nb` 命令。

### 交互式使用

```shell
nb
```

Docker 镜像使用

```shell
docker run --rm -it -v ./:/workspaces nonebot/nb-cli:latest
```

## 开发

### 翻译
Expand Down

0 comments on commit 455a0fe

Please sign in to comment.