From 3c754d7a62f6a54c3c3cad6917a5f87f03c240a0 Mon Sep 17 00:00:00 2001 From: Zisu Zhang Date: Mon, 25 Mar 2024 16:11:05 +0800 Subject: [PATCH] chore(ci): update scripts (#81) --- .github/workflows/check.yaml | 4 ++-- .github/workflows/publish.yaml | 9 +++++---- .yarn/versions/743c80d6.yml | 3 +++ scripts/publish.mjs | 11 ++++++++++- 4 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 .yarn/versions/743c80d6.yml diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index aa067be0..8e0449dc 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -16,7 +16,7 @@ jobs: fetch-depth: 0 - name: Setup Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' @@ -24,7 +24,7 @@ jobs: id: yarn-cache-dir-path run: echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT - - uses: actions/cache@v3 + - uses: actions/cache@v4 id: yarn-cache with: path: ${{ steps.yarn-cache-dir-path.outputs.dir }} diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index d1b1a46f..479ddf23 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -26,15 +26,16 @@ jobs: token: ${{ steps.app-token.outputs.token }} - name: Setup Node - uses: actions/setup-node@v3 + 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@v3 + - uses: actions/cache@v4 id: yarn-cache with: path: ${{ steps.yarn-cache-dir-path.outputs.dir }} @@ -80,14 +81,14 @@ jobs: 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 + 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@v4 + uses: docker/build-push-action@v5 with: push: true context: '.' diff --git a/.yarn/versions/743c80d6.yml b/.yarn/versions/743c80d6.yml new file mode 100644 index 00000000..29172b8c --- /dev/null +++ b/.yarn/versions/743c80d6.yml @@ -0,0 +1,3 @@ +releases: + "@aoi-js/frontend": 1.1.0-alpha.2 + "@aoi-js/server": 1.1.0-alpha.2 diff --git a/scripts/publish.mjs b/scripts/publish.mjs index 35aa240e..d3653a98 100644 --- a/scripts/publish.mjs +++ b/scripts/publish.mjs @@ -26,7 +26,16 @@ const items = stdout for (const { ident } of items) { console.log(`Publishing ${chalk.greenBright(ident)}...`) await $`yarn workspace ${ident} pack --out package.tgz` - await $`cd ${packages[ident]} && npm publish package.tgz --provenance`.nothrow() + try { + await $`cd ${packages[ident]} && npm publish package.tgz --provenance` + } catch (err) { + const stdout = /** @type {ProcessOutput} */ (err).stdout + if (stdout.includes('You cannot publish over the previously published versions')) { + console.log(`${ident} already published, skip it.`) + } else { + throw err + } + } if (process.env.CI) { const name = ident.split('/')[1] await $`echo "${name}_updated=true" >> "$GITHUB_OUTPUT"`