From 2c8e371ad228b459d6be3e1e709842d1829762e4 Mon Sep 17 00:00:00 2001 From: Mikhail Malyshev Date: Sat, 29 Mar 2025 10:42:56 +0100 Subject: [PATCH 1/3] Reformat with YAML LSP Signed-off-by: Mikhail Malyshev --- .github/workflows/mainbuild.yaml | 72 +++++++++++++------------- .github/workflows/prbuild.yaml | 86 ++++++++++++++++---------------- .github/workflows/release.yaml | 78 ++++++++++++++--------------- 3 files changed, 116 insertions(+), 120 deletions(-) diff --git a/.github/workflows/mainbuild.yaml b/.github/workflows/mainbuild.yaml index 8343c22..b984e99 100644 --- a/.github/workflows/mainbuild.yaml +++ b/.github/workflows/mainbuild.yaml @@ -1,38 +1,36 @@ --- - name: main build - on: - push: - branches: - - "main" - - - jobs: - build: - runs-on: ubuntu-latest - strategy: - fail-fast: false - steps: - - name: Starting Report - run: | - echo Git Ref: ${{ github.event.head_commit.id }} - echo GitHub Event: ${{ github.event_name }} - echo Disk usage - df -h - echo Memory - free -m - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - uses: docker/build-push-action@v5 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: false - tags: | - ${{ github.event.repository.full_name }}:${{ github.event.head_commit.id }} - ${{ github.event.repository.full_name }}:latest - \ No newline at end of file +name: main build +on: + push: + branches: + - "main" + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: Starting Report + run: | + echo Git Ref: ${{ github.event.head_commit.id }} + echo GitHub Event: ${{ github.event_name }} + echo Disk usage + df -h + echo Memory + free -m + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: false + tags: | + ${{ github.event.repository.full_name }}:${{ github.event.head_commit.id }} + ${{ github.event.repository.full_name }}:latest diff --git a/.github/workflows/prbuild.yaml b/.github/workflows/prbuild.yaml index b8f258f..058a9dc 100644 --- a/.github/workflows/prbuild.yaml +++ b/.github/workflows/prbuild.yaml @@ -1,45 +1,43 @@ --- - name: PR build - on: - pull_request_target: - paths-ignore: - - '.github/workflows/**' - branches: - - "main" - - - concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number }} - cancel-in-progress: true - - jobs: - build: - runs-on: ubuntu-latest - strategy: - fail-fast: false - steps: - - name: Starting Report - run: | - echo Git Ref: ${{ github.event.pull_request.head.ref }} - echo GitHub Event: ${{ github.event_name }} - echo Disk usage - df -h - echo Memory - free -m - - uses: actions/checkout@v4 - with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} - fetch-depth: 0 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - uses: docker/build-push-action@v5 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: false - tags: | - ${{ github.event.pull_request.head.repo.full_name }}:latest - \ No newline at end of file +name: PR build +on: + pull_request_target: + paths-ignore: + - ".github/workflows/**" + branches: + - "main" + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: Starting Report + run: | + echo Git Ref: ${{ github.event.pull_request.head.ref }} + echo GitHub Event: ${{ github.event_name }} + echo Disk usage + df -h + echo Memory + free -m + - uses: actions/checkout@v4 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} + fetch-depth: 0 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: false + tags: | + ${{ github.event.pull_request.head.repo.full_name }}:latest diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 13fe6ed..4ed0e97 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -5,7 +5,7 @@ on: - "[0-9]+.[0-9]+.[0-9]+" - "[0-9]+.[0-9]+.[0-9]+-[0-9]+" paths-ignore: - - '.github/workflows/**' + - ".github/workflows/**" env: OCIREPO: lfedge/eve-rust @@ -16,41 +16,41 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Get rust version - id: rust_version - run: | - RUST_VERSION=$(awk -F= '/ARG RUST_VERSION/ {print $2}' Dockerfile) - # make sure we got a rust version - if [ -z "$RUST_VERSION" ]; then - echo "Failed to get RUST_VERSION" - exit 1 - fi - # strip off any potential eve-specific extensions to the tag - TAG="${{ github.ref_name }}" - TAG="${TAG%%-*}" - if [ "$TAG" != "$RUST_VERSION" ]; then - echo "Tag $TAG does not match RUST_VERSION $RUST_VERSION" - exit 1 - fi - echo "::set-output name=RUST_VERSION::$RUST_VERSION" - - name: Login to Docker Hub - if: ${{ github.event.repository.full_name }} == 'lf-edge/eve-rust' - uses: docker/login-action@v3 - with: - username: ${{ secrets.RELEASE_DOCKERHUB_ACCOUNT }} - password: ${{ secrets.RELEASE_DOCKERHUB_TOKEN }} - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - uses: docker/build-push-action@v5 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: true - tags: | - ${{ env.OCIREPO }}:${{ steps.rust_version.outputs.RUST_VERSION }} - ${{ env.OCIREPO }}:latest + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Get rust version + id: rust_version + run: | + RUST_VERSION=$(awk -F= '/ARG RUST_VERSION/ {print $2}' Dockerfile) + # make sure we got a rust version + if [ -z "$RUST_VERSION" ]; then + echo "Failed to get RUST_VERSION" + exit 1 + fi + # strip off any potential eve-specific extensions to the tag + TAG="${{ github.ref_name }}" + TAG="${TAG%%-*}" + if [ "$TAG" != "$RUST_VERSION" ]; then + echo "Tag $TAG does not match RUST_VERSION $RUST_VERSION" + exit 1 + fi + echo "::set-output name=RUST_VERSION::$RUST_VERSION" + - name: Login to Docker Hub + if: ${{ github.event.repository.full_name }} == 'lf-edge/eve-rust' + uses: docker/login-action@v3 + with: + username: ${{ secrets.RELEASE_DOCKERHUB_ACCOUNT }} + password: ${{ secrets.RELEASE_DOCKERHUB_TOKEN }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ${{ env.OCIREPO }}:${{ steps.rust_version.outputs.RUST_VERSION }} + ${{ env.OCIREPO }}:latest From d043ed920260e57f4412cce1647666ba7c2bd5e4 Mon Sep 17 00:00:00 2001 From: Mikhail Malyshev Date: Sat, 29 Mar 2025 10:45:19 +0100 Subject: [PATCH 2/3] Add matrix which is now required Signed-off-by: Mikhail Malyshev --- .github/workflows/mainbuild.yaml | 4 +++- .github/workflows/prbuild.yaml | 4 +++- .github/workflows/release.yaml | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/mainbuild.yaml b/.github/workflows/mainbuild.yaml index b984e99..88bcf93 100644 --- a/.github/workflows/mainbuild.yaml +++ b/.github/workflows/mainbuild.yaml @@ -7,8 +7,10 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: + matrix: + os: [ubuntu-latest] fail-fast: false steps: - name: Starting Report diff --git a/.github/workflows/prbuild.yaml b/.github/workflows/prbuild.yaml index 058a9dc..cd66925 100644 --- a/.github/workflows/prbuild.yaml +++ b/.github/workflows/prbuild.yaml @@ -13,8 +13,10 @@ concurrency: jobs: build: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: + matrix: + os: [ubuntu-latest] fail-fast: false steps: - name: Starting Report diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 4ed0e97..3c9d36a 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -12,8 +12,10 @@ env: jobs: build_and_push: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: + matrix: + os: [ubuntu-latest] fail-fast: false steps: - uses: actions/checkout@v4 From 3211faf8a09ac11d19a136792e0aff6126b15994 Mon Sep 17 00:00:00 2001 From: Michael Malyshev Date: Fri, 28 Mar 2025 15:40:40 +0100 Subject: [PATCH 3/3] Use GIT tag as is for docker tag - we should use git tag e.g. 1.84.1-1 as docker tag and not a rust version e.g. 1.84.1 Signed-off-by: Mikhail Malyshev --- .github/workflows/release.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3c9d36a..43e638a 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -37,7 +37,7 @@ jobs: echo "Tag $TAG does not match RUST_VERSION $RUST_VERSION" exit 1 fi - echo "::set-output name=RUST_VERSION::$RUST_VERSION" + echo "::set-output name=IMAGE_TAG::${{ github.ref_name }}" - name: Login to Docker Hub if: ${{ github.event.repository.full_name }} == 'lf-edge/eve-rust' uses: docker/login-action@v3 @@ -54,5 +54,5 @@ jobs: platforms: linux/amd64,linux/arm64 push: true tags: | - ${{ env.OCIREPO }}:${{ steps.rust_version.outputs.RUST_VERSION }} + ${{ env.OCIREPO }}:${{ steps.rust_version.outputs.IMAGE_TAG }} ${{ env.OCIREPO }}:latest