Update release_docker_win.yml #34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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@v4 | |
| - name: Set up Docker | |
| uses: docker/setup-docker-action@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| if: env.IMAGE_PUSH == 'true' | |
| uses: docker/login-action@v3 | |
| 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: 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 | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: Dockerfile.windows | |
| build-args: | | |
| WINDOWS_VERSION=${{ steps.tag.outputs.windows_version }} | |
| WINDOWS_TYPE=${{ matrix.container_type }} | |
| push: ${{ env.IMAGE_PUSH }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |