Skip to content

0.3.4

0.3.4 #153

Workflow file for this run

name: CI
"on":
push:
branches:
- main
tags-ignore:
- "**"
paths-ignore:
- "**/*.md"
- LICENSE
- "**/*.gitignore"
- .editorconfig
- docs/**
- test.ts
pull_request: null
permissions:
contents: write
jobs:
build:
name: Build
runs-on: ubuntu-latest
outputs:
has_update: ${{ steps.check_version.outputs.has_update }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- run: bun install
- run: bun run build
env:
NODE_ENV: production
- name: get-npm-version
id: package-version
uses: martinbeentjes/[email protected]
- name: Get latest version of docbase
run: echo "LATEST_VERSION=$(npm view docbase version)" >> $GITHUB_ENV
- name: Check version and set output
id: check_version
run: |
if [ "${{ steps.package-version.outputs.current-version }}" != "${{ env.LATEST_VERSION }}" ]; then
echo "has_update=true" >> $GITHUB_OUTPUT
else
echo "has_update=false" >> $GITHUB_OUTPUT
fi
# 如果有更新则创建发行版本
- name: Create Release
if: steps.check_version.outputs.has_update == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.package-version.outputs.current-version }}
name: Release v${{ steps.package-version.outputs.current-version }}
# 将构建产物上传为 artifacts
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist
publish:
name: Publish
needs: build
if: needs.build.outputs.has_update == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# 下载构建产物
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: Install Node.js
uses: actions/setup-node@v4
- name: Set publishing config
run: npm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Publish
run: npm publish --access public --no-git-checks
docker:
name: Build and Push Docker Image
needs: build
if: needs.build.outputs.has_update == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- run: bun install
- run: bun run build
- run: bun run ./downloaddufs.ts
- run: rm -rf node_modules
- run: bun install --production --filter=./
# 登录到 Docker Hub
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: gonorth
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: get-npm-version
id: package-version
uses: martinbeentjes/[email protected]
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
load: true
push: false
tags: gonorth/docbase:latest,gonorth/docbase:${{ steps.package-version.outputs.current-version }}
# Push to the registry
- run: docker image push "gonorth/docbase" --all-tags
# docker-arm:
# name: Build and Push Docker Image ARM
# needs: build
# if: needs.build.outputs.has_update == 'true'
# runs-on: ubuntu-24.04-arm
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Install Bun
# uses: oven-sh/setup-bun@v2
# with:
# bun-version: latest
# - run: bun install
# - run: bun run build
# # 登录到 Docker Hub
# - name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: gonorth
# password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: get-npm-version
# id: package-version
# uses: martinbeentjes/[email protected]
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
# with:
# platforms: linux/arm64
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# with:
# platforms: linux/arm64
# - name: Build and push
# uses: docker/build-push-action@v6
# with:
# context: .
# load: true
# push: false
# tags: gonorth/docbase:latest-arm,gonorth/docbase:${{ steps.package-version.outputs.current-version }}-arm
# # Push to the registry
# - run: docker image push "gonorth/docbase" --all-tags
# docker-union:
# name: Union Docker Image
# needs:
# - docker
# - docker-arm
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# # 登录到 Docker Hub
# - name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: gonorth
# password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: get-npm-version
# id: package-version
# uses: martinbeentjes/[email protected]
# - run: docker manifest create gonorth/docbase:latest gonorth/docbase:latest-x86 gonorth/docbase:latest-arm --amend
# - run: docker manifest annotate gonorth/docbase:latest gonorth/docbase:latest-x86 --os linux --arch amd64
# - run: docker manifest annotate gonorth/docbase:latest gonorth/docbase:latest-arm --os linux --arch arm
# - run: docker manifest push gonorth/docbase:latest
# - run: docker manifest create gonorth/docbase:${{ steps.package-version.outputs.current-version }} gonorth/docbase:${{ steps.package-version.outputs.current-version }}-x86 gonorth/docbase:${{ steps.package-version.outputs.current-version }}-arm --amend
# - run: docker manifest annotate gonorth/docbase:${{ steps.package-version.outputs.current-version }} gonorth/docbase:${{ steps.package-version.outputs.current-version }}-x86 --os linux --arch amd64
# - run: docker manifest annotate gonorth/docbase:${{ steps.package-version.outputs.current-version }} gonorth/docbase:${{ steps.package-version.outputs.current-version }}-arm --os linux --arch arm
# - run: docker manifest push gonorth/docbase:${{ steps.package-version.outputs.current-version }}