🌐 更新语言文件 #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- v* | |
jobs: | |
check-version: | |
name: Check Version | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
outputs: | |
VERSION: ${{ steps.version.outputs.VERSION }} | |
TAG_VERSION: ${{ steps.version.outputs.TAG_VERSION }} | |
TAG_NAME: ${{ steps.version.outputs.TAG_NAME }} | |
steps: | |
- name: 🛎️ Checkout | |
uses: actions/checkout@v3 | |
- name: 🚀 Setup poetry | |
run: pipx install poetry | |
- name: 🔖 Get version | |
id: version | |
run: | | |
echo "VERSION=$(poetry version -s)" >> $GITHUB_OUTPUT | |
echo "TAG_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
- name: ✅ Check version | |
if: steps.version.outputs.VERSION != steps.version.outputs.TAG_VERSION | |
run: exit 1 | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
needs: check-version | |
permissions: | |
id-token: write | |
contents: write | |
steps: | |
- name: 🛎️ Checkout | |
uses: actions/checkout@v3 | |
- name: 🚀 Setup pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: 🚀 Setup node | |
uses: actions/[email protected] | |
with: | |
node-version: 18 | |
cache: "pnpm" | |
cache-dependency-path: "pnpm-lock.yaml" | |
- name: 🔧 Install dependencies | |
run: pnpm install | |
- name: 🚧 Build dist files | |
run: pnpm build | |
- name: 📦️ Upload dist | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dist | |
path: nb_cli_plugin_webui/dist | |
- name: 🚀 Setup Python environment | |
uses: ./.github/actions/setup-python | |
- name: 🚧 Build package | |
run: poetry build | |
- name: 📦️ Publish package to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
- name: 📦️ Publish package to GitHub | |
run: | | |
gh release upload --clobber ${{ needs.check-version.outputs.TAG_NAME }} dist/*.tar.gz dist/*.whl | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
docker-build: | |
name: Build Docker Image | |
runs-on: ubuntu-latest | |
needs: check-version | |
permissions: | |
contents: read | |
packages: write | |
if: |- | |
${{ | |
always() && | |
(needs.check-version.result == 'success' || needs.check-version.result == 'skipped') | |
}} | |
strategy: | |
fail-fast: true | |
matrix: | |
platform: | |
- linux/amd64 | |
- linux/arm64 | |
steps: | |
- name: 🛎️ Checkout | |
uses: actions/checkout@v3 | |
- name: 🚀 Setup QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: 🚀 Setup Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: 🔐 Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: ✨ Generate Image Name and Scope | |
id: image | |
run: | | |
echo "IMAGE=${{ github.repository }}" >> $GITHUB_OUTPUT | |
echo "SCOPE=${{ github.repository_owner }}" >> $GITHUB_OUTPUT | |
- name: ✨ Generate Labels | |
uses: docker/metadata-action@v5 | |
id: metadata | |
with: | |
images: ${{ steps.image.outputs.IMAGE }} | |
- name: 🔍 Get Latest Commit | |
id: commit | |
run: | | |
echo "COMMIT=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT | |
- name: 🚧 Build and Publish | |
uses: docker/build-push-action@v5 | |
id: build | |
with: | |
file: docker/Dockerfile.prod | |
tags: nonebot/nb-cli-plugin-webui:latest | |
context: . | |
platforms: ${{ matrix.platform }} | |
labels: ${{ steps.metadata.outputs.labels }} | |
build-args: SOURCE_COMMIT=${{ steps.commit.outputs.COMMIT }} | |
cache-from: type=gha, | |
scope=${{ steps.image.outputs.SCOPE }} | |
cache-to: type=gha, | |
mode=max, | |
scope=${{ steps.image.outputs.SCOPE }} | |
outputs: type=image, | |
name=${{ steps.image.outputs.IMAGE }}, | |
push-by-digest=true, | |
name-canonical=true, | |
push=true, | |
- name: 📤 Export digest | |
run: | | |
mkdir -p /tmp/digests | |
digest="${{ steps.build.outputs.digest }}" | |
touch "/tmp/digests/${digest#sha256:}" | |
- name: 📦️ Upload digest | |
uses: actions/upload-artifact@v3 | |
with: | |
name: digests | |
path: /tmp/digests/* | |
if-no-files-found: error | |
retention-days: 1 | |
docker-push: | |
name: Push Docker Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: 🛎️ Checkout | |
uses: actions/checkout@v3 | |
- name: 📥 Download digests | |
uses: actions/download-artifact@v3 | |
with: | |
name: digests | |
path: /tmp/digests | |
- name: 🚀 Setup Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: 🔐 Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: 🔐 Login to Github Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: ✨ Generate Image Name | |
id: image | |
run: | | |
echo "IMAGE=${GITHUB_REPOSITORY@L}" >> $GITHUB_OUTPUT | |
- name: ✨ Generate Tags | |
uses: docker/metadata-action@v5 | |
id: metadata | |
with: | |
images: | | |
${{ github.repository }} | |
ghcr.io/${{ github.repository }} | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=sha | |
- name: 📦️ Create manifest list and push | |
working-directory: /tmp/digests | |
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: 📝 Docker Hub Description | |
uses: peter-evans/dockerhub-description@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
short-description: ${{ github.event.repository.description }} |