Compare commits
7 Commits
v0.1.4
...
e1eb04620e
Author | SHA1 | Date | |
---|---|---|---|
e1eb04620e
|
|||
eb3feffd70
|
|||
bb7e4ea01d
|
|||
11f1b57a2d
|
|||
e033e8cc71
|
|||
9957d5efc1
|
|||
d458e53c79
|
51
.github/workflows/build-binary.yml
vendored
51
.github/workflows/build-binary.yml
vendored
@@ -1,51 +0,0 @@
|
|||||||
name: Build Binary
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch: # Manual trigger
|
|
||||||
push:
|
|
||||||
branches: [ main ]
|
|
||||||
paths:
|
|
||||||
- 'src/**'
|
|
||||||
- 'Cargo.toml'
|
|
||||||
- 'Cargo.lock'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Rust
|
|
||||||
uses: actions-rs/toolchain@v1
|
|
||||||
with:
|
|
||||||
toolchain: stable
|
|
||||||
override: true
|
|
||||||
|
|
||||||
- name: Cache cargo registry
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: ~/.cargo/registry
|
|
||||||
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
|
||||||
|
|
||||||
- name: Cache cargo index
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: ~/.cargo/git
|
|
||||||
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
|
||||||
|
|
||||||
- name: Cache target directory
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: target
|
|
||||||
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
|
|
||||||
|
|
||||||
- name: Build binary
|
|
||||||
run: cargo build --release
|
|
||||||
|
|
||||||
- name: Upload binary
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: ailog-linux
|
|
||||||
path: target/release/ailog
|
|
||||||
retention-days: 30
|
|
54
.github/workflows/cloudflare-pages.yml
vendored
54
.github/workflows/cloudflare-pages.yml
vendored
@@ -38,18 +38,60 @@ jobs:
|
|||||||
cp -r oauth/dist/assets/* my-blog/static/assets/
|
cp -r oauth/dist/assets/* my-blog/static/assets/
|
||||||
cp oauth/dist/index.html my-blog/static/oauth/index.html || true
|
cp oauth/dist/index.html my-blog/static/oauth/index.html || true
|
||||||
|
|
||||||
- name: Setup Rust
|
- name: Cache ailog binary
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
toolchain: stable
|
path: ./bin
|
||||||
|
key: ailog-bin-${{ runner.os }}
|
||||||
|
restore-keys: |
|
||||||
|
ailog-bin-${{ runner.os }}
|
||||||
|
|
||||||
- name: Build ailog
|
- name: Setup ailog binary
|
||||||
run: cargo build --release
|
run: |
|
||||||
|
# Get expected version from Cargo.toml
|
||||||
|
EXPECTED_VERSION=$(grep '^version' Cargo.toml | cut -d'"' -f2)
|
||||||
|
echo "Expected version from Cargo.toml: $EXPECTED_VERSION"
|
||||||
|
|
||||||
|
# Check current binary version if exists
|
||||||
|
if [ -f "./bin/ailog" ]; then
|
||||||
|
CURRENT_VERSION=$(./bin/ailog --version 2>/dev/null || echo "unknown")
|
||||||
|
echo "Current binary version: $CURRENT_VERSION"
|
||||||
|
else
|
||||||
|
CURRENT_VERSION="none"
|
||||||
|
echo "No binary found"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check OS
|
||||||
|
OS="${{ runner.os }}"
|
||||||
|
echo "Runner OS: $OS"
|
||||||
|
|
||||||
|
# Use pre-packaged binary if version matches or extract from tar.gz
|
||||||
|
if [ "$CURRENT_VERSION" = "$EXPECTED_VERSION" ]; then
|
||||||
|
echo "Binary is up to date"
|
||||||
|
chmod +x ./bin/ailog
|
||||||
|
elif [ "$OS" = "Linux" ] && [ -f "./bin/ailog-linux-x86_64.tar.gz" ]; then
|
||||||
|
echo "Extracting ailog from pre-packaged tar.gz..."
|
||||||
|
cd bin
|
||||||
|
tar -xzf ailog-linux-x86_64.tar.gz
|
||||||
|
chmod +x ailog
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
# Verify extracted version
|
||||||
|
EXTRACTED_VERSION=$(./bin/ailog --version 2>/dev/null || echo "unknown")
|
||||||
|
echo "Extracted binary version: $EXTRACTED_VERSION"
|
||||||
|
|
||||||
|
if [ "$EXTRACTED_VERSION" != "$EXPECTED_VERSION" ]; then
|
||||||
|
echo "Warning: Binary version mismatch. Expected $EXPECTED_VERSION but got $EXTRACTED_VERSION"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Error: No suitable binary found for OS: $OS"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Build site with ailog
|
- name: Build site with ailog
|
||||||
run: |
|
run: |
|
||||||
cd my-blog
|
cd my-blog
|
||||||
../target/release/ailog build
|
../bin/ailog build
|
||||||
|
|
||||||
- name: List public directory
|
- name: List public directory
|
||||||
run: |
|
run: |
|
||||||
|
51
.github/workflows/gh-pages-fast.yml
vendored
51
.github/workflows/gh-pages-fast.yml
vendored
@@ -23,36 +23,46 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
ailog-bin-${{ runner.os }}
|
ailog-bin-${{ runner.os }}
|
||||||
|
|
||||||
- name: Check and update ailog binary
|
- name: Setup ailog binary
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run: |
|
run: |
|
||||||
# Get latest release version
|
# Get expected version from Cargo.toml
|
||||||
LATEST_VERSION=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
|
EXPECTED_VERSION=$(grep '^version' Cargo.toml | cut -d'"' -f2)
|
||||||
https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
|
echo "Expected version from Cargo.toml: $EXPECTED_VERSION"
|
||||||
echo "Latest version: $LATEST_VERSION"
|
|
||||||
|
|
||||||
# Check current binary version if exists
|
# Check current binary version if exists
|
||||||
mkdir -p ./bin
|
|
||||||
if [ -f "./bin/ailog" ]; then
|
if [ -f "./bin/ailog" ]; then
|
||||||
CURRENT_VERSION=$(./bin/ailog --version 2>/dev/null || echo "unknown")
|
CURRENT_VERSION=$(./bin/ailog --version 2>/dev/null || echo "unknown")
|
||||||
echo "Current version: $CURRENT_VERSION"
|
echo "Current binary version: $CURRENT_VERSION"
|
||||||
else
|
else
|
||||||
CURRENT_VERSION="none"
|
CURRENT_VERSION="none"
|
||||||
echo "No binary found"
|
echo "No binary found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Download if version is different or binary doesn't exist
|
# Check OS
|
||||||
if [ "$CURRENT_VERSION" != "${LATEST_VERSION#v}" ]; then
|
OS="${{ runner.os }}"
|
||||||
echo "Downloading ailog $LATEST_VERSION..."
|
echo "Runner OS: $OS"
|
||||||
curl -sL -H "Authorization: Bearer $GITHUB_TOKEN" \
|
|
||||||
https://github.com/${{ github.repository }}/releases/download/$LATEST_VERSION/ailog-linux-x86_64.tar.gz | tar -xzf -
|
# Use pre-packaged binary if version matches or extract from tar.gz
|
||||||
mv ailog ./bin/ailog
|
if [ "$CURRENT_VERSION" = "$EXPECTED_VERSION" ]; then
|
||||||
chmod +x ./bin/ailog
|
|
||||||
echo "Updated to version: $(./bin/ailog --version 2>/dev/null)"
|
|
||||||
else
|
|
||||||
echo "Binary is up to date"
|
echo "Binary is up to date"
|
||||||
chmod +x ./bin/ailog
|
chmod +x ./bin/ailog
|
||||||
|
elif [ "$OS" = "Linux" ] && [ -f "./bin/ailog-linux-x86_64.tar.gz" ]; then
|
||||||
|
echo "Extracting ailog from pre-packaged tar.gz..."
|
||||||
|
cd bin
|
||||||
|
tar -xzf ailog-linux-x86_64.tar.gz
|
||||||
|
chmod +x ailog
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
# Verify extracted version
|
||||||
|
EXTRACTED_VERSION=$(./bin/ailog --version 2>/dev/null || echo "unknown")
|
||||||
|
echo "Extracted binary version: $EXTRACTED_VERSION"
|
||||||
|
|
||||||
|
if [ "$EXTRACTED_VERSION" != "$EXPECTED_VERSION" ]; then
|
||||||
|
echo "Warning: Binary version mismatch. Expected $EXPECTED_VERSION but got $EXTRACTED_VERSION"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Error: No suitable binary found for OS: $OS"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Setup Hugo
|
- name: Setup Hugo
|
||||||
@@ -66,12 +76,13 @@ jobs:
|
|||||||
TZ: "Asia/Tokyo"
|
TZ: "Asia/Tokyo"
|
||||||
run: |
|
run: |
|
||||||
# Use pre-built ailog binary instead of cargo build
|
# Use pre-built ailog binary instead of cargo build
|
||||||
./bin/ailog build --output ./public
|
cd my-blog
|
||||||
|
../bin/ailog build
|
||||||
touch ./public/.nojekyll
|
touch ./public/.nojekyll
|
||||||
|
|
||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
publish_dir: ./public
|
publish_dir: ./my-blog/public
|
||||||
publish_branch: gh-pages
|
publish_branch: gh-pages
|
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "ailog"
|
name = "ailog"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["syui"]
|
authors = ["syui"]
|
||||||
description = "A static blog generator with AI features"
|
description = "A static blog generator with AI features"
|
||||||
|
62
action.yml
62
action.yml
@@ -55,50 +55,27 @@ runs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
ailog-bin-${{ runner.os }}
|
ailog-bin-${{ runner.os }}
|
||||||
|
|
||||||
- name: Check and update ailog binary
|
- name: Setup ailog binary
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
# Get latest release version (for Gitea, adjust API endpoint if needed)
|
# Check if pre-built binary exists
|
||||||
if command -v curl >/dev/null 2>&1; then
|
if [ -f "./bin/ailog-linux-x86_64" ]; then
|
||||||
LATEST_VERSION=$(curl -s https://api.github.com/repos/syui/ailog/releases/latest | jq -r .tag_name 2>/dev/null || echo "v0.1.1")
|
echo "Using pre-built binary from repository"
|
||||||
|
chmod +x ./bin/ailog-linux-x86_64
|
||||||
|
CURRENT_VERSION=$(./bin/ailog-linux-x86_64 --version 2>/dev/null || echo "unknown")
|
||||||
|
echo "Binary version: $CURRENT_VERSION"
|
||||||
else
|
else
|
||||||
LATEST_VERSION="v0.1.1" # fallback version
|
echo "No pre-built binary found, trying to build from source..."
|
||||||
fi
|
|
||||||
echo "Target version: $LATEST_VERSION"
|
|
||||||
|
|
||||||
# Check current binary version if exists
|
|
||||||
mkdir -p ./bin
|
|
||||||
if [ -f "./bin/ailog" ]; then
|
|
||||||
CURRENT_VERSION=$(./bin/ailog --version 2>/dev/null || echo "unknown")
|
|
||||||
echo "Current version: $CURRENT_VERSION"
|
|
||||||
else
|
|
||||||
CURRENT_VERSION="none"
|
|
||||||
echo "No binary found"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Download if version is different or binary doesn't exist
|
|
||||||
if [ "$CURRENT_VERSION" != "${LATEST_VERSION#v}" ]; then
|
|
||||||
echo "Downloading ailog $LATEST_VERSION..."
|
|
||||||
# Try GitHub first, then fallback to local build
|
|
||||||
if curl -sL https://github.com/syui/ailog/releases/download/$LATEST_VERSION/ailog-linux-x86_64.tar.gz | tar -xzf - 2>/dev/null; then
|
|
||||||
mv ailog ./bin/ailog
|
|
||||||
chmod +x ./bin/ailog
|
|
||||||
echo "Downloaded binary: $(./bin/ailog --version 2>/dev/null)"
|
|
||||||
else
|
|
||||||
echo "Download failed, building from source..."
|
|
||||||
if command -v cargo >/dev/null 2>&1; then
|
if command -v cargo >/dev/null 2>&1; then
|
||||||
cargo build --release
|
cargo build --release
|
||||||
cp ./target/release/ailog ./bin/ailog
|
mkdir -p ./bin
|
||||||
echo "Built from source: $(./bin/ailog --version 2>/dev/null)"
|
cp ./target/release/ailog ./bin/ailog-linux-x86_64
|
||||||
|
echo "Built from source: $(./bin/ailog-linux-x86_64 --version 2>/dev/null)"
|
||||||
else
|
else
|
||||||
echo "Error: Neither download nor cargo build available"
|
echo "Error: No binary found and cargo not available"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
echo "Binary is up to date"
|
|
||||||
chmod +x ./bin/ailog
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Setup Node.js for OAuth app
|
- name: Setup Node.js for OAuth app
|
||||||
if: ${{ inputs.atproto-integration == 'true' }}
|
if: ${{ inputs.atproto-integration == 'true' }}
|
||||||
@@ -123,12 +100,15 @@ runs:
|
|||||||
run: |
|
run: |
|
||||||
start_time=$(date +%s)
|
start_time=$(date +%s)
|
||||||
|
|
||||||
./bin/ailog build \
|
# Change to blog directory and run build
|
||||||
--content ${{ inputs.content-dir }} \
|
# Note: ailog build only takes a path argument, not options
|
||||||
--output ${{ inputs.output-dir }} \
|
if [ -d "my-blog" ]; then
|
||||||
--templates ${{ inputs.template-dir }} \
|
cd my-blog
|
||||||
--static ${{ inputs.static-dir }} \
|
../bin/ailog-linux-x86_64 build
|
||||||
--config ${{ inputs.config-file }}
|
else
|
||||||
|
# If no my-blog directory, use current directory
|
||||||
|
./bin/ailog-linux-x86_64 build .
|
||||||
|
fi
|
||||||
|
|
||||||
end_time=$(date +%s)
|
end_time=$(date +%s)
|
||||||
build_time=$((end_time - start_time))
|
build_time=$((end_time - start_time))
|
||||||
|
BIN
bin/ailog-linux-x86_64.tar.gz
Normal file
BIN
bin/ailog-linux-x86_64.tar.gz
Normal file
Binary file not shown.
Reference in New Issue
Block a user