ci: auto-inject version from git tag + unify shared/ mirroring

- CI release workflow now extracts version from tag (v1.4.0 → 1.4.0)
  and injects it into manifest.base.json, shared/constants.js, and
  package.json before building — the tag is the single source of truth
- Build script now copies README.md alongside constants.js and
  blacklist.js from /shared → /extension/shared/ (full mirror)
- .gitignore updated: extension/shared/ is fully generated by build
- AI_INIT.md: simplified release workflow, fixed Chrome-only reference
This commit is contained in:
MacBook
2026-05-04 05:27:07 +02:00
parent f7829bbebb
commit 47ca7563b7
5 changed files with 32 additions and 25 deletions
+23
View File
@@ -52,6 +52,29 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract version from tag
id: version
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
- name: Inject version into source files
run: |
VERSION=${{ steps.version.outputs.VERSION }}
echo "Injecting version $VERSION from tag $GITHUB_REF_NAME..."
# 1. extension/manifest.base.json
jq --arg v "$VERSION" '.version = $v' extension/manifest.base.json > tmp.json && mv tmp.json extension/manifest.base.json
echo " ✓ manifest.base.json -> $VERSION"
# 2. shared/constants.js — APP_VERSION
sed -i "s/export const APP_VERSION = '.*'/export const APP_VERSION = '$VERSION'/" shared/constants.js
echo " ✓ shared/constants.js -> $VERSION"
# 3. package.json
jq --arg v "$VERSION" '.version = $v' package.json > tmp.json && mv tmp.json package.json
echo " ✓ package.json -> $VERSION"
echo "Version injection complete."
- name: Build Extensions
run: |
npm install
+1 -2
View File
@@ -38,8 +38,7 @@ coverage/
# KoalaSync Specific
# We ignore the synced files in the extension folder to ensure
# the root 'shared/' remains the Single Source of Truth.
extension/shared/*
!extension/shared/README.md
extension/shared/
# Temporary scratch files
scratch/
+6 -7
View File
@@ -15,7 +15,7 @@ KoalaSync is a specialized tool for **synchronized video playback** across multi
- **Identity**: Users are identified by a unique hex `peerId` combined with a customizable `username`.
## 2. Repository Structure
- `extension/`: Chrome Extension (Manifest V3). Contains background service worker, content scripts, and popup UI.
- `extension/`: Browser Extension (Chrome & Firefox, Manifest V3). Contains background service worker, content scripts, and popup UI.
- `server/`: Node.js Relay Server using Socket.IO (WebSocket-only).
- `website/`: **Landing Page** & Invitation Bridge (Marketing, Tutorials, and Downloads).
- `shared/`: **Single Source of Truth** for protocol constants and event names.
@@ -86,12 +86,11 @@ The following features are critical and must not be removed or fundamentally alt
### Releasing a New Version (CRITICAL WORKFLOW FOR AI AGENTS)
> [!CAUTION]
> **AI AGENTS MUST FOLLOW THIS EXACT SEQUENCE WHEN RELEASING A NEW VERSION OR TAGGING.**
> The extension version is read from the `manifest.json` and `constants.js`, NOT the Git tag. If you skip steps 1-3, the release will contain the old version numbers.
1. **Update `version`** in `extension/manifest.json`.
2. **Update `APP_VERSION`** in `shared/constants.js`.
3. Commit these changes with message `chore: bump version to X.X.X` and push to `main`.
4. Create and push a new tag. **MANDATORY**: Tags MUST start with a `v` (e.g., `v1.3.1`). The GitHub Actions release workflow is strictly configured to ignore any tags without the `v` prefix.
5. Verify the release builds on GitHub Actions.
> The CI pipeline automatically injects the version from the git tag into `manifest.base.json`, `shared/constants.js`, and `package.json`. You do NOT need to manually bump version numbers.
1. Commit all code changes and push to `main`.
2. Create and push a new tag. **MANDATORY**: Tags MUST start with a `v` (e.g., `v1.4.0`). The GitHub Actions release workflow is strictly configured to ignore any tags without the `v` prefix.
3. The CI will extract the version from the tag (e.g., `v1.4.0``1.4.0`), inject it into all source files, build the extension artifacts, publish the Docker image, and create a GitHub Release.
4. Verify the release builds on GitHub Actions.
### Adding a Protocol Event
1. Add the event name to `shared/constants.js`.
-14
View File
@@ -1,14 +0,0 @@
# ⚠️ READ BEFORE EDITING
This directory is a **MIRROR** of the root `/shared` folder.
**DO NOT edit these files directly.** Any changes made here will be overwritten the next time the synchronization script is run.
### Proper Workflow:
1. **Edit** the source files in the root `[repo_root]/shared/` directory.
2. **Run** the synchronization script:
- **Windows**: `[repo_root]\scripts\sync-constants.bat`
- **Linux/macOS**: `[repo_root]/scripts/sync-constants.sh`
3. **Verify** that the changes have propagated to this folder.
Failure to follow this protocol will result in out-of-sync components and broken protocol logic.
+2 -2
View File
@@ -22,7 +22,7 @@ if (!fs.existsSync(extSharedDir)) {
fs.mkdirSync(extSharedDir, { recursive: true });
}
const sharedFiles = ['constants.js', 'blacklist.js'];
const sharedFiles = ['constants.js', 'blacklist.js', 'README.md'];
for (const file of sharedFiles) {
const src = path.join(masterSharedDir, file);
const dest = path.join(extSharedDir, file);
@@ -31,7 +31,7 @@ for (const file of sharedFiles) {
}
fs.copyFileSync(src, dest);
}
console.log('✓ constants.js and blacklist.js synced to extension/shared/');
console.log('✓ constants.js, blacklist.js, and README.md synced to extension/shared/');
// Read the base manifest
const baseManifest = JSON.parse(fs.readFileSync(baseManifestPath, 'utf8'));