Skip to content

Commit

Permalink
added GitHub workflow
Browse files Browse the repository at this point in the history
* Workflow to check PR
* Workflow to release build
* Added CHANGELOG.md
* Updated related build tasks
  • Loading branch information
krrishnaaaa committed Oct 13, 2024
1 parent a81c601 commit 575d20d
Show file tree
Hide file tree
Showing 6 changed files with 231 additions and 37 deletions.
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 }}
79 changes: 79 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: 🚀✨ Create Fun Release with JAR Upload 🎉

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 17 (using Zulu) ☕
- name: ☕🧙‍♂️ Set up Zulu JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'

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

# Step 4: Get the JAR file name 📁
- name: 📁🔍 Get JAR file name
id: jar-name
run: |
JAR_FILE=$(ls build/libs/*.jar)
echo "jar_file=$JAR_FILE" >> $GITHUB_ENV
# Step 5: Create a new release 📦
- name: 📦🎉 Create GitHub Release
id: create_release
uses: actions/github-script@v7
with:
script: |
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,
});
core.setOutput('release_id', release.data.id);
# Step 6: Download and install `ghr` tool 🔧
- name: 🔧⚡ Download and Install ghr tool
run: |
GHR_VERSION="v0.16.2" # Specify the version you want to install
wget https://github.com/tcnksm/ghr/releases/download/$GHR_VERSION/ghr_${GHR_VERSION}_linux_amd64.tar.gz
tar -xzf ghr_${GHR_VERSION}_linux_amd64.tar.gz
sudo mv ghr_${GHR_VERSION}_linux_amd64/ghr /usr/local/bin/
ghr --version
# Step 7: Upload the JAR to the release 🏗️📦
- name: 🚀📦 Upload JAR to GitHub Release
run: |
ghr -u "${GITHUB_REPOSITORY%/*}" \
-r "${GITHUB_REPOSITORY#*/}" \
"${GITHUB_REF#refs/tags/}" \
"${{ env.jar_file }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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>
```
104 changes: 67 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,81 @@
Search-and-Delete-duplicate-files
=================================

Prerequisites:
1. JDK must be installed, and
2. Path environments must be set.
This tool scans specified directories for duplicate files, automatically excluding common project and system directories. It helps users reclaim disk space by identifying and removing redundant files with ease.

How to use this?
## Prerequisites

Follow the steps to use it:
Step 1: Clone the repo
Step 2: Open `Terminal` or `Command Prompt`
Step 3: Navigate to the cloned repo
Step 4: Compile code `javac *.java`
Step 5: Run `java ListFiles <root-directory-to-search-duplicate-entries>`
Step 6: After processing is completed a file will be generated with list of
duplicate files. Open the file and REMOVE THE ENTRIES WHICH YOU WANT TO KEEP.
Step 7: Run 'java Deletion <file-location>`
1. **JDK 17** must be installed.
2. Path environments must be set.

Now it will delete all those files listed in `toDelete` file.
## How to use this

NOTE:
1. File once deleted cannot be recovered. They will be deleted permanently.
So, be careful while using `Deletion`.
2. Whenever you want to escape press <ctrl>+c [^c] to exit.
Follow the steps to use it:

Java source code to search a directory, recursively, for duplicate files. Well, this code is not commented, but feel
free to query.
1. Download the JAR file: `search-and-delete-duplicates-1.0-SNAPSHOT.jar`.
2. Open `Terminal` or `Command Prompt`.
3. Run the command to find duplicates:
```shell
java -jar search-and-delete-duplicates-1.0-SNAPSHOT.jar --find <root-directory-to-search-duplicate-entries>
```
4. After processing is completed, a file will be generated with a list of duplicate files. Open the file and REMOVE THE ENTRIES WHICH YOU WANT TO KEEP.
5. To delete the files listed in the `toDelete` file, run:
```shell
java -jar search-and-delete-duplicates-1.0-SNAPSHOT.jar --delete <file-location>
```

Feel free to reorganize code, and distribute your own version. I would be happy if you could state your name and
application, in which this code is used.
## Usage
```shell
java -jar search-and-delete-duplicates-1.0-SNAPSHOT.jar --find <directory1> <directory2> [...]
java -jar search-and-delete-duplicates-1.0-SNAPSHOT.jar --delete <file>
```

Send email with following details:
## Examples
```shell
java -jar search-and-delete-duplicates-1.0-SNAPSHOT.jar --find ~/dir1 ~/dir2
java -jar search-and-delete-duplicates-1.0-SNAPSHOT.jar --delete toDelete.txt
```

To: krishna[at]pcsalt[dot]com
Subject: [Search-and-Delete-duplicate-files]
Message: [Name] [Application-Name]
## NOTE
1. File once deleted cannot be recovered. They will be deleted permanently. So, be careful while using `Deletion`.
2. Whenever you want to escape, press `<ctrl>+c` [^c] to exit.

## Ignored Directories and Files

When the program searches for duplicate files, it ignores specific directories and files to streamline the process and avoid unnecessary scanning of commonly used directories.

### Ignored Directories
The following directories are excluded from the search:
- **.git**: This directory is used for version control by Git, and its contents are not relevant to duplicate file searching.
- **build**: This directory often contains compiled files generated during the build process, which are not considered duplicates.
- **node_modules**: This directory is used by Node.js projects to store dependencies and is typically large, so it is ignored.
- **.gradle**: This directory contains Gradle-specific files and caches, which do not need to be scanned.
- **.idea**: This directory is used by JetBrains IDEs (like IntelliJ IDEA) to store project-specific settings and configurations.

### Ignored Files
The program also ignores the following file:
- **.DS_Store**: This is a file created by macOS to store custom attributes of a folder, and it is not useful for the duplicate file search.

By excluding these directories and files, the program focuses on relevant files, enhancing performance and accuracy.

Feel free to reorganize the code and distribute your own version. I would be happy if you could state your name and application in which this code is used.

Send email with the following details:

- **To:** krishna[at]pcsalt[dot]com
- **Subject:** [Search-and-Delete-duplicate-files]
- **Message:** [your-text]

Thank you.

Copyright 2014 Krrishnaaaa
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
## License
Copyright 2014 Krrishnaaaa

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
12 changes: 12 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,16 @@ tasks {
archiveClassifier.set("")
archiveVersion.set("1.0-SNAPSHOT")
}
}

tasks.named("startShadowScripts") {
dependsOn(tasks.named("jar"))
}

tasks.named("startScripts") {
dependsOn(tasks.named("shadowJar"))
}

tasks.named("distTar") {
dependsOn(tasks.named("shadowJar"))
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.

0 comments on commit 575d20d

Please sign in to comment.