-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b87c76
commit dbe4be7
Showing
14 changed files
with
1,137 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
name: 🧪 Release | ||
|
||
on: | ||
push: | ||
branches: [main, feat/html-gen] | ||
pull_request: | ||
branches: [feat/html-gen] | ||
release: | ||
types: [created] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_API_TOKEN }} | ||
|
||
jobs: | ||
build: | ||
name: Build 🛠 | ||
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- os: windows-latest | ||
target: x86_64-pc-windows-msvc | ||
- os: windows-latest | ||
target: aarch64-pc-windows-msvc | ||
- os: macos-latest | ||
target: x86_64-apple-darwin | ||
- os: macos-latest | ||
target: aarch64-apple-darwin | ||
- os: ubuntu-latest | ||
target: x86_64-unknown-linux-gnu | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
target: ${{ matrix.target }} | ||
override: true | ||
- uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
target | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
- name: Build | ||
run: cargo build --verbose --release --target ${{ matrix.target }} | ||
- name: Package | ||
run: | | ||
if [ ! -d "target/package" ]; then | ||
mkdir -p target/package | ||
fi | ||
cd target/${{ matrix.target }}/release | ||
tar czf ../../package/${{ matrix.target }}.tar.gz * | ||
shell: bash | ||
|
||
- name: Package (Windows) | ||
if: matrix.os == 'windows-latest' | ||
run: | | ||
if (!(Test-Path "target/package")) { | ||
mkdir target/package | ||
} | ||
cd target/${{ matrix.target }}/release | ||
tar -czf ../../package/${{ matrix.target }}.tar.gz * | ||
shell: pwsh | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ matrix.target }} | ||
path: target/package/${{ matrix.target }}.tar.gz | ||
|
||
release: | ||
name: Release 🚀 | ||
needs: build | ||
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set version | ||
run: echo "VERSION=$(grep -m 1 '^version =' Cargo.toml | cut -d '"' -f 2)" >> $GITHUB_ENV | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
path: artifacts | ||
- name: Generate Changelog | ||
run: | | ||
echo "## Release v${VERSION} - $(date +'%Y-%m-%d')" > CHANGELOG.md | ||
cat TEMPLATE.md >> CHANGELOG.md | ||
git log --pretty=format:'%s' --reverse HEAD >> CHANGELOG.md | ||
echo "" >> CHANGELOG.md | ||
- uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: v${{ env.VERSION }} | ||
release_name: HTML Generator 🦀 v${{ env.VERSION }} | ||
body_path: CHANGELOG.md | ||
draft: true | ||
prerelease: false | ||
- name: Upload Release Assets | ||
run: | | ||
for asset in artifacts/*/*; do | ||
gh release upload v${{ env.VERSION }} "$asset" --clobber | ||
done | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
crate: | ||
name: Publish to Crates.io 🦀 | ||
needs: release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
override: true | ||
- name: Publish | ||
run: cargo publish --token ${CARGO_REGISTRY_TOKEN} | ||
env: | ||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,65 @@ | ||
// benches/html_benchmark.rs | ||
#![allow(missing_docs)] | ||
|
||
use criterion::{ | ||
black_box, criterion_group, criterion_main, Criterion, | ||
}; | ||
use html_generator::{ | ||
accessibility::add_aria_attributes, generate_html, | ||
performance::minify_html, seo::generate_meta_tags, | ||
utils::extract_front_matter, | ||
}; | ||
|
||
fn benchmark_generate_html(c: &mut Criterion) { | ||
let markdown_input = r#"# Benchmark Heading | ||
This is a test content for benchmarking HTML generation."#; | ||
let config = html_generator::HtmlConfig::default(); | ||
c.bench_function("generate_html", |b| { | ||
b.iter(|| generate_html(black_box(markdown_input), &config)) | ||
}); | ||
} | ||
|
||
fn benchmark_minify_html(c: &mut Criterion) { | ||
let html_input = | ||
r#"<html><head></head><body><h1>Test</h1></body></html>"#; | ||
let temp_file = tempfile::NamedTempFile::new().unwrap(); | ||
std::fs::write(temp_file.path(), html_input).unwrap(); | ||
c.bench_function("minify_html", |b| { | ||
b.iter(|| minify_html(black_box(temp_file.path()))) | ||
}); | ||
} | ||
|
||
fn benchmark_add_aria_attributes(c: &mut Criterion) { | ||
let html_input = r#"<button>Click Me</button>"#; | ||
c.bench_function("add_aria_attributes", |b| { | ||
b.iter(|| add_aria_attributes(black_box(html_input))) | ||
}); | ||
} | ||
|
||
fn benchmark_generate_meta_tags(c: &mut Criterion) { | ||
let html_input = r#"<html><head><title>Page Title</title></head><body><p>Content</p></body></html>"#; | ||
c.bench_function("generate_meta_tags", |b| { | ||
b.iter(|| generate_meta_tags(black_box(html_input))) | ||
}); | ||
} | ||
|
||
fn benchmark_extract_front_matter(c: &mut Criterion) { | ||
let input = r#"--- | ||
title: Test | ||
--- | ||
# Content | ||
This is the main content."#; | ||
c.bench_function("extract_front_matter", |b| { | ||
b.iter(|| extract_front_matter(black_box(input))) | ||
}); | ||
} | ||
|
||
criterion_group!( | ||
benches, | ||
benchmark_generate_html, | ||
benchmark_minify_html, | ||
benchmark_add_aria_attributes, | ||
benchmark_generate_meta_tags, | ||
benchmark_extract_front_matter | ||
); | ||
criterion_main!(benches); |
Oops, something went wrong.