Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions .github/workflows/develop-to-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Develop to Release

on:
push:
branches:
- develop

jobs:
analyze-and-create-release-pr:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Determine version bump
id: version
run: |
# Pega a última tag
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
echo "Last tag: $LAST_TAG"

# Remove 'v' prefix
LAST_VERSION=${LAST_TAG#v}
IFS='.' read -ra VERSION_PARTS <<< "$LAST_VERSION"
MAJOR=${VERSION_PARTS[0]:-0}
MINOR=${VERSION_PARTS[1]:-0}
PATCH=${VERSION_PARTS[2]:-0}

# Analisa commits desde a última tag
COMMITS=$(git log ${LAST_TAG}..HEAD --pretty=format:"%s" 2>/dev/null || git log --pretty=format:"%s")

# Determina o tipo de bump baseado em conventional commits
if echo "$COMMITS" | grep -qiE "^(BREAKING CHANGE|feat!|fix!):"; then
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
BUMP_TYPE="major"
elif echo "$COMMITS" | grep -qiE "^feat(\(.+\))?:"; then
MINOR=$((MINOR + 1))
PATCH=0
BUMP_TYPE="minor"
else
PATCH=$((PATCH + 1))
BUMP_TYPE="patch"
fi

NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "bump_type=$BUMP_TYPE" >> $GITHUB_OUTPUT
echo "New version will be: v$NEW_VERSION (${BUMP_TYPE})"

- name: Create or update release branch
env:
NEW_VERSION: ${{ steps.version.outputs.new_version }}
run: |
RELEASE_BRANCH="release/v${NEW_VERSION}"

# Verifica se a branch já existe
if git ls-remote --heads origin "$RELEASE_BRANCH" | grep -q "$RELEASE_BRANCH"; then
echo "Branch $RELEASE_BRANCH já existe, atualizando..."
git fetch origin "$RELEASE_BRANCH"
git checkout "$RELEASE_BRANCH"
git merge origin/develop --no-edit
else
echo "Criando nova branch $RELEASE_BRANCH"
git checkout -b "$RELEASE_BRANCH"
fi

git push origin "$RELEASE_BRANCH"
echo "RELEASE_BRANCH=$RELEASE_BRANCH" >> $GITHUB_ENV

- name: Check if PR exists
id: check-pr
env:
GH_TOKEN: ${{ github.token }}
NEW_VERSION: ${{ steps.version.outputs.new_version }}
run: |
RELEASE_BRANCH="release/v${NEW_VERSION}"
PR_EXISTS=$(gh pr list --head "$RELEASE_BRANCH" --base main --json number --jq 'length')
if [ "$PR_EXISTS" -gt 0 ]; then
PR_NUMBER=$(gh pr list --head "$RELEASE_BRANCH" --base main --json number --jq '.[0].number')
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
fi
echo "pr_exists=$PR_EXISTS" >> $GITHUB_OUTPUT

- name: Create or update PR to main
env:
GH_TOKEN: ${{ github.token }}
NEW_VERSION: ${{ steps.version.outputs.new_version }}
BUMP_TYPE: ${{ steps.version.outputs.bump_type }}
run: |
RELEASE_BRANCH="release/v${NEW_VERSION}"

if [ "${{ steps.check-pr.outputs.pr_exists }}" -eq 0 ]; then
# Cria novo PR com template
gh pr create \
--base main \
--head "$RELEASE_BRANCH" \
--title "Release v${NEW_VERSION}" \
--body "## 🚀 Release v${NEW_VERSION}

**Bump type:** ${BUMP_TYPE}

### ⚙️ Release Configuration

**Antes de mergear, responda:**

\`\`\`
Release Type: [alpha/beta/lts]
\`\`\`

_Por favor, edite este PR e substitua o placeholder acima com:_
- \`alpha\` - Para releases alpha (instável, desenvolvimento)
- \`beta\` - Para releases beta (pré-release, testes)
- \`lts\` - Para releases estáveis de longo prazo

### 📝 Changelog

$(git log --pretty=format:'- %s (%h)' origin/main..HEAD | head -20)

---

_Este PR foi gerado automaticamente pelo workflow develop-to-release_" \
--draft

echo "✅ PR criado: release/v${NEW_VERSION} → main"
else
echo "ℹ️ PR já existe (#${{ steps.check-pr.outputs.pr_number }}), atualizando..."
fi
73 changes: 73 additions & 0 deletions .github/workflows/feature-fix-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Feature/Fix Workflow

on:
push:
branches:
- "feature/**"
- "fix/**"

jobs:
build-and-test:
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@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo index
uses: actions/cache@v3
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}

- name: Build
run: cargo build --release --all-features

- name: Run tests
run: cargo test --all-features

create-pr-to-develop:
needs: build-and-test
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read
steps:
- uses: actions/checkout@v4

- name: Check if PR already exists
id: check-pr
env:
GH_TOKEN: ${{ github.token }}
run: |
BRANCH_NAME="${{ github.ref_name }}"
PR_EXISTS=$(gh pr list --head "$BRANCH_NAME" --base develop --json number --jq 'length')
echo "pr_exists=$PR_EXISTS" >> $GITHUB_OUTPUT

- name: Create Pull Request to develop
if: steps.check-pr.outputs.pr_exists == '0'
env:
GH_TOKEN: ${{ github.token }}
run: |
gh pr create \
--base develop \
--head ${{ github.ref_name }} \
--title "[${{ github.ref_name }}] Merge to develop" \
--body "## Automated PR

✅ Build: Passed
✅ Tests: Passed

Branch: \`${{ github.ref_name }}\`
Commit: ${{ github.sha }}" \
--reviewer ""
110 changes: 110 additions & 0 deletions .github/workflows/release-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Release Workflow

on:
pull_request:
types: [closed]
branches:
- main

jobs:
create-release:
if: |
github.event.pull_request.merged == true &&
startsWith(github.event.pull_request.head.ref, 'release/')
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Extract version and release type
id: extract
run: |
# Extrai versão do nome da branch
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
VERSION=$(echo "$BRANCH_NAME" | sed 's/release\/v//')
echo "version=$VERSION" >> $GITHUB_OUTPUT

# Extrai tipo de release do corpo do PR
PR_BODY="${{ github.event.pull_request.body }}"
RELEASE_TYPE=$(echo "$PR_BODY" | grep -oP "Release Type:\s*\K(alpha|beta|lts)" || echo "lts")
echo "release_type=$RELEASE_TYPE" >> $GITHUB_OUTPUT

# Monta tag completa
if [ "$RELEASE_TYPE" = "lts" ]; then
FULL_TAG="v${VERSION}"
else
FULL_TAG="v${VERSION}-${RELEASE_TYPE}"
fi
echo "full_tag=$FULL_TAG" >> $GITHUB_OUTPUT

echo "Version: $VERSION"
echo "Release Type: $RELEASE_TYPE"
echo "Full Tag: $FULL_TAG"

- name: Build release artifacts
run: |
cargo build --release
mkdir -p artifacts
cp target/release/* artifacts/ 2>/dev/null || true

- name: Create and push tag
env:
FULL_TAG: ${{ steps.extract.outputs.full_tag }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "$FULL_TAG" -m "Release $FULL_TAG"
git push origin "$FULL_TAG"

- name: Generate changelog
id: changelog
run: |
LAST_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -z "$LAST_TAG" ]; then
CHANGELOG=$(git log --pretty=format:"- %s (%h)" | head -50)
else
CHANGELOG=$(git log ${LAST_TAG}..HEAD --pretty=format:"- %s (%h)")
fi

# Salva changelog em arquivo
echo "$CHANGELOG" > /tmp/changelog.txt
echo "changelog_file=/tmp/changelog.txt" >> $GITHUB_OUTPUT

- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
FULL_TAG: ${{ steps.extract.outputs.full_tag }}
VERSION: ${{ steps.extract.outputs.version }}
RELEASE_TYPE: ${{ steps.extract.outputs.release_type }}
run: |
PRERELEASE_FLAG=""
if [ "$RELEASE_TYPE" = "alpha" ] || [ "$RELEASE_TYPE" = "beta" ]; then
PRERELEASE_FLAG="--prerelease"
fi

# Lê o changelog
CHANGELOG=$(cat /tmp/changelog.txt)

# Cria a release
gh release create "$FULL_TAG" \
--title "Release $FULL_TAG" \
--notes "## 🎉 Release $VERSION ($RELEASE_TYPE)

### 📦 Type: ${RELEASE_TYPE^^}

### 📝 Changes

$CHANGELOG

---

Released on: $(date +'%Y-%m-%d %H:%M:%S UTC')
" \
$PRERELEASE_FLAG \
artifacts/* 2>/dev/null || true

echo "✅ Release $FULL_TAG criada com sucesso!"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
target
.lsm_data
stress*
/examples/*.json
credentials
16 changes: 4 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "lsm-kv-store"
version = "0.1.0"
edition = "2021"
authors = ["Elío Neto <seu@email.com>"]
authors = ["Elio Neto <seuemail.com>"]
description = "High-performance Key-Value Store using LSM-Tree architecture"
repository = "https://github.com/ElioNeto/lsm-kv-store"

Expand All @@ -11,6 +11,7 @@ repository = "https://github.com/ElioNeto/lsm-kv-store"
serde = { version = "1.0", features = ["derive"] }
serde_derive = "1.0"
bincode = "1.3.3"
serde_json = "1.0"

# Checksum & Bloom Filter
crc32fast = "1.3"
Expand All @@ -23,11 +24,10 @@ thiserror = "1.0"
tracing = "0.1"
tracing-subscriber = "0.3"

# HTTP Server (opcionais - apenas se feature "api" estiver ativa)
# HTTP Server (opcionais)
actix-web = { version = "4", optional = true }
actix-cors = { version = "0.7", optional = true }
tokio = { version = "1", features = ["full"], optional = true }
serde_json = { version = "1.0", optional = true }

[dev-dependencies]
criterion = "0.5"
Expand All @@ -42,10 +42,6 @@ codegen-units = 1
[profile.dev]
opt-level = 0

[lib]
name = "lsm_kv_store"
path = "src/lib.rs"

[[bin]]
name = "lsm-kv-store"
path = "src/main.rs"
Expand All @@ -55,10 +51,6 @@ name = "lsm-server"
path = "src/bin/server.rs"
required-features = ["api"]

[[bin]]
name = "server"
path = "src/server.rs"

[features]
default = []
api = ["actix-web", "actix-cors", "tokio", "serde_json"]
api = ["actix-web", "actix-cors", "tokio"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ Contributions are welcome! Priority areas for v1 → v2 transition:
**Contribution workflow:**

1. Fork repository
2. Create feature branch: `git checkout -b feat/my-feature`
2. Create feature branch: `git checkout -b feature/my-feature`
3. Commit changes with clear messages
4. Run tests and linters
5. Open Pull Request with detailed description
Expand Down
Loading
Loading