Skip to content

Commit

Permalink
Fixes publish script to work with zsh (#218)
Browse files Browse the repository at this point in the history
Fixes the publish script so it works with zsh and bash. (bump release)
  • Loading branch information
kamronbatman authored Sep 4, 2020
1 parent dbca97e commit dcbbb13
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -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
45 changes: 45 additions & 0 deletions .github/workflows/sonar-cloud.yml
Original file line number Diff line number Diff line change
@@ -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 }}"
21 changes: 13 additions & 8 deletions publish.cmd
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
#!/usr/bin/env bash
dotnet restore --force-evaluate

:<<"::SHELLSCRIPT"
@ECHO OFF
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
Expand Down

0 comments on commit dcbbb13

Please sign in to comment.