Skip to content

Commit 108a5f9

Browse files
committed
feat: add version updates management with GitHub Releases integration
1 parent f6c3dfd commit 108a5f9

10 files changed

Lines changed: 1066 additions & 11 deletions

File tree

.github/workflows/release.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
release:
14+
name: Create GitHub Release
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 10
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v6
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Detect new changelog
24+
id: changelog
25+
shell: bash
26+
run: |
27+
set -euo pipefail
28+
29+
BEFORE_SHA="${{ github.event.before }}"
30+
if [ -z "$BEFORE_SHA" ] || [ "$BEFORE_SHA" = "0000000000000000000000000000000000000000" ]; then
31+
BEFORE_SHA="HEAD^"
32+
fi
33+
34+
NEW_FILE="$(git diff --name-status "$BEFORE_SHA" "${{ github.sha }}" | awk '$1 == "A" {print $2}' | grep -E '^changelog/v[0-9]+\.[0-9]+\.[0-9]+.*\.md$' | head -n 1 || true)"
35+
36+
if [ -z "$NEW_FILE" ]; then
37+
echo "has_release=false" >> "$GITHUB_OUTPUT"
38+
echo "version=" >> "$GITHUB_OUTPUT"
39+
echo "file_path=" >> "$GITHUB_OUTPUT"
40+
echo "No new changelog file found."
41+
exit 0
42+
fi
43+
44+
VERSION="$(basename "$NEW_FILE" .md)"
45+
echo "has_release=true" >> "$GITHUB_OUTPUT"
46+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
47+
echo "file_path=$NEW_FILE" >> "$GITHUB_OUTPUT"
48+
echo "Detected release changelog: $NEW_FILE"
49+
50+
- name: Sync package versions
51+
if: steps.changelog.outputs.has_release == 'true'
52+
shell: bash
53+
run: |
54+
set -euo pipefail
55+
56+
TARGET_VERSION="${{ steps.changelog.outputs.version }}"
57+
TARGET_VERSION="${TARGET_VERSION#v}"
58+
59+
node - <<'NODE' "$TARGET_VERSION"
60+
const fs = require("node:fs");
61+
const version = process.argv[2];
62+
63+
function updatePackageJson(filePath) {
64+
const raw = fs.readFileSync(filePath, "utf8");
65+
const json = JSON.parse(raw);
66+
json.version = version;
67+
fs.writeFileSync(filePath, JSON.stringify(json, null, 2) + "\n");
68+
}
69+
70+
function updatePackageLock(filePath) {
71+
if (!fs.existsSync(filePath)) return;
72+
73+
const raw = fs.readFileSync(filePath, "utf8");
74+
const json = JSON.parse(raw);
75+
json.version = version;
76+
if (json.packages && json.packages[""]) {
77+
json.packages[""].version = version;
78+
}
79+
fs.writeFileSync(filePath, JSON.stringify(json, null, 2) + "\n");
80+
}
81+
82+
updatePackageJson("package.json");
83+
updatePackageLock("package-lock.json");
84+
NODE
85+
86+
git add package.json package-lock.json
87+
88+
if git diff --cached --quiet; then
89+
echo "Package versions are already up to date."
90+
exit 0
91+
fi
92+
93+
git config user.name "github-actions[bot]"
94+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
95+
git commit -m "chore(release): sync package version to ${{ steps.changelog.outputs.version }} [skip ci]"
96+
git push origin HEAD:${{ github.ref_name }}
97+
98+
- name: Finalize release commit
99+
id: finalize
100+
if: steps.changelog.outputs.has_release == 'true'
101+
shell: bash
102+
run: |
103+
echo "build_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
104+
105+
- name: Generate release notes
106+
if: steps.changelog.outputs.has_release == 'true'
107+
shell: bash
108+
run: |
109+
set -euo pipefail
110+
111+
FILE_PATH="${{ steps.changelog.outputs.file_path }}"
112+
113+
cat "$FILE_PATH" > release.md
114+
115+
- name: Create release
116+
if: steps.changelog.outputs.has_release == 'true'
117+
uses: softprops/action-gh-release@v2
118+
with:
119+
tag_name: ${{ steps.changelog.outputs.version }}
120+
name: Release ${{ steps.changelog.outputs.version }}
121+
body_path: release.md
122+
target_commitish: ${{ steps.finalize.outputs.build_sha }}
123+
fail_on_unmatched_files: true
124+
env:
125+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

changelog/v0.1.0.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
InsightFlare v0.1.0 is the first public release of the project.
2+
3+
This initial version establishes the core analytics experience and brings the foundational analysis workflow to a highly usable state. Teams can already collect traffic data, inspect real-time activity, analyze pages, referrers, sessions, visitors, devices, browsers, geography, campaigns, events, funnels, retention, and performance signals from a unified dashboard.
4+
5+
## Highlights
6+
7+
- Delivered the first complete InsightFlare analytics dashboard experience.
8+
- Added high-availability core analysis flows for traffic overview, realtime monitoring, page analytics, referrers, sessions, visitors, geography, device and browser breakdowns, campaign tracking, custom events, funnels, retention, and Web performance.
9+
- Included team, site, user, and system management surfaces required to operate the product.
10+
- Established the tracking script and ingestion pipeline for collecting analytics data.
11+
- Added the first version update surface for future release visibility.
12+
13+
## Notes
14+
15+
This release is intended as the baseline for future versioned updates. Subsequent releases will build on this foundation with more automation, deeper analysis, and operational refinements.

next.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import type { NextConfig } from "next";
22
import { initOpenNextCloudflareForDev } from "@opennextjs/cloudflare";
33

4+
import packageJson from "./package.json";
5+
46
initOpenNextCloudflareForDev();
57

68
const nextConfig: NextConfig = {
79
reactStrictMode: true,
10+
env: {
11+
NEXT_PUBLIC_APP_VERSION: packageJson.version,
12+
},
813
turbopack: {
914
rules: {
1015
"*.yaml": {

0 commit comments

Comments
 (0)