66 - main
77
88 workflow_dispatch :
9+ inputs :
10+ bump :
11+ description : " Version bump"
12+ required : true
13+ default : " auto"
14+ type : choice
15+ options :
16+ - auto
17+ - patch
18+ - minor
19+ - major
920
1021permissions :
11- contents : read
22+ contents : write
1223 pages : write
1324 id-token : write
1425
@@ -17,13 +28,131 @@ concurrency:
1728 cancel-in-progress : false
1829
1930jobs :
31+ version :
32+ name : Prepare SemVer release
33+ runs-on : ubuntu-latest
34+
35+ outputs :
36+ version : ${{ steps.bump.outputs.version }}
37+ tag : ${{ steps.bump.outputs.tag }}
38+ bump : ${{ steps.bump.outputs.bump }}
39+ sha : ${{ steps.bump.outputs.sha }}
40+ build_time : ${{ steps.bump.outputs.build_time }}
41+
42+ steps :
43+ - name : Checkout
44+ uses : actions/checkout@v5
45+ with :
46+ fetch-depth : 0
47+
48+ - name : Setup Node.js
49+ uses : actions/setup-node@v6
50+ with :
51+ node-version : 24
52+ cache : npm
53+
54+ - name : Configure git
55+ run : |
56+ git config user.name "github-actions[bot]"
57+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
58+
59+ - name : Calculate and commit next version
60+ id : bump
61+ env :
62+ BUMP_INPUT : ${{ github.event.inputs.bump || 'auto' }}
63+ run : |
64+ set -euo pipefail
65+
66+ git fetch --tags --force
67+
68+ LAST_TAG="$(git describe --tags --abbrev=0 --match 'v[0-9]*.[0-9]*.[0-9]*' 2>/dev/null || true)"
69+
70+ if [ -n "$LAST_TAG" ]; then
71+ BASE_VERSION="${LAST_TAG#v}"
72+ COMMITS="$(git log "${LAST_TAG}..HEAD" --pretty=format:'%s%n%b')"
73+ else
74+ BASE_VERSION="$(node -p "require('./package.json').version || '0.0.0'")"
75+ COMMITS="$(git log --pretty=format:'%s%n%b')"
76+ fi
77+
78+ if [ "$BUMP_INPUT" != "auto" ]; then
79+ BUMP="$BUMP_INPUT"
80+ elif printf '%s\n' "$COMMITS" | grep -Eiq '\[major\]|BREAKING CHANGE|^[a-z]+(\([^)]+\))?!:'; then
81+ BUMP="major"
82+ elif printf '%s\n' "$COMMITS" | grep -Eiq '\[minor\]|^feat(\([^)]+\))?:|^feature(\([^)]+\))?:'; then
83+ BUMP="minor"
84+ else
85+ BUMP="patch"
86+ fi
87+
88+ IFS='.' read -r MAJOR MINOR PATCH <<VERSION_PARTS
89+ $BASE_VERSION
90+ VERSION_PARTS
91+
92+ MAJOR="${MAJOR:-0}"
93+ MINOR="${MINOR:-0}"
94+ PATCH="${PATCH:-0}"
95+
96+ case "$BUMP" in
97+ major)
98+ MAJOR=$((MAJOR + 1))
99+ MINOR=0
100+ PATCH=0
101+ ;;
102+ minor)
103+ MINOR=$((MINOR + 1))
104+ PATCH=0
105+ ;;
106+ patch)
107+ PATCH=$((PATCH + 1))
108+ ;;
109+ *)
110+ echo "Unknown bump type: $BUMP"
111+ exit 1
112+ ;;
113+ esac
114+
115+ NEXT_VERSION="${MAJOR}.${MINOR}.${PATCH}"
116+ NEXT_TAG="v${NEXT_VERSION}"
117+
118+ if git rev-parse "$NEXT_TAG" >/dev/null 2>&1; then
119+ echo "Tag already exists: $NEXT_TAG"
120+ exit 1
121+ fi
122+
123+ npm version "$NEXT_VERSION" --no-git-tag-version --allow-same-version
124+
125+ git add package.json
126+ if [ -f package-lock.json ]; then
127+ git add package-lock.json
128+ fi
129+
130+ git commit -m "chore(release): ${NEXT_TAG} [skip ci]"
131+ git tag -a "$NEXT_TAG" -m "$NEXT_TAG"
132+
133+ git push origin HEAD:main
134+ git push origin "$NEXT_TAG"
135+
136+ BUILD_TIME="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
137+ RELEASE_SHA="$(git rev-parse HEAD)"
138+
139+ echo "version=$NEXT_VERSION" >> "$GITHUB_OUTPUT"
140+ echo "tag=$NEXT_TAG" >> "$GITHUB_OUTPUT"
141+ echo "bump=$BUMP" >> "$GITHUB_OUTPUT"
142+ echo "sha=$RELEASE_SHA" >> "$GITHUB_OUTPUT"
143+ echo "build_time=$BUILD_TIME" >> "$GITHUB_OUTPUT"
144+
20145 build :
21146 name : Build static PWA
147+ needs : version
22148 runs-on : ubuntu-latest
23149
24150 steps :
25- - name : Checkout
151+ - name : Checkout release tag
26152 uses : actions/checkout@v5
153+ with :
154+ ref : ${{ needs.version.outputs.tag }}
155+ fetch-depth : 0
27156
28157 - name : Setup Node.js
29158 uses : actions/setup-node@v6
@@ -35,8 +164,36 @@ jobs:
35164 run : npm ci
36165
37166 - name : Build
167+ env :
168+ VITE_APP_VERSION : ${{ needs.version.outputs.version }}
169+ VITE_APP_VERSION_TAG : ${{ needs.version.outputs.tag }}
170+ VITE_APP_BUILD_SHA : ${{ needs.version.outputs.sha }}
171+ VITE_APP_BUILD_TIME : ${{ needs.version.outputs.build_time }}
38172 run : npm run build
39173
174+ - name : Add build version metadata
175+ env :
176+ APP_VERSION : ${{ needs.version.outputs.version }}
177+ APP_VERSION_TAG : ${{ needs.version.outputs.tag }}
178+ APP_VERSION_BUMP : ${{ needs.version.outputs.bump }}
179+ APP_BUILD_SHA : ${{ needs.version.outputs.sha }}
180+ APP_BUILD_TIME : ${{ needs.version.outputs.build_time }}
181+ run : |
182+ node <<'NODE'
183+ const fs = require('fs');
184+
185+ const versionInfo = {
186+ name: 'auditm-field',
187+ version: process.env.APP_VERSION,
188+ tag: process.env.APP_VERSION_TAG,
189+ bump: process.env.APP_VERSION_BUMP,
190+ sha: process.env.APP_BUILD_SHA,
191+ builtAt: process.env.APP_BUILD_TIME,
192+ };
193+
194+ fs.writeFileSync('dist/version.json', JSON.stringify(versionInfo, null, 2) + '\n');
195+ NODE
196+
40197 - name : Add SPA fallback
41198 run : cp dist/index.html dist/404.html
42199
@@ -50,9 +207,14 @@ jobs:
50207
51208 deploy :
52209 name : Deploy static PWA
53- needs : build
210+ needs :
211+ - version
212+ - build
54213 runs-on : ubuntu-latest
55214
215+ outputs :
216+ page_url : ${{ steps.deployment.outputs.page_url }}
217+
56218 environment :
57219 name : github-pages
58220 url : ${{ steps.deployment.outputs.page_url }}
@@ -61,3 +223,27 @@ jobs:
61223 - name : Deploy to GitHub Pages
62224 id : deployment
63225 uses : actions/deploy-pages@v4
226+
227+ release :
228+ name : Create GitHub Release
229+ needs :
230+ - version
231+ - deploy
232+ runs-on : ubuntu-latest
233+
234+ steps :
235+ - name : Create release
236+ env :
237+ GH_TOKEN : ${{ github.token }}
238+ RELEASE_TAG : ${{ needs.version.outputs.tag }}
239+ PAGE_URL : ${{ needs.deploy.outputs.page_url }}
240+ VERSION_BUMP : ${{ needs.version.outputs.bump }}
241+ BUILD_SHA : ${{ needs.version.outputs.sha }}
242+ run : |
243+ gh release create "$RELEASE_TAG" \
244+ --title "$RELEASE_TAG" \
245+ --notes "AuditM-Field GitHub Pages deployment.
246+
247+ Version bump: $VERSION_BUMP
248+ Commit: $BUILD_SHA
249+ Deployed URL: $PAGE_URL"
0 commit comments