From dcbbb13e72742115ae6f5509a9e1fac1b8702931 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Thu, 3 Sep 2020 17:18:28 -0700 Subject: [PATCH] Fixes publish script to work with zsh (#218) Fixes the publish script so it works with zsh and bash. (bump release) --- .gitattributes | 2 ++ .github/workflows/sonar-cloud.yml | 45 +++++++++++++++++++++++++++++++ publish.cmd | 21 +++++++++------ 3 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/sonar-cloud.yml diff --git a/.gitattributes b/.gitattributes index 85b9dcfd6..d52f4e4af 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,6 +3,8 @@ *.cs text diff=csharp *.csproj text eol=crlf *.json text eol=lf +*.md text eol=lf *.sh text eol=lf *.sln text eol=crlf +*.yml text eol=lf publish.cmd text eol=lf diff --git a/.github/workflows/sonar-cloud.yml b/.github/workflows/sonar-cloud.yml new file mode 100644 index 000000000..0a03074cf --- /dev/null +++ b/.github/workflows/sonar-cloud.yml @@ -0,0 +1,45 @@ +name: Build +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] + +jobs: + sonar_cloud: + name: Sonar Cloud + if: "false" + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Cache SonarCloud packages + uses: actions/cache@v1 + with: + path: ~\sonar\cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache SonarCloud scanner + id: cache-sonar-scanner + uses: actions/cache@v1 + with: + path: .\.sonar\scanner + key: ${{ runner.os }}-sonar-scanner + restore-keys: ${{ runner.os }}-sonar-scanner + - name: Install SonarCloud scanner + if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' + shell: powershell + run: | + New-Item -Path .\.sonar\scanner -ItemType Directory + dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner + - name: Build and analyze + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + shell: powershell + run: | + .\.sonar\scanner\dotnet-sonarscanner begin /k:"modernuo_ModernUO" /o:"modernuo" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" + .\publish.cmd win core Release + .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" \ No newline at end of file diff --git a/publish.cmd b/publish.cmd index c148bea46..dbbb57461 100755 --- a/publish.cmd +++ b/publish.cmd @@ -1,4 +1,3 @@ -#!/usr/bin/env bash dotnet restore --force-evaluate :<<"::SHELLSCRIPT" @@ -6,25 +5,31 @@ dotnet restore --force-evaluate GOTO :CMDSCRIPT ::SHELLSCRIPT -if [[ $1 ]]; then - r="-r $1-x64" +os=$1 + +if [[ $os ]]; then + r="-r $os-x64" elif [[ $(uname) = "Darwin" ]]; then r="-r osx-x64" elif [[ -f /etc/os-release ]]; then . /etc/os-release - r="-r ${NAME,,}.$VERSION_ID-x64" + NAME="$(tr '[:upper:]' '[:lower:]' <<< $NAME)" + r="-r $NAME.$VERSION_ID-x64" fi -if [[ -z $2 ]] || [[ ${2,,} = "core" ]]; then - f="-f netcoreapp3.1" -else +framework="$(tr '[:upper:]' '[:lower:]' <<< $2)" + +if [[ $framework = "net" ]]; then f="-f net5.0" +else + f="-f netcoreapp3.1" fi if [[ -z $3 ]]; then c="-c Release" else - c="-c ${3^}" + config="$(tr '[:lower:]' '[:upper:]' <<< ${3:0:1})${3:1}" + c="-c $config" fi echo dotnet publish ${c} ${r} ${f} --no-restore --self-contained=false -o Distribution Projects/Server/Server.csproj