forked from OpenListTeam/OpenList
-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (120 loc) · 4.23 KB
/
release_docker_win.yml
File metadata and controls
138 lines (120 loc) · 4.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Release builds (Docker) (Windows Container)
on:
workflow_dispatch:
inputs:
manual_tag:
description: "Tag name (like v0.1.0). Required if as_latest is true."
required: false
type: string
default: latest
as_latest:
description: "Tag as latest?"
required: true
default: "false"
type: choice
options:
- "true"
- "false"
push:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
GHCR_ORG_NAME: ${{ vars.GHCR_ORG_NAME || 'nbtca' }}
IMAGE_NAME: openlist
REGISTRY: ghcr.io
IMAGE_PUSH: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
permissions:
packages: write
jobs:
release_docker_windows:
name: Release Windows Docker image
runs-on: windows-${{ matrix.windows_version }}
strategy:
matrix:
windows_version: ["2025", "2022"]
container_type: ["nanoserver", "servercore"]
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Login to GitHub Container Registry
if: env.IMAGE_PUSH == 'true'
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Determine tag
id: tag
shell: pwsh
run: |
$tag = "${{ github.ref_name }}"
$windowsVersion = "ltsc${{ matrix.windows_version }}"
$isPush = "${{ github.event_name == 'push' }}"
$isManualLatest = "${{ github.event.inputs.as_latest == 'true' }}"
if ($isPush -eq "true" -or $isManualLatest -eq "true") {
$isLatest = "true"
} else {
$isLatest = "false"
}
echo "tag=$tag" >> $env:GITHUB_OUTPUT
echo "windows_version=$windowsVersion" >> $env:GITHUB_OUTPUT
echo "is_latest=$isLatest" >> $env:GITHUB_OUTPUT
- name: Ensure Docker Engine is started
shell: pwsh
run: |
$service = Get-Service -Name docker -ErrorAction SilentlyContinue
if ($null -ne $service -and $service.Status -ne 'Running') {
Write-Host "Starting Docker service..."
Start-Service docker
}
$retries = 0
while (!(Test-Path \\.\pipe\docker_engine) -and $retries -lt 15) {
Write-Host "Waiting for docker pipe..."
Start-Sleep -Seconds 2
$retries++
}
docker info
- name: Build Docker tags
id: meta
shell: pwsh
run: |
$tag = "${{ steps.tag.outputs.tag }}"
$winVer = "${{ steps.tag.outputs.windows_version }}"
$isLatest = "${{ steps.tag.outputs.is_latest }}"
$containerType = "${{ matrix.container_type }}"
$ghcrImage = "${{ env.REGISTRY }}/${{ env.GHCR_ORG_NAME }}/${{ env.IMAGE_NAME }}"
# include container type in tags so we can distinguish nanoserver/servercore builds
$tags = @(
"${ghcrImage}:${tag}-windows-${winVer}-${containerType}"
)
if ($isLatest -eq "true") {
$tags += "${ghcrImage}:windows-${winVer}-${containerType}"
if ($winVer -eq "ltsc2025") {
$tags += "${ghcrImage}:windows-${containerType}"
}
}
$tagsString = $tags -join ","
echo "tags=$tagsString" >> $env:GITHUB_OUTPUT
Write-Host "Tags: $tagsString"
- name: Build and push Windows container
shell: pwsh
run: |
$tags = "${{ steps.meta.outputs.tags }}".Split(",")
$tagArgs = @()
foreach ($tag in $tags) {
$tagArgs += "-t"
$tagArgs += $tag.Trim()
}
docker build `
--build-arg WINDOWS_VERSION=${{ steps.tag.outputs.windows_version }} `
--build-arg WINDOWS_TYPE=${{ matrix.container_type }} `
-f Dockerfile.windows `
$tagArgs `
.
if ("${{ env.IMAGE_PUSH }}" -eq "true") {
foreach ($tag in $tags) {
Write-Host "Pushing $($tag.Trim())"
docker push $tag.Trim()
}
}