-
Notifications
You must be signed in to change notification settings - Fork 0
125 lines (104 loc) · 3.46 KB
/
Copy pathrelease-dist.yml
File metadata and controls
125 lines (104 loc) · 3.46 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: Rebuild release archive
on:
workflow_dispatch:
inputs:
tag:
description: 'Тег релиза, например v1.5.5'
required: true
type: string
permissions:
contents: read
jobs:
verify:
permissions:
contents: read
runs-on: ubuntu-latest
env:
RELEASE_TAG: ${{ inputs.tag }}
steps:
- name: Validate release tag
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
if [[ ! "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then
echo "Некорректный тег релиза: $RELEASE_TAG"
exit 1
fi
git ls-remote --exit-code --tags \
"https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" \
"refs/tags/${RELEASE_TAG}" >/dev/null
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ inputs.tag }}
fetch-depth: 0
persist-credentials: false
- name: Verify release revision
shell: bash
run: |
VERSION="$(node -p "require('./package.json').version")"
EXPECTED_TAG="v$VERSION"
HEAD_SHA="$(git rev-parse HEAD)"
TAG_SHA="$(git rev-list -n 1 "$RELEASE_TAG")"
if [[ "$RELEASE_TAG" != "$EXPECTED_TAG" ]]; then
echo "Тег $RELEASE_TAG не соответствует версии package.json: $EXPECTED_TAG"
exit 1
fi
if [[ "$TAG_SHA" != "$HEAD_SHA" ]]; then
echo "Тег $RELEASE_TAG указывает на $TAG_SHA вместо checkout-ревизии $HEAD_SHA"
exit 1
fi
- name: Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 22
- name: Enable pnpm
run: corepack enable
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Audit production dependencies
run: pnpm audit --prod
- name: Install Playwright browser
run: pnpm exec playwright install --with-deps chromium
- name: Lint
run: pnpm lint
- name: Run tests
run: pnpm test
- name: Build site
run: pnpm build
env:
VITE_BASE_PATH: ./
- name: Verify PWA build
run: pnpm test:pwa
- name: Run production browser E2E
run: pnpm test:e2e
- name: Pack dist
run: |
cd dist
zip -r ../credit-calculator-dist.zip .
- name: Upload verified release artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: release-dist
path: credit-calculator-dist.zip
if-no-files-found: error
publish:
needs: verify
permissions:
contents: write
runs-on: ubuntu-latest
env:
RELEASE_TAG: ${{ inputs.tag }}
steps:
- name: Download verified release artifact
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: release-dist
- name: Create GitHub Release
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2
with:
tag_name: ${{ env.RELEASE_TAG }}
files: credit-calculator-dist.zip
generate_release_notes: true
fail_on_unmatched_files: true