fix cargo version gh-actions
This commit is contained in:
18
.github/workflows/release.yml
vendored
18
.github/workflows/release.yml
vendored
@@ -48,6 +48,24 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Node.js for version sync
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '18'
|
||||||
|
|
||||||
|
- name: Install jq
|
||||||
|
run: |
|
||||||
|
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
|
||||||
|
sudo apt-get update && sudo apt-get install -y jq
|
||||||
|
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
|
||||||
|
brew install jq
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Sync package.json versions
|
||||||
|
run: |
|
||||||
|
chmod +x scripts/sync-versions.sh
|
||||||
|
./scripts/sync-versions.sh
|
||||||
|
|
||||||
- name: Setup Rust
|
- name: Setup Rust
|
||||||
uses: dtolnay/rust-toolchain@stable
|
uses: dtolnay/rust-toolchain@stable
|
||||||
with:
|
with:
|
||||||
|
81
.github/workflows/sync-versions.yml
vendored
Normal file
81
.github/workflows/sync-versions.yml
vendored
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
name: Sync Versions
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main ]
|
||||||
|
paths:
|
||||||
|
- 'Cargo.toml'
|
||||||
|
pull_request:
|
||||||
|
branches: [ main ]
|
||||||
|
paths:
|
||||||
|
- 'Cargo.toml'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sync-versions:
|
||||||
|
name: Sync package.json versions with Cargo.toml
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '18'
|
||||||
|
|
||||||
|
- name: Install jq
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y jq
|
||||||
|
|
||||||
|
- name: Make scripts executable
|
||||||
|
run: chmod +x scripts/sync-versions.sh
|
||||||
|
|
||||||
|
- name: Sync versions
|
||||||
|
run: ./scripts/sync-versions.sh
|
||||||
|
|
||||||
|
- name: Check for changes
|
||||||
|
id: changes
|
||||||
|
run: |
|
||||||
|
if git diff --quiet; then
|
||||||
|
echo "changed=false" >> $GITHUB_OUTPUT
|
||||||
|
echo "No version changes detected"
|
||||||
|
else
|
||||||
|
echo "changed=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "Version changes detected"
|
||||||
|
git diff --name-only
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Commit and push changes
|
||||||
|
if: steps.changes.outputs.changed == 'true' && github.event_name == 'push'
|
||||||
|
run: |
|
||||||
|
git config --local user.email "action@github.com"
|
||||||
|
git config --local user.name "GitHub Action"
|
||||||
|
git add oauth/package.json pds/package.json
|
||||||
|
git commit -m "🔄 Sync package.json versions with Cargo.toml"
|
||||||
|
git push
|
||||||
|
|
||||||
|
- name: Create Pull Request
|
||||||
|
if: steps.changes.outputs.changed == 'true' && github.event_name == 'pull_request'
|
||||||
|
uses: peter-evans/create-pull-request@v5
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
commit-message: "🔄 Sync package.json versions with Cargo.toml"
|
||||||
|
title: "Auto-sync package.json versions"
|
||||||
|
body: |
|
||||||
|
This PR automatically syncs package.json versions with the version in Cargo.toml.
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
- Updated oauth/package.json version
|
||||||
|
- Updated pds/package.json version
|
||||||
|
|
||||||
|
Generated by GitHub Actions.
|
||||||
|
branch: sync-versions-${{ github.run_number }}
|
||||||
|
delete-branch: true
|
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "ailog"
|
name = "ailog"
|
||||||
version = "0.3.2"
|
version = "0.3.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["syui"]
|
authors = ["syui"]
|
||||||
description = "A static blog generator with AI features"
|
description = "A static blog generator with AI features"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ailog-oauth",
|
"name": "ailog-oauth",
|
||||||
"version": "0.3.2",
|
"version": "0.3.4",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pds-browser",
|
"name": "pds-browser",
|
||||||
"version": "0.3.2",
|
"version": "0.3.4",
|
||||||
"description": "AT Protocol browser for ai.log",
|
"description": "AT Protocol browser for ai.log",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
72
scripts/sync-versions.js
Executable file
72
scripts/sync-versions.js
Executable file
@@ -0,0 +1,72 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Version synchronization script for ailog
|
||||||
|
* Syncs version from Cargo.toml to all package.json files
|
||||||
|
*/
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
// Read version from Cargo.toml
|
||||||
|
function getCargoVersion() {
|
||||||
|
const cargoPath = path.join(__dirname, '../Cargo.toml');
|
||||||
|
const cargoContent = fs.readFileSync(cargoPath, 'utf8');
|
||||||
|
const versionMatch = cargoContent.match(/^version\s*=\s*"([^"]+)"/m);
|
||||||
|
|
||||||
|
if (!versionMatch) {
|
||||||
|
throw new Error('Could not find version in Cargo.toml');
|
||||||
|
}
|
||||||
|
|
||||||
|
return versionMatch[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update package.json version
|
||||||
|
function updatePackageVersion(packagePath, version) {
|
||||||
|
if (!fs.existsSync(packagePath)) {
|
||||||
|
console.warn(`Package.json not found: ${packagePath}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const packageData = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
|
||||||
|
const oldVersion = packageData.version;
|
||||||
|
packageData.version = version;
|
||||||
|
|
||||||
|
fs.writeFileSync(packagePath, JSON.stringify(packageData, null, 2) + '\n');
|
||||||
|
console.log(`Updated ${path.relative(process.cwd(), packagePath)}: ${oldVersion} → ${version}`);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main function
|
||||||
|
function main() {
|
||||||
|
try {
|
||||||
|
const version = getCargoVersion();
|
||||||
|
console.log(`Cargo.toml version: ${version}`);
|
||||||
|
|
||||||
|
// List of package.json files to update
|
||||||
|
const packageFiles = [
|
||||||
|
path.join(__dirname, '../oauth/package.json'),
|
||||||
|
path.join(__dirname, '../pds/package.json')
|
||||||
|
];
|
||||||
|
|
||||||
|
let updatedCount = 0;
|
||||||
|
for (const packageFile of packageFiles) {
|
||||||
|
if (updatePackageVersion(packageFile, version)) {
|
||||||
|
updatedCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`✅ Successfully updated ${updatedCount} package.json files`);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('❌ Error syncing versions:', error.message);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run if called directly
|
||||||
|
if (require.main === module) {
|
||||||
|
main();
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { getCargoVersion, updatePackageVersion };
|
81
scripts/sync-versions.sh
Executable file
81
scripts/sync-versions.sh
Executable file
@@ -0,0 +1,81 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Version synchronization script for ailog
|
||||||
|
# Syncs version from Cargo.toml to all package.json files
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Get the directory of this script
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||||
|
|
||||||
|
# Function to extract version from Cargo.toml
|
||||||
|
get_cargo_version() {
|
||||||
|
grep '^version = ' "$PROJECT_ROOT/Cargo.toml" | cut -d'"' -f2
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to update package.json version using jq
|
||||||
|
update_package_version() {
|
||||||
|
local package_file="$1"
|
||||||
|
local version="$2"
|
||||||
|
|
||||||
|
if [[ ! -f "$package_file" ]]; then
|
||||||
|
echo "⚠️ Package.json not found: $package_file"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if jq is available
|
||||||
|
if ! command -v jq &> /dev/null; then
|
||||||
|
echo "❌ jq is required but not installed. Please install jq first."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get current version using jq
|
||||||
|
local old_version=$(jq -r '.version' "$package_file")
|
||||||
|
|
||||||
|
# Update version using jq (with proper formatting)
|
||||||
|
local temp_file=$(mktemp)
|
||||||
|
jq --arg version "$version" '.version = $version' "$package_file" > "$temp_file"
|
||||||
|
|
||||||
|
# Replace original file if jq succeeded
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
mv "$temp_file" "$package_file"
|
||||||
|
echo "✅ Updated $(basename "$package_file"): $old_version → $version"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
rm -f "$temp_file"
|
||||||
|
echo "❌ Failed to update $package_file"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Main execution
|
||||||
|
main() {
|
||||||
|
local version
|
||||||
|
version=$(get_cargo_version)
|
||||||
|
|
||||||
|
if [[ -z "$version" ]]; then
|
||||||
|
echo "❌ Could not find version in Cargo.toml"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "📦 Cargo.toml version: $version"
|
||||||
|
echo "🔄 Syncing versions..."
|
||||||
|
|
||||||
|
# List of package.json files to update
|
||||||
|
local packages=(
|
||||||
|
"$PROJECT_ROOT/oauth/package.json"
|
||||||
|
"$PROJECT_ROOT/pds/package.json"
|
||||||
|
)
|
||||||
|
|
||||||
|
local updated_count=0
|
||||||
|
for package in "${packages[@]}"; do
|
||||||
|
if update_package_version "$package" "$version"; then
|
||||||
|
((updated_count++))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "✅ Successfully synced $updated_count package.json files"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run main function
|
||||||
|
main "$@"
|
@@ -70,10 +70,10 @@ async fn communicate_with_claude_mcp(
|
|||||||
// Claude Code MCPプロセスを起動
|
// Claude Code MCPプロセスを起動
|
||||||
// Use the full path to avoid shell function and don't use --continue
|
// Use the full path to avoid shell function and don't use --continue
|
||||||
let claude_executable = if claude_code_path == "claude" {
|
let claude_executable = if claude_code_path == "claude" {
|
||||||
// Use $HOME environment variable instead of hardcoded path
|
// Use dirs crate for cross-platform home directory detection
|
||||||
match std::env::var("HOME") {
|
match dirs::home_dir() {
|
||||||
Ok(home) => format!("{}/.claude/local/claude", home),
|
Some(home) => home.join(".claude/local/claude").to_string_lossy().to_string(),
|
||||||
Err(_) => "/Users/syui/.claude/local/claude".to_string(), // fallback
|
None => "/Users/syui/.claude/local/claude".to_string(), // fallback
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
claude_code_path.to_string()
|
claude_code_path.to_string()
|
||||||
|
Reference in New Issue
Block a user