From e4b0e3b7583af0a6241b41240d1f69dbe5581d70 Mon Sep 17 00:00:00 2001 From: David Eadie Date: Fri, 11 Oct 2024 20:44:23 +0100 Subject: [PATCH 1/6] Split Hub releases into multiple steps --- .github/workflows/hub.yml | 83 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 78 insertions(+), 5 deletions(-) diff --git a/.github/workflows/hub.yml b/.github/workflows/hub.yml index d4f804cd..30291c8a 100644 --- a/.github/workflows/hub.yml +++ b/.github/workflows/hub.yml @@ -94,10 +94,84 @@ jobs: migrate info - release: - name: Release + overall-build: + name: Overall Build + needs: + - build-gateway + - build-replay-processor + - build-database runs-on: ubuntu-latest - needs: [build-gateway, build-replay-processor, build-database] + steps: + - name: Check + run: echo "Checked" + + release-gateway-github: + name: Release - Gateway - GitHub + runs-on: ubuntu-latest + needs: overall-build + if: github.ref == 'refs/heads/main' + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Release + run: | + make gateway.release.github GITHUB_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }} + + release-gateway-dockerhub: + name: Release - Gateway - DockerHub + runs-on: ubuntu-latest + needs: overall-build + if: github.ref == 'refs/heads/main' + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Expose GitHub Runtime + uses: crazy-max/ghaction-github-runtime@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: theeadie + password: ${{ secrets.DockerHubAccessToken }} + + - name: Release + run: | + make gateway.release.dockerhub + + release-replay-processor-github: + name: Release - Replay Processor - GitHub + runs-on: ubuntu-latest + needs: overall-build + if: github.ref == 'refs/heads/main' + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Release + run: | + make replay-processor.release.github GITHUB_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }} + + release-replay-processor-dockerhub: + name: Release - Replay Processor - DockerHub + runs-on: ubuntu-latest + needs: overall-build if: github.ref == 'refs/heads/main' steps: @@ -123,5 +197,4 @@ jobs: - name: Release run: | - make gateway.release GITHUB_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }} - make replay-processor.release GITHUB_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }} + make replay-processor.release.dockerhub From cd0ea1fb1fbe85c933bcf6cf1ffbebbb71551fc4 Mon Sep 17 00:00:00 2001 From: David Eadie Date: Fri, 11 Oct 2024 20:56:45 +0100 Subject: [PATCH 2/6] Split hub build into 2 files --- .github/workflows/hub-build.yml | 98 +++++++++++++++ .github/workflows/hub-release.yml | 95 +++++++++++++++ .github/workflows/hub.yml | 194 ++---------------------------- 3 files changed, 201 insertions(+), 186 deletions(-) create mode 100644 .github/workflows/hub-build.yml create mode 100644 .github/workflows/hub-release.yml diff --git a/.github/workflows/hub-build.yml b/.github/workflows/hub-build.yml new file mode 100644 index 00000000..7f3924a4 --- /dev/null +++ b/.github/workflows/hub-build.yml @@ -0,0 +1,98 @@ +name: Hub - Build + +on: + workflow_call: + +jobs: + build-gateway: + name: Gateway + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Expose GitHub Runtime + uses: crazy-max/ghaction-github-runtime@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Package + run: | + make gateway.package + + build-replay-processor: + name: Replay Processor + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Expose GitHub Runtime + uses: crazy-max/ghaction-github-runtime@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Package + run: | + make replay-processor.package + + build-database: + name: Database + runs-on: ubuntu-latest + env: + FLYWAY_EMAIL: ${{ secrets.FLYWAY_EMAIL }} + FLYWAY_TOKEN: ${{ secrets.FLYWAY_TOKEN }} + + services: + postgres: + image: postgres:15 + env: + POSTGRES_USER: worms + POSTGRES_PASSWORD: worms + POSTGRES_DB: worms + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Test Flyway Migrations + uses: docker://redgate/flyway:10 + with: + args: >- + -workingDirectory=/github/workspace/src/database + -environment=build + info + migrate + info + + overall-build: + name: Overall Build + needs: + - build-gateway + - build-replay-processor + - build-database + runs-on: ubuntu-latest + steps: + - name: Check + run: echo "Checked" diff --git a/.github/workflows/hub-release.yml b/.github/workflows/hub-release.yml new file mode 100644 index 00000000..5c739189 --- /dev/null +++ b/.github/workflows/hub-release.yml @@ -0,0 +1,95 @@ +name: Hub - Release + +on: + workflow_call: + +jobs: + release-gateway-github: + name: Gateway - GitHub + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Release + run: | + make gateway.release.github GITHUB_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }} + + release-gateway-dockerhub: + name: Gateway - DockerHub + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Expose GitHub Runtime + uses: crazy-max/ghaction-github-runtime@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: theeadie + password: ${{ secrets.DockerHubAccessToken }} + + - name: Release + run: | + make gateway.release.dockerhub + + release-replay-processor-github: + name: Replay Processor - GitHub + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Release + run: | + make replay-processor.release.github GITHUB_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }} + + release-replay-processor-dockerhub: + name: Replay Processor - DockerHub + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Expose GitHub Runtime + uses: crazy-max/ghaction-github-runtime@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: theeadie + password: ${{ secrets.DockerHubAccessToken }} + + - name: Release + run: | + make replay-processor.release.dockerhub diff --git a/.github/workflows/hub.yml b/.github/workflows/hub.yml index 30291c8a..304b6d4c 100644 --- a/.github/workflows/hub.yml +++ b/.github/workflows/hub.yml @@ -12,189 +12,11 @@ on: - ".github/workflows/hub.yml" jobs: - build-gateway: - name: Package - Gateway - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Expose GitHub Runtime - uses: crazy-max/ghaction-github-runtime@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Package - run: | - make gateway.package - - build-replay-processor: - name: Package - Replay Processor - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Expose GitHub Runtime - uses: crazy-max/ghaction-github-runtime@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Package - run: | - make replay-processor.package - - build-database: - name: Build - Database - runs-on: ubuntu-latest - env: - FLYWAY_EMAIL: ${{ secrets.FLYWAY_EMAIL }} - FLYWAY_TOKEN: ${{ secrets.FLYWAY_TOKEN }} - - services: - postgres: - image: postgres:15 - env: - POSTGRES_USER: worms - POSTGRES_PASSWORD: worms - POSTGRES_DB: worms - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 5432:5432 - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Test Flyway Migrations - uses: docker://redgate/flyway:10 - with: - args: >- - -workingDirectory=/github/workspace/src/database - -environment=build - info - migrate - info - - overall-build: - name: Overall Build - needs: - - build-gateway - - build-replay-processor - - build-database - runs-on: ubuntu-latest - steps: - - name: Check - run: echo "Checked" - - release-gateway-github: - name: Release - Gateway - GitHub - runs-on: ubuntu-latest - needs: overall-build - if: github.ref == 'refs/heads/main' - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Release - run: | - make gateway.release.github GITHUB_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }} - - release-gateway-dockerhub: - name: Release - Gateway - DockerHub - runs-on: ubuntu-latest - needs: overall-build - if: github.ref == 'refs/heads/main' - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Expose GitHub Runtime - uses: crazy-max/ghaction-github-runtime@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to DockerHub - uses: docker/login-action@v3 - with: - username: theeadie - password: ${{ secrets.DockerHubAccessToken }} - - - name: Release - run: | - make gateway.release.dockerhub - - release-replay-processor-github: - name: Release - Replay Processor - GitHub - runs-on: ubuntu-latest - needs: overall-build - if: github.ref == 'refs/heads/main' - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Release - run: | - make replay-processor.release.github GITHUB_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }} - - release-replay-processor-dockerhub: - name: Release - Replay Processor - DockerHub - runs-on: ubuntu-latest - needs: overall-build - if: github.ref == 'refs/heads/main' - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Expose GitHub Runtime - uses: crazy-max/ghaction-github-runtime@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to DockerHub - uses: docker/login-action@v3 - with: - username: theeadie - password: ${{ secrets.DockerHubAccessToken }} - - - name: Release - run: | - make replay-processor.release.dockerhub + build: + name: Build + uses: ./.github/workflows/hub-build.yml + + release: + name: Release + needs: build + uses: ./.github/workflows/hub-release.yml From 37d1f871ed360dd50f1b0a6fd145f822231a87e1 Mon Sep 17 00:00:00 2001 From: David Eadie Date: Fri, 11 Oct 2024 21:00:02 +0100 Subject: [PATCH 3/6] Remove overall build --- .github/workflows/hub-build.yml | 11 ----------- .github/workflows/hub.yml | 2 ++ 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/hub-build.yml b/.github/workflows/hub-build.yml index 7f3924a4..509104f6 100644 --- a/.github/workflows/hub-build.yml +++ b/.github/workflows/hub-build.yml @@ -85,14 +85,3 @@ jobs: info migrate info - - overall-build: - name: Overall Build - needs: - - build-gateway - - build-replay-processor - - build-database - runs-on: ubuntu-latest - steps: - - name: Check - run: echo "Checked" diff --git a/.github/workflows/hub.yml b/.github/workflows/hub.yml index 304b6d4c..e6700154 100644 --- a/.github/workflows/hub.yml +++ b/.github/workflows/hub.yml @@ -10,6 +10,8 @@ on: - "build/release-github.sh" - "build/version.sh" - ".github/workflows/hub.yml" + - ".github/workflows/hub-*.yml" + jobs: build: From 5144f4f91244496351845059926116e397d014b2 Mon Sep 17 00:00:00 2001 From: David Eadie Date: Fri, 11 Oct 2024 21:05:25 +0100 Subject: [PATCH 4/6] Don't show Release steps for branches --- .github/workflows/hub-branch.yml | 21 +++++++++++++++++++++ .github/workflows/{hub.yml => hub-main.yml} | 5 +++-- 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/hub-branch.yml rename .github/workflows/{hub.yml => hub-main.yml} (89%) diff --git a/.github/workflows/hub-branch.yml b/.github/workflows/hub-branch.yml new file mode 100644 index 00000000..29cf9580 --- /dev/null +++ b/.github/workflows/hub-branch.yml @@ -0,0 +1,21 @@ +name: Hub - Branches + +on: + push: + branches-ignore: + - "main" + paths: + - "src/Directory.Build.props" + - "src/Worms.Hub*/**" + - "src/database/**" + - "build/docker/**" + - "build/release-github.sh" + - "build/version.sh" + - ".github/workflows/hub-*.yml" + + +jobs: + build: + name: Build + uses: ./.github/workflows/hub-build.yml + diff --git a/.github/workflows/hub.yml b/.github/workflows/hub-main.yml similarity index 89% rename from .github/workflows/hub.yml rename to .github/workflows/hub-main.yml index e6700154..a139e202 100644 --- a/.github/workflows/hub.yml +++ b/.github/workflows/hub-main.yml @@ -1,7 +1,9 @@ -name: Hub +name: Hub - Main on: push: + branches: + - "main" paths: - "src/Directory.Build.props" - "src/Worms.Hub*/**" @@ -9,7 +11,6 @@ on: - "build/docker/**" - "build/release-github.sh" - "build/version.sh" - - ".github/workflows/hub.yml" - ".github/workflows/hub-*.yml" From ee9e90ec658d261bf3c2365f9460219c0754090d Mon Sep 17 00:00:00 2001 From: David Eadie Date: Fri, 11 Oct 2024 21:32:51 +0100 Subject: [PATCH 5/6] Add conditional release based on files changed --- .github/workflows/hub-branch.yml | 4 +++ .github/workflows/hub-release.yml | 41 ++++++++++++++++++++++++++++--- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/.github/workflows/hub-branch.yml b/.github/workflows/hub-branch.yml index 29cf9580..f931d487 100644 --- a/.github/workflows/hub-branch.yml +++ b/.github/workflows/hub-branch.yml @@ -19,3 +19,7 @@ jobs: name: Build uses: ./.github/workflows/hub-build.yml + release: + name: Release + needs: build + uses: ./.github/workflows/hub-release.yml diff --git a/.github/workflows/hub-release.yml b/.github/workflows/hub-release.yml index 5c739189..4e9fcd1c 100644 --- a/.github/workflows/hub-release.yml +++ b/.github/workflows/hub-release.yml @@ -4,10 +4,40 @@ on: workflow_call: jobs: + + changes: + name: Detect Changes + runs-on: ubuntu-latest + outputs: + gateway: ${{ steps.filter.outputs.gateway || steps.filter.outputs.common }} + replay-processor: ${{ steps.filter.outputs.replay-processor || steps.filter.outputs.common }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Filter + uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + gateway: + - 'src/Worms.Hub.Gateway/**' + - 'src/Worms.Hub.Storage/**' + replay-processor: + - 'src/Worms.Hub.ReplayProcessor/**' + - 'src/Worms.Hub.Storage/**' + - 'src/Worms.Armageddon.Game/**' + common: + - 'src/Directory.Build.props' + - '.github/workflows/hub-*.yml' + - 'build/docker/**' + release-gateway-github: name: Gateway - GitHub runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' + needs: changes + if: ${{ needs.changes.outputs.gateway == 'true' && github.ref == 'refs/heads/main' }} steps: - name: Checkout @@ -22,7 +52,8 @@ jobs: release-gateway-dockerhub: name: Gateway - DockerHub runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' + needs: changes + if: ${{ needs.changes.outputs.gateway == 'true' && github.ref == 'refs/heads/main' }} steps: - name: Checkout @@ -52,7 +83,8 @@ jobs: release-replay-processor-github: name: Replay Processor - GitHub runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' + needs: changes + if: ${{ needs.changes.outputs.replay-processor == 'true' && github.ref == 'refs/heads/main' }} steps: - name: Checkout @@ -67,7 +99,8 @@ jobs: release-replay-processor-dockerhub: name: Replay Processor - DockerHub runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' + needs: changes + if: ${{ needs.changes.outputs.replay-processor == 'true' && github.ref == 'refs/heads/main' }} steps: - name: Checkout From db2a75f2d0a7ce9c3efad9e3678dbbdbf2c75f06 Mon Sep 17 00:00:00 2001 From: David Eadie Date: Fri, 11 Oct 2024 21:51:58 +0100 Subject: [PATCH 6/6] Run Hub builds on all commits --- .github/workflows/hub-branch.yml | 14 -------------- .github/workflows/hub-main.yml | 9 --------- 2 files changed, 23 deletions(-) diff --git a/.github/workflows/hub-branch.yml b/.github/workflows/hub-branch.yml index f931d487..3f824e8c 100644 --- a/.github/workflows/hub-branch.yml +++ b/.github/workflows/hub-branch.yml @@ -4,22 +4,8 @@ on: push: branches-ignore: - "main" - paths: - - "src/Directory.Build.props" - - "src/Worms.Hub*/**" - - "src/database/**" - - "build/docker/**" - - "build/release-github.sh" - - "build/version.sh" - - ".github/workflows/hub-*.yml" - jobs: build: name: Build uses: ./.github/workflows/hub-build.yml - - release: - name: Release - needs: build - uses: ./.github/workflows/hub-release.yml diff --git a/.github/workflows/hub-main.yml b/.github/workflows/hub-main.yml index a139e202..faf18558 100644 --- a/.github/workflows/hub-main.yml +++ b/.github/workflows/hub-main.yml @@ -4,15 +4,6 @@ on: push: branches: - "main" - paths: - - "src/Directory.Build.props" - - "src/Worms.Hub*/**" - - "src/database/**" - - "build/docker/**" - - "build/release-github.sh" - - "build/version.sh" - - ".github/workflows/hub-*.yml" - jobs: build: