Publish #70
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: Publish | |
on: | |
workflow_dispatch: | |
jobs: | |
publish-npm: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write | |
outputs: | |
server_updated: ${{ steps.publish.outputs.server_updated }} | |
steps: | |
- name: Get App Token | |
uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ vars.APP_ID }} | |
private-key: ${{ secrets.PRIVATE_KEY }} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ steps.app-token.outputs.token }} | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v4 | |
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: Publish and commit | |
id: publish | |
run: corepack yarn zx scripts/publish.mjs | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- 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@v3 | |
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@v5 | |
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 }} |