Skip to content

Restore synced browser sessions #310

Restore synced browser sessions

Restore synced browser sessions #310

name: Version Management
on:
push:
branches: [ main ]
permissions:
contents: write
concurrency:
group: version-management
cancel-in-progress: false
jobs:
bump-version-and-tag:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[no-cli]')"
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.RELEASE_PUSH_TOKEN || github.token }}
fetch-depth: 0
- name: Warn when release PAT is missing
env:
RELEASE_PUSH_TOKEN: ${{ secrets.RELEASE_PUSH_TOKEN }}
run: |
if [ -z "${RELEASE_PUSH_TOKEN}" ]; then
echo "::warning::RELEASE_PUSH_TOKEN is not set. Tag-push triggers may not run, but Chrome publish will still run via workflow_run after Version Management completes on main."
fi
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Configure Git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- name: Bump version, commit, and tag
run: |
# Fetch tags to ensure we have the latest tag information
git fetch --tags
# Read current version from manifest.json
current_version=$(node -e "const fs=require('fs'); const m=JSON.parse(fs.readFileSync('./manifest.json','utf8')); process.stdout.write(m.version);")
echo "Current version: $current_version"
# Parse major.minor.patch and bump minor
IFS='.' read -r major minor patch <<< "$current_version"
if [ -z "${major:-}" ] || [ -z "${minor:-}" ] || [ -z "${patch:-}" ]; then
echo "manifest.json version must be in major.minor.patch format"
exit 1
fi
new_minor=$((minor + 1))
# Find the next available version that doesn't have a tag
while true; do
new_version="$major.$new_minor.0"
if git rev-parse "v$new_version" >/dev/null 2>&1 || git ls-remote --tags origin "v$new_version" | grep -q "refs/tags/v$new_version"; then
echo "Tag v$new_version already exists, trying next version..."
new_minor=$((new_minor + 1))
else
break
fi
done
echo "New version: $new_version"
# Keep manifest and package versions aligned.
node -e "
const fs = require('fs');
const manifest = JSON.parse(fs.readFileSync('./manifest.json', 'utf8'));
manifest.version = '$new_version';
fs.writeFileSync('./manifest.json', JSON.stringify(manifest, null, 2) + '\n');
const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
pkg.version = '$new_version';
fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2) + '\n');
"
# Commit the changes
git add manifest.json package.json
git commit -m "chore(release): bump version to v$new_version [no-cli]"
git push origin main
# Create and push tag
git tag "v$new_version"
git push origin "v$new_version"