Release #385
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: Release | |
on: | |
# push: | |
# branches: | |
# - master | |
workflow_dispatch: | |
schedule: | |
# 每周六 UTC+0 12:00 即 UTC+8 20:00 | |
- cron: "0 12 * * 6" | |
# 仅取消针对当前工作流正在进行的作业或运行 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
permissions: | |
packages: write | |
contents: write | |
issues: write | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
# fetch-depth: 10 | |
# fetch-tags: true | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: "latest" | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "lts/*" | |
cache: "pnpm" | |
- name: Cache Dependency | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.npm | |
~/.yarn | |
~/.cache/pnpm | |
~/cache | |
!~/cache/exclude | |
**/node_modules | |
key: pnpm-${{ runner.os }}-${{ hashFiles('package.json') }} | |
restore-keys: pnpm-${{ runner.os }} | |
- run: pnpm i --frozen-lockfile | |
- run: pnpm run lint | |
- run: pnpm run lint:md | |
- run: pnpm run build | |
- run: pnpm run test | |
- run: pnpm run test:e2e | |
- env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: pnpm run release | |
# 发布到 docker | |
- name: Get git tag | |
run: | | |
GIT_TAG=$(git describe --tags --exact-match HEAD 2>/dev/null || true) | |
echo "GIT_TAG=$GIT_TAG" >> ${GITHUB_ENV} | |
chmod +x scripts/git.sh | |
scripts/git.sh | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Login to Alibaba Cloud Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: registry.cn-hangzhou.aliyuncs.com | |
username: ${{ secrets.ALIYUN_USERNAME }} | |
password: ${{ secrets.ALIYUN_PASSWORD }} | |
- name: Extract Docker metadata | |
id: metadata | |
uses: docker/metadata-action@v5 | |
with: | |
# 发布到 docker.io / ghcr.io / registry.cn-hangzhou.aliyuncs.com | |
images: | | |
${{ github.repository }} | |
ghcr.io/${{ github.repository }} | |
registry.cn-hangzhou.aliyuncs.com/${{ github.repository }} | |
tags: | | |
type=semver,priority=1100,pattern={{version}},value=${{env.GIT_TAG}},enable=true | |
type=raw,value=latest,enable=true | |
type=raw,value={{date 'YYYY-MM-DD' tz='Asia/Shanghai'}},enable=true | |
type=sha,format=short,prefix=sha-,enable=true | |
flavor: latest=false | |
- name: Build and push Docker images | |
uses: docker/build-push-action@v5 | |
# 如果有 GIT_TAG ,就发布 | |
if: ${{ env.GIT_TAG }} | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: ${{ steps.metadata.outputs.tags }} | |
labels: ${{ steps.metadata.outputs.labels }} | |
platforms: linux/amd64,linux/arm64 | |
build-args: | | |
VITE_BAIDU_STATISTICS=${{ secrets.VITE_BAIDU_STATISTICS }} | |
VITE_DOMAIN=${{ secrets.VITE_DOMAIN }} | |
VITE_SENTRY_DSN=${{ secrets.VITE_SENTRY_DSN }} |