Last active
December 18, 2023 23:32
-
-
Save rafesposo/bb8ec873dc46eb6729f9e5fab74beb4f to your computer and use it in GitHub Desktop.
Generate a package with the files that were modified in the last commit.
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
#!/bin/sh | |
# ================================== | |
# Creators: @rafesposo | @dudecussi | |
# Date: 2022-12-16 | |
# Description: This script will generate a package with the files that were modified in the last commit. | |
# How to use: Copy this file to the .git/hooks folder and give it execution permissions. | |
# ================================== | |
branchPath=$(git symbolic-ref -q HEAD) | |
branch=${branchPath##*/} | |
commitHash=$(git rev-parse --short HEAD) | |
listFiles=$(git show --pretty="" --name-only $commitHash) | |
if [ "master" == "$branch" ]; then | |
echo "Generating package..." | |
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" | |
zip package/$commitHash.zip $listFiles | |
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" | |
echo "Creating changelog..." | |
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" | |
echo "-- CHANGELOG --" >> changelog-$commitHash.txt | |
git show --name-only -1 >> changelog-$commitHash.txt | |
zip -u package/$commitHash.zip changelog-$commitHash.txt | |
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" | |
echo "Package generated: package/$commitHash.zip" | |
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" | |
rm changelog-$commitHash.txt | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment