Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated the project #1

Merged
merged 2 commits into from
Oct 13, 2024
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
47 changes: 47 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: 🔨 Build and Check PR 🚀

on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
# Step 1: Checkout the repository 📂
- name: 📥 Checkout repository
uses: actions/checkout@v4

# Step 2: Set up Zulu JDK 17 ☕
- name: ☕ Set up Zulu JDK 17
uses: actions/setup-java@v4
with:
java-version: '17' # Set the desired JDK version
distribution: 'zulu' # Specify Zulu as the distribution

# Step 3: Build the project 🔨
- name: 🔨 Run Gradle build
run: ./gradlew build --no-daemon

# Step 4: Create the shadow JAR 📦
- name: 🛠️ Build Shadow JAR
run: ./gradlew shadowJar --no-daemon

# Step 5: Get the name of the generated jar file
- name: 🧾 Get the shadowJar file name
id: get_jar_name
run: |
JAR_NAME=$(basename build/libs/*.jar)
echo "jar_name=$JAR_NAME" >> $GITHUB_ENV

# Step 6: Upload the shadowJar artifact (optional) 🎁
- name: 🎁 Upload shadowJar
uses: actions/upload-artifact@v4
with:
name: ${{ env.jar_name }}
path: build/libs/${{ env.jar_name }}
71 changes: 71 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Create Release 🎉

on:
push:
tags:
- 'v*' # Trigger on version tag pushes (e.g., v1.0, v2.0)

jobs:
build:
runs-on: ubuntu-latest

steps:
# Step 1: Checkout the repository
- name: 🛎️ Checkout code
uses: actions/checkout@v4

# Step 2: Set up JDK (using Zulu)
- name: ☕ Set up Zulu JDK 17
uses: actions/setup-java@v4
with:
java-version: '17' # Specify the JDK version
distribution: 'zulu'

# Step 3: Build the project and create shadowJar
- name: 🚧 Build with Gradle
run: ./gradlew shadowJar --no-daemon

# Step 4: Create a new release
- name: 📦 Create Release
id: create_release
uses: actions/github-script@v6
with:
script: |
const { exec } = require('child_process');
const { promises: fs } = require('fs');

// Get the latest tag
const tag = context.ref.replace('refs/tags/', '');

// Read the release notes if available
const releaseNotes = await fs.readFile('CHANGELOG.md', 'utf-8').catch(() => 'No release notes.');

// Create the release
const release = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: tag,
name: tag,
body: releaseNotes,
draft: false,
prerelease: false,
});

return release.data;

# Step 5: Upload the shadowJar artifact to the release
- name: 🎁 Upload shadowJar to Release
id: upload_jar
run: |
# Find the generated JAR file name
jar_file=$(ls build/libs/*.jar | grep -v '\-javadoc' | grep -v '\-sources' | head -n 1)
echo "Found JAR file: $jar_file"
echo "jar_file_name=$jar_file" >> $GITHUB_ENV

- name: 🎁 Upload shadowJar to Release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.jar_file_name }}
asset_name: ${{ env.jar_file_name }} # Use the dynamic name here
asset_content_type: application/java-archive
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
.idea/
.gradle/
*.iml
build/
toDelete
.DS_Store
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Changelog

## [Version 1.0]

### Added
- Flag-based operations for **find** and **delete** functionalities, allowing users to specify operations more clearly using command-line flags.

### Changed
- Organized the project structure using **Gradle**, making it easier to manage dependencies and build processes.

### Updated
- Integrated JAR file usage for executing the application, simplifying the running process for users.

### Removed
- Manual compilation steps are no longer required, enhancing user experience and reducing setup complexity.

### Examples
- **Find duplicates**:
```bash
java -jar search-and-delete-duplicates-1.0-SNAPSHOT.jar --find <directory1> <directory2> [...]
```

- **Delete files**:
```bash
java -jar search-and-delete-duplicates-1.0-SNAPSHOT.jar --delete <file>
```
54 changes: 0 additions & 54 deletions Deletion.java

This file was deleted.

23 changes: 0 additions & 23 deletions DuplicateDetails.java

This file was deleted.

43 changes: 0 additions & 43 deletions Files.java

This file was deleted.

Loading