Skip to content

Commit 616076f

Browse files
Use Azure Pipelines for Windows instead of AppVeyor
This removes the AppVeyor configuration and adapts it for use on Azure Pipelines. For deployment, the maintainer must create a `docker-creds` variable group containing `DockerUsername` and `DockerPassword`. `DockerPassword` should be secret. This variable group must be linked to the particular build. Secrets are not visible to PR builds by default, which mitigates some of the security risks here. Still, it would be better to opt in to deployment as opposed to opting out of it with a `condition`.
1 parent fe1bd41 commit 616076f

File tree

4 files changed

+24
-36
lines changed

4 files changed

+24
-36
lines changed

appveyor.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

azure-pipelines.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
jobs:
2+
- job: Windows
3+
pool:
4+
vmImage: win1803
5+
variables:
6+
group: docker-creds
7+
IMAGE_NAME: 'crates-build-env-windows'
8+
steps:
9+
- pwsh: ./windows/ci/build.ps1
10+
displayName: Build Docker image
11+
- pwsh: ./windows/ci/publish.ps1
12+
displayName: Publish image to Docker Hub
13+
# FIXME: Using condition for this seems brittle, maybe there's a better way?
14+
condition: |
15+
and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'), ne(variables['Build.Reason'], 'PullRequest'))
16+
env:
17+
DOCKER_PASSWORD: $(DockerPassword)
18+
DOCKER_USERNAME: $(DockerUsername)

windows/ci/build.ps1

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
$ErrorActionPreference = "Stop"
2-
3-
$ContainerBase = '@sha256:c06b4bfaf634215ea194e6005450740f3a230b27c510cf8facab1e9c678f3a99'
1+
$ContainerBase = ':1803'
42

53
docker build `
6-
-t "$env:PUSH_IMAGE" `
4+
-t "$env:IMAGE_NAME" `
75
--build-arg "BASE_IMAGE_VER=$ContainerBase" `
86
windows

windows/ci/publish.ps1

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
$ErrorActionPreference = "Stop"
2-
3-
# Build the image
4-
./windows/ci/build.ps1
5-
61
foreach ($var in "DOCKER_USERNAME", "DOCKER_PASSWORD") {
72
if (-not (Test-Path "env:$var")) {
83
echo "Environment variable \"$var\" not set"
94
exit 22
105
}
116
}
127

13-
# Log in to dockerhub
14-
[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Env:DOCKER_PASSWORD)).Trim() `
15-
| docker login --username "$Env:DOCKER_USERNAME" --password-stdin
16-
17-
docker push "$env:PUSH_IMAGE"
8+
Write-Host "Publishing to hub.docker.com/$env:DOCKER_USERNAME"
9+
docker login --username "$env:DOCKER_USERNAME" --password "$env:DOCKER_PASSWORD"
10+
docker tag "$env:IMAGE_NAME" "$env:DOCKER_USERNAME/$env:IMAGE_NAME"
11+
docker push "$env:DOCKER_USERNAME/$env:IMAGE_NAME"

0 commit comments

Comments
 (0)