From d6e7040aba419087bcfcf2ac9dd1f268a3df3e01 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 13 Mar 2019 10:17:24 -0400 Subject: [PATCH] move to powershell for appveyor --- appveyor.yml | 87 ++++++++++++++++++++++++++++++++------------ bitwarden-server.sln | 1 - build-ci.sh | 41 --------------------- 3 files changed, 64 insertions(+), 65 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 16cd24748..e77ab65f7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,46 +1,87 @@ image: -- Visual Studio 2017 +#- Visual Studio 2017 - Ubuntu1804 -environment: - APPVEYOR_YML_DISABLE_PS_LINUX: true - services: - docker stack: node 10 init: -- ps: Install-Product node 10 +- ps: | + if($isWindows) { + Install-Product node 10 + } install: -- sh: npm i -g gulp -- ps: choco install cloc --no-progress -- ps: "cloc --include-lang C#,SQL,Razor,\"Bourne Shell\",PowerShell,HTML,CSS,Sass,JavaScript,TypeScript --vcs git" +- ps: | + $env:PROD_DEPLOY = "false" + $env:TAG_NAME = "" + if($env:APPVEYOR_REPO_TAG -eq "true" -and $env:APPVEYOR_RE_BUILD -eq "True") { + $env:PROD_DEPLOY = "true" + $env:TAG_NAME = $env:APPVEYOR_REPO_TAG_NAME.TrimStart("v") + echo "This is a production deployment for ${env:TAG_NAME}." + } + if($isLinux) { + npm i -g gulp + } else { + choco install cloc --no-progress + cloc --include-lang C#,SQL,Razor,"Bourne Shell",PowerShell,HTML,CSS,Sass,JavaScript,TypeScript --vcs git + } before_build: -#- sh: dotnet restore -- ps: msbuild /t:restore +- sh: | + if [ "${DOCKER_USERNAME}" != "" -a "${DOCKER_PASSWORD}" != "" ] + then + echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + fi +- ps: | + if($isLinux) { + #dotnet restore + } else { + msbuild /t:restore + } build_script: -- sh: chmod +x ./build-ci.sh -- sh: ./build-ci.sh +- sh: chmod +x ./build.sh - ps: | - msbuild bitwarden-server.sln /p:Configuration=Debug /verbosity:minimal ` + if($isLinux) { + #dotnet build --configuration Debug + ./build.sh + ./build.sh tag dev + + if($env:PROD_DEPLOY -eq "true") { + ./build.sh tag beta + ./build.sh tag ${TAG_NAME} + } + + docker images + ./build.sh push dev + + if($env:PROD_DEPLOY -eq "true") { + ./build.sh push beta + ./build.sh push latest + ./build.sh push ${TAG_NAME} + } + } else { + msbuild bitwarden-server.sln /p:Configuration=Debug /verbosity:minimal ` /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" -- ps: | - $env:swaggerGen="true" - $env:ASPNETCORE_ENVIRONMENT="Production" - cd .\src\Api; dotnet swagger tofile --output ..\..\swagger.json --host api.bitwarden.com --format Indented ` + + $env:swaggerGen="true" + $env:ASPNETCORE_ENVIRONMENT="Production" + cd .\src\Api; dotnet swagger tofile --output ..\..\swagger.json --host api.bitwarden.com --format Indented ` .\bin\Debug\netcoreapp2.1\Api.dll public - cd ..\.. - $env:ASPNETCORE_ENVIRONMENT="" - $env:swaggerGen="" - Push-AppveyorArtifact .\swagger.json + cd ..\.. + $env:ASPNETCORE_ENVIRONMENT="" + $env:swaggerGen="" + Push-AppveyorArtifact .\swagger.json + } after_build: - sh: docker logout test_script: -#- sh: dotnet test .\test\Core.Test\Core.Test.csproj --configuration Debug --no-build -- ps: dotnet test .\test\Core.Test\Core.Test.csproj --configuration Debug --no-build +- ps: | + if($isWindows) { + dotnet test .\test\Core.Test\Core.Test.csproj --configuration Debug --no-build + } diff --git a/bitwarden-server.sln b/bitwarden-server.sln index eb3f78444..67197cde3 100644 --- a/bitwarden-server.sln +++ b/bitwarden-server.sln @@ -14,7 +14,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution .editorconfig = .editorconfig .gitignore = .gitignore appveyor.yml = appveyor.yml - build-ci.sh = build-ci.sh build.sh = build.sh LICENSE.txt = LICENSE.txt NuGet.Config = NuGet.Config diff --git a/build-ci.sh b/build-ci.sh index e0c0b1ccc..0510f2c06 100644 --- a/build-ci.sh +++ b/build-ci.sh @@ -1,43 +1,2 @@ #!/usr/bin/env bash set -e - -echo "Repo tag name: ${APPVEYOR_REPO_TAG_NAME}" -echo "Rebuild: ${APPVEYOR_RE_BUILD}" - -PROD_DEPLOY=false -TAG_NAME="" -if [ "${APPVEYOR_REPO_TAG_NAME}" != "" -a "${APPVEYOR_RE_BUILD}" == "True" ] -then - PROD_DEPLOY=true - TAG_NAME=${APPVEYOR_REPO_TAG_NAME#"v"} -fi - -echo "Prod deploy: ${PROD_DEPLOY}" -echo "Tag name: ${TAG_NAME}" - -#dotnet build --configuration Debug - -if [ "${DOCKER_USERNAME}" != "" -a "${DOCKER_PASSWORD}" != "" ] -then - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin -fi - -chmod +x ./build.sh -./build.sh -./build.sh tag dev - -if [ "${PROD_DEPLOY}" == "true" ] -then - ./build.sh tag beta - ./build.sh tag $TAG_NAME -fi - -docker images -./build.sh push dev - -if [ "${PROD_DEPLOY}" == "true" ] -then - ./build.sh push beta - ./build.sh push latest - ./build.sh push $TAG_NAME -fi