0.5.3 #220
This file contains hidden or 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: 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 }} | |
version: v${{ steps.package-version.outputs.current-version }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
- name: Install Bun | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: latest | |
- name: Cache node_modules | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package.json') }} | |
- run: bun install | |
- run: cd packages/app && npx -y prisma generate | |
- 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 | |
compile: | |
name: Compile | |
needs: build | |
if: needs.build.outputs.has_update == 'true' | |
strategy: | |
matrix: | |
os: | |
[ | |
ubuntu-latest, | |
ubuntu-24.04-arm, | |
windows-latest, | |
# windows-11-arm, | |
macos-latest, | |
macos-13, | |
] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
- name: Install Bun | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: latest | |
- name: Cache node_modules | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package.json') }} | |
- run: bun install | |
- if: matrix.os != 'windows-latest' | |
run: cd packages/app && npx -y prisma generate | |
- if: matrix.os == 'windows-latest' | |
run: cd packages/app ; npx -y prisma generate | |
- run: bun run build | |
- run: bun compile | |
- uses: AButler/[email protected] | |
with: | |
files: "compile/*" | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
release-tag: ${{ needs.build.outputs.version }} | |
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: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist | |
path: dist | |
# 登录到 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 |