summaryrefslogtreecommitdiff
path: root/build/windows/finalize-install-package.sh
blob: 0996e3ed5813b18aaeef044ca7c23838316eec47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash

##########
## Read config
##########
# get SMAPI version
version="$1"
if [ $# -eq 0 ]; then
    echo "SMAPI release version (like '4.0.0'):"
    read version
fi

# get Windows bin path
windowsBinPath="$2"
if [ $# -le 1 ]; then
    echo "Windows compiled bin path:"
    read windowsBinPath
fi

# installer internal folders
buildFolders=("linux" "macOS" "windows")


##########
## Finalize release package
##########
for folderName in "SMAPI $version installer" "SMAPI $version installer for developers"; do
    # move files to Linux filesystem
    echo "Preparing $folderName.zip..."
    echo "-------------------------------------------------"
    echo "copying '$windowsBinPath/$folderName' to Linux filesystem..."
    cp -r "$windowsBinPath/$folderName" .

    # fix permissions
    echo "fixing permissions..."
    find "$folderName" -type d -exec chmod 755 {} \;
    find "$folderName" -type f -exec chmod 644 {} \;
    find "$folderName" -name "*.sh" -exec chmod 755 {} \;
    find "$folderName" -name "*.command" -exec chmod 755 {} \;
    find "$folderName" -name "SMAPI.Installer" -exec chmod 755 {} \;
    find "$folderName" -name "StardewModdingAPI" -exec chmod 755 {} \;

    # convert bundle folder into final 'install.dat' files
    for build in ${buildFolders[@]}; do
        echo "packaging $folderName/internal/$build/install.dat..."
        pushd "$folderName/internal/$build/bundle" > /dev/null
        zip "install.dat" * --recurse-paths --quiet
        mv install.dat ../
        popd > /dev/null

        rm -rf "$folderName/internal/$build/bundle"
    done

    # zip installer
    echo "packaging installer..."
    zip -9 "$folderName.zip" "$folderName" --recurse-paths --quiet

    # move zip back to Windows bin path
    echo "moving release zip to $windowsBinPath/$folderName.zip..."
    mv "$folderName.zip" "$windowsBinPath"
    rm -rf "$folderName"

    echo ""
    echo ""
done

echo "Done!"