diff --git a/.github/workflows/build-installers.yml b/.github/workflows/build-installers.yml new file mode 100644 index 000000000..94b7614b0 --- /dev/null +++ b/.github/workflows/build-installers.yml @@ -0,0 +1,36 @@ +name: Build-Installers + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + linux: + name: "Linux" + + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Indicate full history so Nerdbank.GitVersioning works. + + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.302 + + - name: Install dependencies + run: dotnet restore --force + + - name: Build Linux Payloads + run: dotnet build -c release src/linux/Payload.Linux/Payload.Linux.csproj + + - name: Upload Installers + uses: actions/upload-artifact@v2 + with: + name: Installers + path: | + out/linux/*.deb + out/linux/*.tar.gz diff --git a/src/linux/Payload.Linux/build.sh b/src/linux/Payload.Linux/build.sh index 13e924285..37a8795d8 100755 --- a/src/linux/Payload.Linux/build.sh +++ b/src/linux/Payload.Linux/build.sh @@ -4,15 +4,21 @@ die () { exit 1 } -echo "Building Payload.Linux..." +make_absolute () { + case "$1" in + /*) + echo "$1" + ;; + *) + echo "$PWD/$1" + ;; + esac +} -# Directories -THISDIR="$( cd "$(dirname "$0")" ; pwd -P )" -ROOT="$( cd "$THISDIR"/../../.. ; pwd -P )" -SRC="$ROOT/src" -OUT="$ROOT/out" -PAYLOAD_SRC="$SRC/linux/Payload.Linux" -PAYLOAD_OUT="$OUT/linux/Payload.Linux" +##################################################################### +# Building +##################################################################### +echo "Building Payload.Linux..." # Parse script arguments for i in "$@" @@ -32,17 +38,106 @@ case "$i" in esac done +# Directories +THISDIR="$( cd "$(dirname "$0")" ; pwd -P )" +ROOT="$( cd "$THISDIR"/../../.. ; pwd -P )" +SRC="$ROOT/src" +OUT="$ROOT/out" +GCM_SRC="$SRC/shared/Git-Credential-Manager" +PAYLOAD_OUT="$OUT/linux/" + +# Build parameters +FRAMEWORK=netcoreapp3.1 +RUNTIME=linux-x64 + # Perform pre-execution checks CONFIGURATION="${CONFIGURATION:=Debug}" if [ -z "$VERSION" ]; then die "--version was not set" fi -PAYLOAD="$PAYLOAD_OUT/tar/$CONFIGURATION/payload" -TAROUT="$PAYLOAD_OUT/tar/$CONFIGURATION/gcmcore-linux-x86_64-$VERSION.tar.gz" +ARCH="`dpkg-architecture -q DEB_HOST_ARCH`" +if test -z "$ARCH"; then + die "Could not determine host architecture!" +fi + +# Outputs +PAYLOAD="$PAYLOAD_OUT/payload/$CONFIGURATION" +TAROUT="$PAYLOAD_OUT/gcmcore-linux_$ARCH.$CONFIGURATION.$VERSION.tar.gz" +DEBPKG="$PAYLOAD_OUT/gcmcore-linux/" +DEBOUT="$PAYLOAD_OUT/gcmcore-linux_$ARCH.$CONFIGURATION.$VERSION.deb" +SYMBOLOUT="$PAYLOAD.sym" + +# Cleanup payload directory +if [ -d "$PAYLOAD" ]; then + echo "Cleaning existing payload directory '$PAYLOAD'..." + rm -rf "$PAYLOAD" +fi + +# Ensure directories exists +mkdir -p "$PAYLOAD" "$SYMBOLOUT" "$DEBPKG" + +# Publish core application executables +echo "Publishing core application..." +dotnet publish "$GCM_SRC" \ + --configuration="$CONFIGURATION" \ + --framework="$FRAMEWORK" \ + --runtime="$RUNTIME" \ + --self-contained=true \ + "/p:PublishSingleFile=True" \ + --output="$(make_absolute "$PAYLOAD")" || exit 1 + +# Collect symbols +echo "Collecting managed symbols..." +mv "$PAYLOAD"/*.pdb "$SYMBOLOUT" || exit 1 + +echo "Build complete." + +##################################################################### +# PACKING +##################################################################### +echo "Packing Payload.Linux..." +# Cleanup any old archive files +if [ -e "$TAROUT" ]; then + echo "Deleteing old archive '$TAROUT'..." + rm "$TAROUT" +fi + +# Ensure the parent directory for the archive exists +mkdir -p "$(dirname "$TAROUT")" + +# Set full read, write, execute permissions for owner and just read and execute permissions for group and other +echo "Setting file permissions..." +/bin/chmod -R 755 "$PAYLOAD" || exit 1 + +# Build tarball +echo "Building archive..." +pushd "$PAYLOAD" +tar -czvf "$TAROUT" * || exit 1 +popd + +# Build .deb +INSTALL_TO="$DEBPKG/usr/bin/" +mkdir -p "$DEBPKG/DEBIAN" "$INSTALL_TO" + +# make the debian control file +cat >"$DEBPKG/DEBIAN/control" < +Description: Cross Platform Git-Credential-Manager-Core command line utility. + Linux build of the GCM-Core project to support auth with a number of + git hosting providers including GitHub, BitBucket, and Azure DevOps. + Hosted at https://github.com/microsoft/Git-Credential-Manager-Core +EOF + +# Copy single binary to target installation location +cp "$PAYLOAD/git-credential-manager-core" "$INSTALL_TO" -# Layout and pack -"$PAYLOAD_SRC/layout.sh" --configuration="$CONFIGURATION" --output="$PAYLOAD" || exit 1 -"$PAYLOAD_SRC/pack.sh" --payload="$PAYLOAD" --output="$TAROUT" || exit 1 +dpkg-deb --build "$DEBPKG" "$DEBOUT" -echo "Build of Payload.Linux complete." +echo "Pack complete." diff --git a/src/linux/Payload.Linux/layout.sh b/src/linux/Payload.Linux/layout.sh deleted file mode 100755 index 41348f696..000000000 --- a/src/linux/Payload.Linux/layout.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash -die () { - echo "$*" >&2 - exit 1 -} -make_absolute () { - case "$1" in - /*) - echo "$1" - ;; - *) - echo "$PWD/$1" - ;; - esac -} - -# Directories -THISDIR="$( cd "$(dirname "$0")" ; pwd -P )" -ROOT="$( cd "$THISDIR"/../../.. ; pwd -P )" -SRC="$ROOT/src" -OUT="$ROOT/out" -GCM_SRC="$SRC/shared/Git-Credential-Manager" - -# Build parameters -FRAMEWORK=netcoreapp3.1 -RUNTIME=linux-x64 - -# Parse script arguments -for i in "$@" -do -case "$i" in - --configuration=*) - CONFIGURATION="${i#*=}" - shift # past argument=value - ;; - --output=*) - PAYLOAD="${i#*=}" - shift # past argument=value - ;; - --symbol-output=*) - SYMBOLOUT="${i#*=}" - ;; - *) - # unknown option - ;; -esac -done - -# Perform pre-execution checks -CONFIGURATION="${CONFIGURATION:=Debug}" -if [ -z "$PAYLOAD" ]; then - die "--output was not set" -fi -if [ -z "$SYMBOLOUT" ]; then - SYMBOLOUT="$PAYLOAD.sym" -fi - -# Cleanup any old payload directory -if [ -d "$PAYLOAD" ]; then - echo "Cleaning old payload directory '$PAYLOAD'..." - rm -rf "$PAYLOAD" -fi - -# Ensure payload and symbol directories exists -mkdir -p "$PAYLOAD" "$SYMBOLOUT" - -# Publish core application executables -echo "Publishing core application..." -dotnet publish "$GCM_SRC" \ - --configuration="$CONFIGURATION" \ - --framework="$FRAMEWORK" \ - --runtime="$RUNTIME" \ - --output="$(make_absolute "$PAYLOAD")" || exit 1 - -# Collect symbols -echo "Collecting managed symbols..." -mv "$PAYLOAD"/*.pdb "$SYMBOLOUT" || exit 1 - -echo "Layout complete." diff --git a/src/linux/Payload.Linux/pack.sh b/src/linux/Payload.Linux/pack.sh deleted file mode 100755 index 617dfde46..000000000 --- a/src/linux/Payload.Linux/pack.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash -die () { - echo "$*" >&2 - exit 1 -} - -# Directories -THISDIR="$( cd "$(dirname "$0")" ; pwd -P )" -ROOT="$( cd "$THISDIR"/../../.. ; pwd -P )" -SRC="$ROOT/src" -OUT="$ROOT/out" - -# Parse script arguments -for i in "$@" -do -case "$i" in - --payload=*) - PAYLOAD="${i#*=}" - shift # past argument=value - ;; - --output=*) - TAROUT="${i#*=}" - shift # past argument=value - ;; - *) - # unknown option - ;; -esac -done - -# Perform pre-execution checks -if [ -z "$PAYLOAD" ]; then - die "--payload was not set" -elif [ ! -d "$PAYLOAD" ]; then - die "Could not find '$PAYLOAD'. Did you run layout.sh first?" -fi -if [ -z "$TAROUT" ]; then - die "--output was not set" -fi - -# Cleanup any old archive files -if [ -e "$TAROUT" ]; then - echo "Deleteing old archive '$TAROUT'..." - rm "$TAROUT" -fi - -# Ensure the parent directory for the archive exists -mkdir -p "$(dirname "$TAROUT")" - -# Set full read, write, execute permissions for owner and just read and execute permissions for group and other -echo "Setting file permissions..." -/bin/chmod -R 755 "$PAYLOAD" || exit 1 - -# Build tarball -echo "Building archive..." -cd "$PAYLOAD" -tar -czvf "$TAROUT" * || exit 1 - -echo "Pack complete."