From cc07aee8772ffb798d768f7cc0a196f7cf0c0a69 Mon Sep 17 00:00:00 2001 From: Aman Singh Date: Thu, 27 Feb 2025 22:47:50 -0800 Subject: [PATCH] Rewrite Release WF to use ARM runner --- .github/workflows/draft-release.yml | 113 +++++++++++++++++----------- 1 file changed, 70 insertions(+), 43 deletions(-) diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index 6db617a4b..c050e2452 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -51,9 +51,10 @@ jobs: permissions: packages: write contents: read - runs-on: ubuntu-latest - strategy: + runs-on: ${{ matrix.runner }} + strategy: matrix: + runner: [ubuntu-latest, ubuntu-24.04-arm] component: [ { label: 'Query Host', @@ -78,9 +79,6 @@ jobs: submodules: true token: ${{ secrets.DRASI_CORE_PAT }} - - name: Set up QEMU - uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 - - name: Set up Docker Buildx uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1 with: @@ -92,30 +90,41 @@ jobs: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + + - name: Determine platform + id: platform + run: | + if [[ "${{ matrix.runner }}" == "ubuntu-latest" ]]; then + echo "platform=linux/amd64" >> $GITHUB_OUTPUT + elif [[ "${{ matrix.runner }}" == "ubuntu-24.04-arm" ]]; then + echo "platform=linux/arm64" >> $GITHUB_OUTPUT + fi + - name: Cache Docker layers uses: actions/cache@v4 with: path: /tmp/.buildx-cache - key: buildx-${{ matrix.component.name }} + key: buildx-${{ matrix.component.name }}-${{ matrix.runner }} restore-keys: | - buildx-${{ matrix.component.name }} + buildx-${{ matrix.component.name }}-${{ matrix.runner }} - name: Build and Push to GHCR run: | cd ${{ matrix.component.path }} DOCKER_TAG_VERSION=${{ inputs.tag }} \ IMAGE_PREFIX=${{ inputs.image_prefix }} \ - DOCKERX_OPTS="--push --platform linux/amd64,linux/arm64 --cache-to type=local,dest=/tmp/.buildx-cache,mode=max --cache-from type=local,src=/tmp/.buildx-cache" \ - make + DOCKERX_OPTS="--push --platform ${{ steps.platform.outputs.platform }} --cache-to type=local,dest=/tmp/.buildx-cache,mode=max --cache-from type=local,src=/tmp/.buildx-cache" \ + make build-control-plane: - runs-on: ubuntu-latest needs: validate permissions: packages: write contents: read + runs-on: ${{ matrix.runner }} strategy: matrix: + runner: [ubuntu-latest, ubuntu-24.04-arm] component: [ { label: 'Management API', @@ -132,9 +141,6 @@ jobs: - name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - name: Set up QEMU - uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 - - name: Set up Docker Buildx uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1 with: @@ -146,32 +152,41 @@ jobs: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - + + - name: Determine platform + id: platform + run: | + if [[ "${{ matrix.runner }}" == "ubuntu-latest" ]]; then + echo "platform=linux/amd64" >> $GITHUB_OUTPUT + elif [[ "${{ matrix.runner }}" == "ubuntu-24.04-arm" ]]; then + echo "platform=linux/arm64" >> $GITHUB_OUTPUT + fi + - name: Cache Docker layers uses: actions/cache@v4 with: path: /tmp/.buildx-cache - key: buildx-${{ matrix.component.name }} + key: buildx-${{ matrix.component.name }}-${{ matrix.runner }} restore-keys: | - buildx-${{ matrix.component.name }} - + buildx-${{ matrix.component.name }}-${{ matrix.runner }} + - name: Build and Push to GHCR run: | cd ${{ matrix.component.path }} DOCKER_TAG_VERSION=${{ inputs.tag }} \ IMAGE_PREFIX=${{ inputs.image_prefix }} \ - DOCKERX_OPTS="--push --platform linux/amd64,linux/arm64 --cache-to type=local,dest=/tmp/.buildx-cache,mode=max --cache-from type=local,src=/tmp/.buildx-cache" \ + DOCKERX_OPTS="--push --platform ${{ steps.platform.outputs.platform }} --cache-to type=local,dest=/tmp/.buildx-cache,mode=max --cache-from type=local,src=/tmp/.buildx-cache" \ make - build-sources: - runs-on: ubuntu-latest needs: validate permissions: packages: write contents: read + runs-on: ${{ matrix.runner }} strategy: matrix: + runner: [ubuntu-latest, ubuntu-24.04-arm] component: [ { label: 'Change Router', @@ -198,7 +213,6 @@ jobs: path: 'sources/relational/sql-proxy', name: 'source-sql-proxy' }, - { label: 'CosmosDB Reactivator', path: './sources/cosmosdb/cosmosdb-ffcf-reactivator', @@ -240,14 +254,10 @@ jobs: name: 'source-kubernetes-proxy' } ] - steps: - name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - name: Set up QEMU - uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 - - name: Set up Docker Buildx uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1 with: @@ -260,20 +270,29 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Determine platform + id: platform + run: | + if [[ "${{ matrix.runner }}" == "ubuntu-latest" ]]; then + echo "platform=linux/amd64" >> $GITHUB_OUTPUT + elif [[ "${{ matrix.runner }}" == "ubuntu-24.04-arm" ]]; then + echo "platform=linux/arm64" >> $GITHUB_OUTPUT + fi + - name: Cache Docker layers uses: actions/cache@v4 with: path: /tmp/.buildx-cache - key: buildx-${{ matrix.component.name }} + key: buildx-${{ matrix.component.name }}-${{ matrix.runner }} restore-keys: | - buildx-${{ matrix.component.name }} + buildx-${{ matrix.component.name }}-${{ matrix.runner }} - name: Build and Push to GHCR run: | cd ${{ matrix.component.path }} DOCKER_TAG_VERSION=${{ inputs.tag }} \ IMAGE_PREFIX=${{ inputs.image_prefix }} \ - DOCKERX_OPTS="--push --platform linux/amd64,linux/arm64 --cache-to type=local,dest=/tmp/.buildx-cache,mode=max --cache-from type=local,src=/tmp/.buildx-cache" \ + DOCKERX_OPTS="--push --platform ${{ steps.platform.outputs.platform }} --cache-to type=local,dest=/tmp/.buildx-cache,mode=max --cache-from type=local,src=/tmp/.buildx-cache" \ make build-reactions: @@ -281,9 +300,10 @@ jobs: permissions: packages: write contents: read - runs-on: ubuntu-latest + runs-on: ${{ matrix.runner }} strategy: matrix: + runner: [ubuntu-latest, ubuntu-24.04-arm] component: [ { label: 'SignalR', @@ -344,9 +364,6 @@ jobs: - name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - name: Set up QEMU - uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 - - name: Set up Docker Buildx uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1 with: @@ -358,21 +375,31 @@ jobs: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - + + - name: Determine platform + id: platform + run: | + if [[ "${{ matrix.runner }}" == "ubuntu-latest" ]]; then + echo "platform=linux/amd64" >> $GITHUB_OUTPUT + elif [[ "${{ matrix.runner }}" == "ubuntu-24.04-arm" ]]; then + echo "platform=linux/arm64" >> $GITHUB_OUTPUT + fi + - name: Cache Docker layers uses: actions/cache@v4 with: path: /tmp/.buildx-cache - key: buildx-${{ matrix.component.name }} + key: buildx-${{ matrix.component.name }}-${{ matrix.runner }} restore-keys: | - buildx-${{ matrix.component.name }} + buildx-${{ matrix.component.name }}-${{ matrix.runner }} - name: Build and Push to GHCR + if: contains(matrix.component.platforms, steps.platform.outputs.platform) run: | cd ${{ matrix.component.path }} DOCKER_TAG_VERSION=${{ inputs.tag }} \ IMAGE_PREFIX=${{ inputs.image_prefix }} \ - DOCKERX_OPTS="--push --platform ${{ matrix.component.platforms }} --cache-to type=local,dest=/tmp/.buildx-cache,mode=max --cache-from type=local,src=/tmp/.buildx-cache" \ + DOCKERX_OPTS="--push --platform ${{ steps.platform.outputs.platform }} --cache-to type=local,dest=/tmp/.buildx-cache,mode=max --cache-from type=local,src=/tmp/.buildx-cache" \ make build-cli: @@ -436,7 +463,7 @@ jobs: run: | mkdir -p ${{ env.RELEASE_PATH}}/cli/${{ matrix.os }}-${{ matrix.arch }}/ cp -r ${{ matrix.os }}-${{ matrix.arch }}/drasi ${{ env.RELEASE_PATH}}/drasi-${{ matrix.os }}-${{ matrix.arch }} - - name: Copy cli binaries to release (non-windows) + - name: Copy cli binaries to release (windows) if: matrix.os == 'windows' run: | mkdir -p ${{ env.RELEASE_PATH}}/cli/${{ matrix.os }}-${{ matrix.arch }}/ @@ -473,7 +500,7 @@ jobs: with: name: drasi_vscode_extension path: ${{ env.RELEASE_PATH}} - + release: permissions: contents: write @@ -483,17 +510,17 @@ jobs: name: Draft Release needs: - validate - - build-sources - build-query-container - - build-reactions - build-control-plane - - package-cli + - build-sources + - build-reactions + - package-cli - vscode-extension runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - + - name: Download CLI release uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: @@ -510,4 +537,4 @@ jobs: - name: Draft Release run: | - gh release create ${{ inputs.tag }} ${{ env.RELEASE_PATH }}/* --draft --title ${{ inputs.tag }} --target ${{ github.ref_name }} --generate-notes + gh release create ${{ inputs.tag }} ${{ env.RELEASE_PATH }}/* --draft --title ${{ inputs.tag }} --target ${{ github.ref_name }} --generate-notes \ No newline at end of file