Skip to content

Instantly share code, notes, and snippets.

@tadhgboyle
Last active November 6, 2022 16:48
Show Gist options
  • Select an option

  • Save tadhgboyle/fb3377a178468a34c14b8dd6567aed74 to your computer and use it in GitHub Desktop.

Select an option

Save tadhgboyle/fb3377a178468a34c14b8dd6567aed74 to your computer and use it in GitHub Desktop.

Revisions

  1. tadhgboyle revised this gist Nov 6, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nameless-release.sh
    Original file line number Diff line number Diff line change
    @@ -57,4 +57,4 @@ zip -r /tmp/$zipfile.zip ./ > /dev/null 2>&1
    echo "Deleting temp files..."
    rm -rf /tmp/Nameless
    rm -rf /tmp/$zipfile
    echo "Done!"
    echo "Done!"
  2. tadhgboyle created this gist Aug 9, 2022.
    60 changes: 60 additions & 0 deletions nameless-release.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,60 @@
    rm -rf /tmp/Nameless
    # clone the repo to a temp directory
    echo "Cloning repo..."
    git clone https://github.com/NamelessMC/Nameless.git /tmp/Nameless > /dev/null 2>&1

    cd /tmp/Nameless

    tag=$1

    if [ ! $(git tag -l "$tag") ]; then
    echo "Invalid tag '$tag'!"
    exit 1
    fi

    git checkout $tag > /dev/null 2>&1

    # get the previous tag
    prevtag=$(git describe --abbrev=0 --tags $tag^)
    echo "Found previous tag of '$prevtag'!"

    # zip file name is the tag without periods and v
    zipfile="update"$(echo $tag | sed 's/\.//g' | sed 's/\v//g')
    rm -rf /tmp/$zipfile

    echo "Installing assets..."
    composer install > /dev/null 2>&1
    yarnpkg > /dev/null 2>&1

    # get the diff files and make a folder
    echo "Calculating and splitting diff..."
    IFS=$'\n'
    for file_change in `git diff $prevtag $tag --name-only --diff-filter=d`
    do
    echo $file_change
    done | zip -@ /tmp/$zipfile.zip > /dev/null 2>&1

    # extract zip file
    unzip /tmp/$zipfile.zip -d /tmp/$zipfile > /dev/null 2>&1
    rm /tmp/$zipfile.zip

    # copy package.json and composer.json to the root of the zip file
    echo "Copying asset metadata..."
    cp /tmp/Nameless/package.json /tmp/$zipfile/package.json > /dev/null 2>&1
    cp /tmp/Nameless/composer.json /tmp/$zipfile/composer.json > /dev/null 2>&1
    mkdir -p /tmp/$zipfile/vendor
    cp -R /tmp/Nameless/vendor /tmp/$zipfile
    mkdir -p /tmp/$zipfile/core/assets/vendor
    cp -R /tmp/Nameless/core/assets/vendor /tmp/$zipfile/core/assets

    cd /tmp/$zipfile

    # zip the folder again
    echo "Creating update zip..."
    zip -r /tmp/$zipfile.zip ./ > /dev/null 2>&1

    # delete the temp directories
    echo "Deleting temp files..."
    rm -rf /tmp/Nameless
    rm -rf /tmp/$zipfile
    echo "Done!"