diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 13976c3..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,22 +0,0 @@ -version: 1.0.{build} -image: Visual Studio 2017 - -platform: - - x86 - -environment: - PUSH_IMAGE: 'rustops/crates-build-env-windows' - -# If Docker is currently configured to run Linux containers, we need to switch -# to running Windows containers. -# -# https://github.com/docker/cli/issues/1042 -init: - # - ps: $env:ProgramFiles/Docker/Docker/DockerCli.exe -SwitchDaemon - -build_script: - - ps: ./windows/ci/build.ps1 - -deploy_script: - - ps: if ($env:APPVEYOR_REPO_BRANCH -eq "master") { ./windows/ci/publish.ps1 } - diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..705737e --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,21 @@ +variables: + - group: docker-creds + +jobs: +- job: Windows + pool: + vmImage: win1803 + variables: + IMAGE_NAME: 'crates-build-env-windows' + steps: + - pwsh: ./windows/ci/build.ps1 + displayName: Build Docker image + - pwsh: ./windows/ci/publish.ps1 + displayName: Publish image to Docker Hub + condition: | + and(succeeded(), + eq(variables['Build.SourceBranch'], 'refs/heads/master'), + ne(variables['Build.Reason'], 'PullRequest')) + env: + DOCKER_PASSWORD: $(DOCKER_PASSWORD) + DOCKER_USERNAME: $(DOCKER_USERNAME) diff --git a/windows/ci/build.ps1 b/windows/ci/build.ps1 index 59ccf41..33a02b9 100644 --- a/windows/ci/build.ps1 +++ b/windows/ci/build.ps1 @@ -1,8 +1,6 @@ -$ErrorActionPreference = "Stop" - -$ContainerBase = '@sha256:c06b4bfaf634215ea194e6005450740f3a230b27c510cf8facab1e9c678f3a99' +$ContainerBase = ':1803' docker build ` - -t "$env:PUSH_IMAGE" ` + -t "$env:IMAGE_NAME" ` --build-arg "BASE_IMAGE_VER=$ContainerBase" ` windows diff --git a/windows/ci/publish.ps1 b/windows/ci/publish.ps1 index 581d8c4..4f21918 100644 --- a/windows/ci/publish.ps1 +++ b/windows/ci/publish.ps1 @@ -1,8 +1,3 @@ -$ErrorActionPreference = "Stop" - -# Build the image -./windows/ci/build.ps1 - foreach ($var in "DOCKER_USERNAME", "DOCKER_PASSWORD") { if (-not (Test-Path "env:$var")) { echo "Environment variable \"$var\" not set" @@ -10,8 +5,7 @@ foreach ($var in "DOCKER_USERNAME", "DOCKER_PASSWORD") { } } -# Log in to dockerhub -[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Env:DOCKER_PASSWORD)).Trim() ` - | docker login --username "$Env:DOCKER_USERNAME" --password-stdin - -docker push "$env:PUSH_IMAGE" +Write-Host "Publishing to hub.docker.com/$env:DOCKER_USERNAME" +docker login --username "$env:DOCKER_USERNAME" --password "$env:DOCKER_PASSWORD" +docker tag "$env:IMAGE_NAME" "$env:DOCKER_USERNAME/$env:IMAGE_NAME" +docker push "$env:DOCKER_USERNAME/$env:IMAGE_NAME"