Revert "chore: try add actions/cache for windows container" #36
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: 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 | |
| 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() | |
| } | |
| } |