Skip to content

Publish

Publish #32

Workflow file for this run

name: Publish
on:
workflow_dispatch:
permissions:
contents: write
jobs:
publish-npm:
runs-on: ubuntu-latest
outputs:
server_updated: ${{ steps.publish.outputs.server_updated }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: corepack yarn
- name: Build packages
run: corepack yarn workspaces foreach -Ap --topological-dev run build
- name: Setup Yarn
run: corepack yarn config set -H 'npmAuthToken' "${{ secrets.NPM_TOKEN }}"
- name: Publish and commit
id: publish
run: corepack yarn zx scripts/publish.mjs
- name: Upload server tgz
uses: actions/upload-artifact@v4
if: steps.publish.outputs.server_updated == 'true'
with:
name: server
path: apps/server/package.tgz
publish-docker-server:
runs-on: ubuntu-latest
needs: publish-npm
if: needs.publish-npm.outputs.server_updated == 'true'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download server tgz
uses: actions/download-artifact@v4
with:
name: server
path: apps/server
- name: Get current server version
id: version
run: node -p -e "'version='+require('./apps/server/package.json').version" >> $GITHUB_OUTPUT
- name: Log in to Aliyun Container Registry
uses: docker/login-action@v2
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.ACR_USER }}
password: ${{ secrets.ACR_PASS }}
- name: Build and push server Docker image
uses: docker/build-push-action@v4
with:
push: true
context: '.'
file: './docker/dockerfiles/server.dockerfile'
tags: |
registry.cn-hangzhou.aliyuncs.com/aoi-js/server:latest
registry.cn-hangzhou.aliyuncs.com/aoi-js/server:${{ steps.version.outputs.version }}