Repository navigation
94 lines (83 loc) · 3.18 KB
/
Copy pathrelease.yml
File metadata and controls
94 lines (83 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: 'Release 打包'
on:
workflow_dispatch:
inputs:
tag:
description: '要构建并上传的版本标签,例如 v1.0.20261022;留空则只构建不上传'
required: false
type: string
push:
tags:
- 'v*'
release:
types: [published, released]
permissions:
contents: write
concurrency:
group: 'imagemarker-release-${{ github.workflow }}-${{ github.ref }}'
cancel-in-progress: false
jobs:
release:
name: '打包静态站点并发布 Release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: package-lock.json
- name: '校验版本号与发布标签一致'
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
INPUT_TAG: ${{ github.event.inputs.tag }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
REF_NAME: ${{ github.ref_name }}
run: |
set -euo pipefail
version="$(node -p "require('./package.json').version")"
tag="${INPUT_TAG:-}"
[ -n "$tag" ] || tag="${RELEASE_TAG:-$REF_NAME}"
echo "源码版本号: v${version}"
echo "发布标签: ${tag:-<未指定>}"
if [ -z "${tag}" ] || [ "${tag}" = "main" ] || [ "${tag}" = "master" ]; then
echo '未指定发布标签,跳过一致性校验。'
exit 0
fi
if [ "${tag}" != "v${version}" ]; then
echo "::error::发布标签 ${tag} 与源码版本号 v${version} 不一致,请先把版本号改成 ${tag#v} 再发布。"
exit 1
fi
- name: '安装前端依赖并构建'
run: |
npm ci --no-audit --no-fund
npm run build
- name: '打包静态站点'
run: |
mkdir -p release
tar czf release/imagemarker-web.tar.gz -C dist .
- name: '生成 MD5/SHA1 校验文件'
run: |
set -euo pipefail
cd release
md5sum imagemarker-web.tar.gz > checksums-md5.txt
sha1sum imagemarker-web.tar.gz > checksums-sha1.txt
- name: '上传到 Release'
if: github.event_name != 'workflow_dispatch' || github.event.inputs.tag != ''
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.tag || github.event.release.tag_name || github.ref_name }}
name: 'ImageMarker v${{ github.event.inputs.tag || github.event.release.tag_name || github.ref_name }}'
body: |
## ImageMarker v${{ github.event.inputs.tag || github.event.release.tag_name || github.ref_name }}
### 离线静态站点包
- `imagemarker-web.tar.gz`:解压后可用任意静态文件服务器或 `npx serve` 直接托管。
### Docker 镜像
`imagemarker-image.tar.gz` 由 `docker-image.yml` 自动附加,导入方式:
`docker load -i imagemarker-image.tar.gz`
files: |
release/imagemarker-web.tar.gz
release/checksums-md5.txt
release/checksums-sha1.txt
fail_on_unmatched_files: true