From 59c4acf189a39f9fb905637378e49ba21af87f73 Mon Sep 17 00:00:00 2001 From: Alexey Pustovalov Date: Sat, 9 Oct 2021 10:12:02 +0200 Subject: [PATCH] Updated build script --- .github/workflows/images_build.yml | 10 +++--- .github/workflows/images_build_windows.yml | 38 ++++++++++++++++------ build.json | 7 +++- 3 files changed, 39 insertions(+), 16 deletions(-) diff --git a/.github/workflows/images_build.yml b/.github/workflows/images_build.yml index 56acc716b..31e88fee1 100644 --- a/.github/workflows/images_build.yml +++ b/.github/workflows/images_build.yml @@ -48,14 +48,14 @@ jobs: - name: Prepare Operating System list id: os run: | - os_list=$(jq -r '.os | keys | [ .[] | tostring ] | @json' "./build.json") + os_list=$(jq -r '.["os-linux"] | keys | [ .[] | tostring ] | @json' "./build.json") echo "::set-output name=list::$os_list" - name: Prepare Platform list id: platform_list run: | - platform_list=$(jq -r '.os | tostring | @json' "./build.json") + platform_list=$(jq -r '.["os-linux"] | tostring | @json' "./build.json") echo "::set-output name=list::$platform_list" @@ -108,7 +108,7 @@ jobs: - name: Prepare Platform list id: platform run: | - platform_list=$(jq -r '.os.${{ matrix.os }} | join(",")' "./build.json") + platform_list=$(jq -r '.["os-linux"].${{ matrix.os }} | join(",")' "./build.json") echo ::set-output name=list::$platform_list @@ -178,7 +178,7 @@ jobs: - name: Prepare Platform list id: platform run: | - platform_list=$(jq -r '.os.${{ matrix.os }} | join(",")' "./build.json") + platform_list=$(jq -r '.["os-linux"].${{ matrix.os }} | join(",")' "./build.json") echo ::set-output name=list::$platform_list @@ -266,7 +266,7 @@ jobs: if [ "${{ matrix.os }}" == "alpine" ] && [ "${{ matrix.build }}" == "web-service" ]; then platform_list="linux/amd64,linux/arm64" else - platform_list=$(jq -r '.os.${{ matrix.os }} | join(",")' "./build.json") + platform_list=$(jq -r '.["os-linux"].${{ matrix.os }} | join(",")' "./build.json") fi echo ::set-output name=list::$platform_list diff --git a/.github/workflows/images_build_windows.yml b/.github/workflows/images_build_windows.yml index 62c4a767a..147a7de78 100644 --- a/.github/workflows/images_build_windows.yml +++ b/.github/workflows/images_build_windows.yml @@ -47,7 +47,7 @@ jobs: - name: Prepare Operating System list id: os run: | - $os_list='["ltsc2022"]' + os_list=$(jq -r '.["os-windows"] | keys | [ .[] | tostring ] | @json' ".\build.json") echo "::set-output name=list::$os_list" @@ -74,7 +74,7 @@ jobs: os: ${{ fromJson(needs.init_build.outputs.os) }} component: ${{ fromJson(needs.init_build.outputs.components) }} - runs-on: windows-2022 + runs-on: ${{ matrix.os }} steps: - name: Checkout repository uses: actions/checkout@v2.3.4 @@ -86,14 +86,20 @@ jobs: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} if (-not $?) {throw "Failed"} + - name: Base OS tag + id: base_os_tag + run: | + $os_tag=$(Get-Content -Path .\build.json | ConvertFrom-Json).'os-windows'.'${{ matrix.os }}' + echo "::set-output name=os_tag::$os_tag" + - name: Generate tags id: meta uses: docker/metadata-action@v3 with: images: ${{ env.DOCKER_REPOSITORY }}/${{ env.IMAGE_PREFIX }}${{ env.BASE_BUILD_NAME }} tags: | - type=ref,event=branch,prefix=${{ matrix.component }}-${{ matrix.os }}- - type=ref,event=branch,suffix=-${{ matrix.os }},prefix=${{ matrix.component }}- + type=ref,event=branch,prefix=${{ matrix.component }}-${{ steps.base_os_tag.outputs.os_tag }}- + type=ref,event=branch,suffix=-${{ steps.base_os_tag.outputs.os_tag }},prefix=${{ matrix.component }}- flavor: | latest=false @@ -162,7 +168,7 @@ jobs: os: ${{ fromJson(needs.init_build.outputs.os) }} component: ${{ fromJson(needs.init_build.outputs.components) }} - runs-on: windows-2022 + runs-on: ${{ matrix.os }} steps: - name: Checkout repository uses: actions/checkout@v2.3.4 @@ -172,14 +178,20 @@ jobs: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} if (-not $?) {throw "Failed"} + - name: Base OS tag + id: base_os_tag + run: | + $os_tag=$(Get-Content -Path .\build.json | ConvertFrom-Json).'os-windows'.'${{ matrix.os }}' + echo "::set-output name=os_tag::$os_tag" + - name: Generate tags id: meta uses: docker/metadata-action@v3 with: images: ${{ env.DOCKER_REPOSITORY }}/${{ env.IMAGE_PREFIX }}${{ env.COMPONENT_BASE_BUILD_NAME }} tags: | - type=ref,event=branch,prefix=${{ matrix.component }}-${{ matrix.os }}- - type=ref,event=branch,suffix=-${{ matrix.os }},prefix=${{ matrix.component }}- + type=ref,event=branch,prefix=${{ matrix.component }}-${{ steps.base_os_tag.outputs.os_tag }}- + type=ref,event=branch,suffix=-${{ steps.base_os_tag.outputs.os_tag }},prefix=${{ matrix.component }}- flavor: | latest=false @@ -262,7 +274,7 @@ jobs: os: ${{ fromJson(needs.init_build.outputs.os) }} component: ${{ fromJson(needs.init_build.outputs.components) }} - runs-on: windows-2022 + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2.3.4 @@ -271,14 +283,20 @@ jobs: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} if (-not $?) {throw "Failed"} + - name: Base OS tag + id: base_os_tag + run: | + $os_tag=$(Get-Content -Path .\build.json | ConvertFrom-Json).'os-windows'.'${{ matrix.os }}' + echo "::set-output name=os_tag::$os_tag" + - name: Generate tags id: meta uses: docker/metadata-action@v3 with: images: ${{ env.DOCKER_REPOSITORY }}/${{ env.IMAGE_PREFIX }}${{ matrix.component }} tags: | - type=ref,event=branch,prefix=${{ matrix.os }}- - type=ref,event=branch,suffix=-${{ matrix.os }} + type=ref,event=branch,prefix=${{ steps.base_os_tag.outputs.os_tag }}- + type=ref,event=branch,suffix=-${{ steps.base_os_tag.outputs.os_tag }} flavor: | latest=false diff --git a/build.json b/build.json index 45b482722..0d0eb54b5 100644 --- a/build.json +++ b/build.json @@ -1,5 +1,5 @@ { - "os": { + "os-linux": { "alpine": [ "linux/amd64", "linux/arm/v6", @@ -20,6 +20,11 @@ "linux/arm64" ] }, + "os-windows": { + "windows-2022": "ltsc2022", + "windows-2019": "ltsc2019", + "windows-2016": "ltsc2016" + }, "components": { "agent": "build-mysql", "agent2": "build-mysql",