diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c9bdef3..d812456 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 diff --git a/.gitignore b/.gitignore index 566f25c..f7fb0ab 100644 --- a/.gitignore +++ b/.gitignore @@ -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/ diff --git a/AI_INIT.md b/AI_INIT.md index 8b2d2e4..13923f3 100644 --- a/AI_INIT.md +++ b/AI_INIT.md @@ -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`. diff --git a/extension/shared/README.md b/extension/shared/README.md deleted file mode 100644 index 33cfe6f..0000000 --- a/extension/shared/README.md +++ /dev/null @@ -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. diff --git a/scripts/build-extension.js b/scripts/build-extension.js index 96e68c7..6b439e5 100644 --- a/scripts/build-extension.js +++ b/scripts/build-extension.js @@ -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'));