From 0be12a19b188aad06c63eeee58df02535578af4c Mon Sep 17 00:00:00 2001 From: Prashant Adhikari Date: Mon, 21 Jul 2025 22:49:47 +0545 Subject: [PATCH 1/3] Enhance release workflow with manual trigger and versioning logic based on commit analysis --- .github/workflows/release.yml | 141 ++++++++++++++++++++++++++-------- 1 file changed, 111 insertions(+), 30 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c38810c..5014508 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,6 +3,17 @@ name: Build and Release on: push: branches: [main] + workflow_dispatch: # Allow manual triggering + inputs: + release_type: + description: "Release type" + required: true + default: "patch" + type: choice + options: + - patch + - minor + - major env: APP_NAME: securebank @@ -167,9 +178,58 @@ jobs: # Split version into major.minor.patch IFS='.' read -r MAJOR MINOR PATCH <<< "$LATEST_TAG" - # Increment patch version for automatic releases - NEW_PATCH=$((PATCH + 1)) - NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH" + # Determine release type + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + # Manual trigger - use selected type + RELEASE_TYPE="${{ github.event.inputs.release_type }}" + echo "Manual release type: $RELEASE_TYPE" + else + # Automatic trigger - analyze commits since last release + echo "Analyzing commits for automatic version detection..." + + # Get commits since last tag + if git describe --tags --abbrev=0 2>/dev/null; then + LAST_TAG=$(git describe --tags --abbrev=0) + COMMITS=$(git log ${LAST_TAG}..HEAD --oneline) + else + COMMITS=$(git log --oneline) + fi + + echo "Commits to analyze:" + echo "$COMMITS" + + # Check for breaking changes (major) + if echo "$COMMITS" | grep -E "(BREAKING CHANGE|!:)" > /dev/null; then + RELEASE_TYPE="major" + echo "🚨 Breaking changes detected → MAJOR release" + # Check for new features (minor) + elif echo "$COMMITS" | grep -E "^[a-f0-9]+ feat(\(.*\))?:" > /dev/null; then + RELEASE_TYPE="minor" + echo "✨ New features detected → MINOR release" + # Default to patch for fixes, docs, chore, etc. + else + RELEASE_TYPE="patch" + echo "🔧 Bug fixes/improvements detected → PATCH release" + fi + fi + + echo "Final release type: $RELEASE_TYPE" + + # Increment version based on type + case $RELEASE_TYPE in + major) + NEW_MAJOR=$((MAJOR + 1)) + NEW_VERSION="$NEW_MAJOR.0.0" + ;; + minor) + NEW_MINOR=$((MINOR + 1)) + NEW_VERSION="$MAJOR.$NEW_MINOR.0" + ;; + patch|*) + NEW_PATCH=$((PATCH + 1)) + NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH" + ;; + esac echo "New version: v$NEW_VERSION" echo "version=v$NEW_VERSION" >> $GITHUB_OUTPUT @@ -188,41 +248,62 @@ jobs: done ls -la release-assets/ + - name: Generate custom release notes + id: release_notes + run: | + # Get commits since last release + if git describe --tags --abbrev=0 2>/dev/null; then + LAST_TAG=$(git describe --tags --abbrev=0) + COMMITS=$(git log --oneline ${LAST_TAG}..HEAD --pretty=format:"- %s (%h)") + else + COMMITS=$(git log --oneline --pretty=format:"- %s (%h)") + fi + + # Create release notes + cat << EOF > release_notes.md + # SecureBank C++ Banking Application ${{ steps.version.outputs.version }} + + ## 🚀 What's New + ${COMMITS} + + ## đŸ“Ļ Downloads + - **🐧 Linux:** [securebank-linux.tar.gz](https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.version }}/securebank-linux.tar.gz) — Extract and run \`./crow_bank_app\` + - **đŸĒŸ Windows:** [securebank-windows.zip](https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.version }}/securebank-windows.zip) — Extract and run \`crow_bank_app.exe\` + + ## đŸ› ī¸ Quick Start + \`\`\`sh + # Linux + tar -xzf securebank-linux.tar.gz && cd securebank-linux/ + ./crow_bank_app + + # Windows - Extract zip file then: + crow_bank_app.exe + \`\`\` + Open your browser to [http://localhost:8080](http://localhost:8080) + + ## 🔧 System Requirements + - **Linux:** Ubuntu 18.04+ or equivalent, 64-bit + - **Windows:** Windows 10+ or Windows Server 2019+, 64-bit + - **Memory:** 512MB RAM minimum + - **Storage:** 50MB free space + + --- + *For major releases and new features, see our [release history](https://github.com/${{ github.repository }}/releases).* + EOF + + echo "Generated release notes:" + cat release_notes.md + - name: Create Release uses: softprops/action-gh-release@v2 with: tag_name: ${{ steps.version.outputs.version }} name: SecureBank ${{ steps.version.outputs.version }} - body: | - # SecureBank C++ Banking Application ${{ steps.version.outputs.version }} - - ## đŸ“Ļ Downloads - - **🐧 Linux:** [securebank-linux.tar.gz](https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.version }}/securebank-linux.tar.gz) — Extract and run `./crow_bank_app` - - **đŸĒŸ Windows:** [securebank-windows.zip](https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.version }}/securebank-windows.zip) — Extract and run `crow_bank_app.exe` - - ## đŸ› ī¸ Quick Start - ```sh - # Linux - tar -xzf securebank-linux.tar.gz && cd securebank-linux/ - ./crow_bank_app - - # Windows - Extract zip file then: - crow_bank_app.exe - ``` - Open your browser to [http://localhost:8080](http://localhost:8080) - - ## 🔧 System Requirements - - **Linux:** Ubuntu 18.04+ or equivalent, 64-bit - - **Windows:** Windows 10+ or Windows Server 2019+, 64-bit - - **Memory:** 512MB RAM minimum - - **Storage:** 50MB free space - - --- - *For major releases and new features, see our [release history](https://github.com/ITx-prash/securebank-cpp/releases).* + body_path: release_notes.md files: release-assets/* draft: false prerelease: false - generate_release_notes: true + generate_release_notes: false make_latest: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From f74571b17a76fde86c90eccca984f1a9fd438ed2 Mon Sep 17 00:00:00 2001 From: Prashant Adhikari Date: Sat, 2 Aug 2025 00:49:17 +0545 Subject: [PATCH 2/3] Refactor icon display logic for Windows and remove unnecessary text from menus --- crow-bank-app/main.cpp | 128 +++++++++++------------------------------ 1 file changed, 32 insertions(+), 96 deletions(-) diff --git a/crow-bank-app/main.cpp b/crow-bank-app/main.cpp index bcf385a..a393543 100644 --- a/crow-bank-app/main.cpp +++ b/crow-bank-app/main.cpp @@ -341,99 +341,38 @@ string get_file_path(const string &relative_path) string getIcon(const string &iconType) { #ifdef _WIN32 - // Windows - Smart emoji detection - // Check for Windows Terminal or modern terminal capabilities - static bool useEmojis = []() - { - // Check environment variables that indicate modern terminal - const char *wt_session = getenv("WT_SESSION"); // Windows Terminal - const char *term_program = getenv("TERM_PROGRAM"); // VS Code terminal, etc. - const char *colorterm = getenv("COLORTERM"); // Modern terminals - const char *force_emojis = getenv("FORCE_EMOJIS"); // User override - const char *no_emojis = getenv("NO_EMOJIS"); // User disable - - // User explicitly disabled emojis - if (no_emojis) - return false; - - // User explicitly enabled emojis - if (force_emojis) - return true; - - // Detect modern terminal environment - return (wt_session || term_program || colorterm); - }(); - - if (useEmojis) - { - // Unicode emojis for modern Windows terminals - if (iconType == "bank") - return "đŸĻ"; - if (iconType == "register") - return "📝"; - if (iconType == "login") - return "🔐"; - if (iconType == "help") - return "❓"; - if (iconType == "exit") - return "đŸšĒ"; - if (iconType == "deposit") - return "💰"; - if (iconType == "withdraw") - return "💸"; - if (iconType == "balance") - return "đŸ’ŗ"; - if (iconType == "history") - return "📊"; - if (iconType == "transfer") - return "🔄"; - if (iconType == "settings") - return "âš™ī¸"; - if (iconType == "logout") - return "đŸšĒ"; - if (iconType == "success") - return "✅"; - if (iconType == "error") - return "❌"; - if (iconType == "warning") - return "âš ī¸"; - return "â€ĸ"; - } - else - { - // Windows fallback - basic ASCII characters only - if (iconType == "bank") - return ""; - if (iconType == "register") - return ""; - if (iconType == "login") - return ""; - if (iconType == "help") - return ""; - if (iconType == "exit") - return ""; - if (iconType == "deposit") - return ""; - if (iconType == "withdraw") - return ""; - if (iconType == "balance") - return ""; - if (iconType == "history") - return ""; - if (iconType == "transfer") - return ""; - if (iconType == "settings") - return ""; - if (iconType == "logout") - return ""; - if (iconType == "success") - return "[OK]"; - if (iconType == "error") - return "[ERROR]"; - if (iconType == "warning") - return "[WARNING]"; + // Windows - Clean text without icons for better appearance + if (iconType == "bank") return ""; - } + if (iconType == "register") + return ""; + if (iconType == "login") + return ""; + if (iconType == "help") + return ""; + if (iconType == "exit") + return ""; + if (iconType == "deposit") + return ""; + if (iconType == "withdraw") + return ""; + if (iconType == "balance") + return ""; + if (iconType == "history") + return ""; + if (iconType == "transfer") + return ""; + if (iconType == "settings") + return ""; + if (iconType == "logout") + return ""; + if (iconType == "success") + return "[SUCCESS]"; + if (iconType == "error") + return "[ERROR]"; + if (iconType == "warning") + return "[WARNING]"; + return ""; #else // Linux/Unix - Unicode emojis if (iconType == "bank") @@ -929,7 +868,6 @@ string read_file(const string &filename) // Main CLI authentication menu void displayAuthMenu() { - cout << "Made with <3\n\n"; cout << "==============================================\n"; cout << " " << getIcon("bank") << " SECURE BANK CLI SYSTEM \n"; cout << "==============================================\n"; @@ -945,7 +883,6 @@ void displayAuthMenu() // Banking dashboard menu (after login) void displayBankingMenu(const string &userName) { - cout << "Made with <3\n\n"; cout << "==============================================\n"; cout << " " << getIcon("bank") << " WELCOME " << userName << "\n"; cout << "==============================================\n"; @@ -1453,7 +1390,6 @@ void runCLI() void displayWelcomeScreen() { - cout << "Made with <3\n\n"; cout << "========================================\n"; cout << " " << getIcon("bank") << " SECURE BANK SYSTEM \n"; cout << "========================================\n"; @@ -1555,7 +1491,7 @@ int main(int argc, char *argv[]) case 3: { // Exit clearScreen(); - cout << "\nīŋŊ Thank you for exploring SecureBank!\n"; + cout << "\n" << getIcon("exit") << " Thank you for exploring SecureBank!\n"; return 0; } From dac4e012607f21586b0283e6c211566b2550f4cb Mon Sep 17 00:00:00 2001 From: Prashant Adhikari <78313801+ITx-prash@users.noreply.github.com> Date: Sat, 2 Aug 2025 01:04:54 +0545 Subject: [PATCH 3/3] Update release.yml --- .github/workflows/release.yml | 141 ++++++++-------------------------- 1 file changed, 30 insertions(+), 111 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5014508..c38810c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,17 +3,6 @@ name: Build and Release on: push: branches: [main] - workflow_dispatch: # Allow manual triggering - inputs: - release_type: - description: "Release type" - required: true - default: "patch" - type: choice - options: - - patch - - minor - - major env: APP_NAME: securebank @@ -178,58 +167,9 @@ jobs: # Split version into major.minor.patch IFS='.' read -r MAJOR MINOR PATCH <<< "$LATEST_TAG" - # Determine release type - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - # Manual trigger - use selected type - RELEASE_TYPE="${{ github.event.inputs.release_type }}" - echo "Manual release type: $RELEASE_TYPE" - else - # Automatic trigger - analyze commits since last release - echo "Analyzing commits for automatic version detection..." - - # Get commits since last tag - if git describe --tags --abbrev=0 2>/dev/null; then - LAST_TAG=$(git describe --tags --abbrev=0) - COMMITS=$(git log ${LAST_TAG}..HEAD --oneline) - else - COMMITS=$(git log --oneline) - fi - - echo "Commits to analyze:" - echo "$COMMITS" - - # Check for breaking changes (major) - if echo "$COMMITS" | grep -E "(BREAKING CHANGE|!:)" > /dev/null; then - RELEASE_TYPE="major" - echo "🚨 Breaking changes detected → MAJOR release" - # Check for new features (minor) - elif echo "$COMMITS" | grep -E "^[a-f0-9]+ feat(\(.*\))?:" > /dev/null; then - RELEASE_TYPE="minor" - echo "✨ New features detected → MINOR release" - # Default to patch for fixes, docs, chore, etc. - else - RELEASE_TYPE="patch" - echo "🔧 Bug fixes/improvements detected → PATCH release" - fi - fi - - echo "Final release type: $RELEASE_TYPE" - - # Increment version based on type - case $RELEASE_TYPE in - major) - NEW_MAJOR=$((MAJOR + 1)) - NEW_VERSION="$NEW_MAJOR.0.0" - ;; - minor) - NEW_MINOR=$((MINOR + 1)) - NEW_VERSION="$MAJOR.$NEW_MINOR.0" - ;; - patch|*) - NEW_PATCH=$((PATCH + 1)) - NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH" - ;; - esac + # Increment patch version for automatic releases + NEW_PATCH=$((PATCH + 1)) + NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH" echo "New version: v$NEW_VERSION" echo "version=v$NEW_VERSION" >> $GITHUB_OUTPUT @@ -248,62 +188,41 @@ jobs: done ls -la release-assets/ - - name: Generate custom release notes - id: release_notes - run: | - # Get commits since last release - if git describe --tags --abbrev=0 2>/dev/null; then - LAST_TAG=$(git describe --tags --abbrev=0) - COMMITS=$(git log --oneline ${LAST_TAG}..HEAD --pretty=format:"- %s (%h)") - else - COMMITS=$(git log --oneline --pretty=format:"- %s (%h)") - fi - - # Create release notes - cat << EOF > release_notes.md - # SecureBank C++ Banking Application ${{ steps.version.outputs.version }} - - ## 🚀 What's New - ${COMMITS} - - ## đŸ“Ļ Downloads - - **🐧 Linux:** [securebank-linux.tar.gz](https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.version }}/securebank-linux.tar.gz) — Extract and run \`./crow_bank_app\` - - **đŸĒŸ Windows:** [securebank-windows.zip](https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.version }}/securebank-windows.zip) — Extract and run \`crow_bank_app.exe\` - - ## đŸ› ī¸ Quick Start - \`\`\`sh - # Linux - tar -xzf securebank-linux.tar.gz && cd securebank-linux/ - ./crow_bank_app - - # Windows - Extract zip file then: - crow_bank_app.exe - \`\`\` - Open your browser to [http://localhost:8080](http://localhost:8080) - - ## 🔧 System Requirements - - **Linux:** Ubuntu 18.04+ or equivalent, 64-bit - - **Windows:** Windows 10+ or Windows Server 2019+, 64-bit - - **Memory:** 512MB RAM minimum - - **Storage:** 50MB free space - - --- - *For major releases and new features, see our [release history](https://github.com/${{ github.repository }}/releases).* - EOF - - echo "Generated release notes:" - cat release_notes.md - - name: Create Release uses: softprops/action-gh-release@v2 with: tag_name: ${{ steps.version.outputs.version }} name: SecureBank ${{ steps.version.outputs.version }} - body_path: release_notes.md + body: | + # SecureBank C++ Banking Application ${{ steps.version.outputs.version }} + + ## đŸ“Ļ Downloads + - **🐧 Linux:** [securebank-linux.tar.gz](https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.version }}/securebank-linux.tar.gz) — Extract and run `./crow_bank_app` + - **đŸĒŸ Windows:** [securebank-windows.zip](https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.version }}/securebank-windows.zip) — Extract and run `crow_bank_app.exe` + + ## đŸ› ī¸ Quick Start + ```sh + # Linux + tar -xzf securebank-linux.tar.gz && cd securebank-linux/ + ./crow_bank_app + + # Windows - Extract zip file then: + crow_bank_app.exe + ``` + Open your browser to [http://localhost:8080](http://localhost:8080) + + ## 🔧 System Requirements + - **Linux:** Ubuntu 18.04+ or equivalent, 64-bit + - **Windows:** Windows 10+ or Windows Server 2019+, 64-bit + - **Memory:** 512MB RAM minimum + - **Storage:** 50MB free space + + --- + *For major releases and new features, see our [release history](https://github.com/ITx-prash/securebank-cpp/releases).* files: release-assets/* draft: false prerelease: false - generate_release_notes: false + generate_release_notes: true make_latest: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}