-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (103 loc) · 3.2 KB
/
release.yml
File metadata and controls
115 lines (103 loc) · 3.2 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
name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
permissions:
contents: write
jobs:
lint:
name: Lint & Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- run: npm ci
- run: npm run lint
- run: npm run format:check
test:
name: Unit & Integration Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- run: npm ci
- run: npm run test:unit
- run: npm run test:integration
build:
name: Build & Bundle Size Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- run: npm ci
- run: npm run build
- name: Check bundle size
run: npm run size-check
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [lint, test, build]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Extract version from tag
id: version
run: |
VERSION=${GITHUB_REF_NAME#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Releasing version: $VERSION"
- name: Check if package.json version needs update
id: check-version
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
TAG_VERSION=${{ steps.version.outputs.version }}
if [ "$CURRENT_VERSION" = "$TAG_VERSION" ]; then
echo "needs_update=false" >> $GITHUB_OUTPUT
echo "Package.json already at version $TAG_VERSION"
else
echo "needs_update=true" >> $GITHUB_OUTPUT
echo "Package.json version $CURRENT_VERSION differs from tag $TAG_VERSION"
fi
- name: Update package.json version
if: steps.check-version.outputs.needs_update == 'true'
run: |
npm version ${{ steps.version.outputs.version }} --no-git-tag-version
echo "Updated package.json to version ${{ steps.version.outputs.version }}"
- name: Commit and push version update
if: steps.check-version.outputs.needs_update == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add package.json package-lock.json
git commit -m "chore(release): ${{ github.ref_name }}"
git push origin HEAD:main
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
dist/sonar-quiz.iife.js
dist/sonar-quiz.iife.js.map
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}