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

Add Bash script for building Chocolatey package #20

Open
philippgille opened this issue May 21, 2018 · 0 comments
Open

Add Bash script for building Chocolatey package #20

philippgille opened this issue May 21, 2018 · 0 comments
Labels
enhancement New feature or request

Comments

@philippgille
Copy link
Owner

For executing in Linux or a Docker container with Mono installed.

Like this:

#!/bin/bash

# Builds the Chocolatey package if the Windows x64 binary exists.
# Uses Chocolatey via Mono
# Is intended to be used inside a linuturk/mono-choco Docker container

# No "-o pipefail" option for the bash script,
# because when used in the .NET Core SDK Docker container this leads to "invalid option name: pipefail".
set -eux

SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
APPNAME=$(<$SCRIPTDIR/APP_NAME)
VERSION=$(<$SCRIPTDIR/../VERSION)
ARTIFACTSDIR="$SCRIPTDIR/../artifacts"

$SCRIPTDIR/bumpVersion.sh

# Build chocolatey package if a win-x64 SCD was built

if [[ -f $ARTIFACTSDIR/${APPNAME}_v${VERSION}_win-x64/$APPNAME.exe ]]; then
    # Clean and create directories
    rm -f $ARTIFACTSDIR/$APPNAME.*.nupkg
    rm -f $SCRIPTDIR/../chocolatey/tools/serve.exe
    mkdir -p $SCRIPTDIR/../chocolatey/tools
    # Copy SCD files
    cp -r $ARTIFACTSDIR/${APPNAME}_v${VERSION}_win-x64 $SCRIPTDIR/../chocolatey/tools
    # Workaround for a bug where choco uses the wrong working directory when using choco via Mono
    REGEX="<file src=\\\"tools\\\\\**\\\" target=\"tools\" />"
    REPLACEMENT="<file src=\"${SCRIPTDIR}/../chocolatey/tools\\**\" target=\"tools\" />"
    sed -r "s@${REGEX}@${REPLACEMENT}@g" $SCRIPTDIR/../chocolatey/$APPNAME.portable.nuspec > $SCRIPTDIR/../chocolatey/$APPNAME.temp-linux.nuspec
    # Build Chocolatey package
    choco pack "$SCRIPTDIR/../chocolatey/$APPNAME.temp-linux.nuspec" --out $ARTIFACTSDIR
    choco pack "$SCRIPTDIR/../chocolatey/$APPNAME.nuspec" --out $ARTIFACTSDIR
    # Clean up workaround
    rm -f $SCRIPTDIR/../chocolatey/$APPNAME.temp-linux.nuspec
fi

First check if the workaround is still required with the current Chocolatey version.

@philippgille philippgille added the enhancement New feature or request label May 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant