From fdf030b26d8bf40b9014bef01a38d4c0deaa533b Mon Sep 17 00:00:00 2001 From: Richard Ward Date: Thu, 18 Dec 2025 23:45:54 +0000 Subject: [PATCH] tidy workflow --- .github/workflows/package-release.yml | 55 ++++++++++++ .github/workflows/publish-container.yml | 46 ++++++++++ .github/workflows/release.yml | 94 +++------------------ .github/workflows/upload-build-artifact.yml | 60 +++++++++++++ .gitignore | 1 + 5 files changed, 173 insertions(+), 83 deletions(-) create mode 100644 .github/workflows/package-release.yml create mode 100644 .github/workflows/publish-container.yml create mode 100644 .github/workflows/upload-build-artifact.yml diff --git a/.github/workflows/package-release.yml b/.github/workflows/package-release.yml new file mode 100644 index 0000000..7cbf84e --- /dev/null +++ b/.github/workflows/package-release.yml @@ -0,0 +1,55 @@ +name: Package Release + +on: + workflow_call: + +permissions: + contents: read + packages: write + releases: write + +jobs: + package-release: + strategy: + fail-fast: false + matrix: + include: + - name: linux-amd64 + runner: ubuntu-24.04 + platform: linux + arch: amd64 + - name: linux-arm64 + runner: ubuntu-24.04-arm64 + platform: linux + arch: arm64 + runs-on: ${{ matrix.runner }} + env: + BUILD_DIR: build/${{ matrix.platform }}-${{ matrix.arch }} + ZIP_NAME: sdl3_app-${{ matrix.platform }}-${{ matrix.arch }}.zip + PLATFORM_NAME: ${{ matrix.platform }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Download build artifact + uses: actions/download-artifact@v4 + with: + name: build-${{ matrix.platform }}-${{ matrix.arch }} + path: . + run-id: ${{ github.run_id }} + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Package release ZIP + run: python scripts/package_release.py + + - name: Publish GitHub release asset + if: github.ref != 'refs/tags/local' + uses: softprops/action-gh-release@v1 + with: + files: release/${{ env.ZIP_NAME }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish-container.yml b/.github/workflows/publish-container.yml new file mode 100644 index 0000000..2cfd567 --- /dev/null +++ b/.github/workflows/publish-container.yml @@ -0,0 +1,46 @@ +name: Publish Container Image + +on: + workflow_call: + +permissions: + contents: read + packages: write + +jobs: + publish-image: + strategy: + fail-fast: false + matrix: + include: + - name: linux-amd64 + runner: ubuntu-24.04 + platform: linux + arch: amd64 + - name: linux-arm64 + runner: ubuntu-24.04-arm64 + platform: linux + arch: arm64 + runs-on: ${{ matrix.runner }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and publish container image + run: | + docker build \ + --build-arg USERNAME=builder \ + --build-arg UID=$(id -u) \ + --build-arg GID=$(id -g) \ + -f .github/workflows/Dockerfile \ + -t sdl3_app:${{ matrix.platform }}-${{ matrix.arch }} . + IMAGE=ghcr.io/${{ github.repository_owner }}/sdl3_app:${{ matrix.platform }}-${{ matrix.arch }} + docker tag sdl3_app:${{ matrix.platform }}-${{ matrix.arch }} "$IMAGE" + docker push "$IMAGE" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d8587e3..5e38220 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,88 +8,16 @@ permissions: packages: write jobs: - release: - strategy: - fail-fast: false - matrix: - include: - - name: linux-amd64 - runner: ubuntu-24.04 - platform: linux - arch: amd64 - - name: linux-arm64 - runner: ubuntu-24.04-arm64 - platform: linux - arch: arm64 - runs-on: ${{ matrix.runner }} - env: - ZIP_NAME: sdl3_app-${{ matrix.platform }}-${{ matrix.arch }}.zip - BUILD_DIR: build/${{ matrix.platform }}-${{ matrix.arch }} - steps: - - name: Checkout - uses: actions/checkout@v4 + upload-build-artifact: + uses: ./.github/workflows/upload-build-artifact.yml + secrets: inherit - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.x' + package-release: + needs: upload-build-artifact + uses: ./.github/workflows/package-release.yml + secrets: inherit - - name: Create Python virtual environment - run: python -m venv .venv - - - name: Build linux container image - if: matrix.platform == 'linux' - run: | - docker build \ - --build-arg USERNAME=builder \ - --build-arg UID=$(id -u) \ - --build-arg GID=$(id -g) \ - -f .github/workflows/Dockerfile \ - -t sdl3_app:${{ matrix.platform }}-${{ matrix.arch }} . - - - name: Log in to GitHub Container Registry - if: matrix.platform == 'linux' - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Publish build image - if: matrix.platform == 'linux' - run: | - IMAGE=ghcr.io/${{ github.repository_owner }}/sdl3_app:${{ matrix.platform }}-${{ matrix.arch }} - docker tag sdl3_app:${{ matrix.platform }}-${{ matrix.arch }} "$IMAGE" - docker push "$IMAGE" - - - name: Run linux build in container - if: matrix.platform == 'linux' - env: - BUILD_DIR: ${{ env.BUILD_DIR }} - run: | - docker run --rm \ - -e BUILD_DIR \ - -w /workspace \ - -v "${{ github.workspace }}:/workspace" \ - sdl3_app:${{ matrix.platform }}-${{ matrix.arch }} \ - bash -c 'set -euo pipefail - if [ -d "$BUILD_DIR" ]; then rm -rf "$BUILD_DIR"; fi - cp -a /conan_build "$BUILD_DIR" - cmake -S . -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release - cmake --build "$BUILD_DIR" --config Release' - - - name: Package release ZIP - env: - PLATFORM_NAME: ${{ matrix.platform }} - shell: bash - run: | - . .venv/bin/activate - python scripts/package_release.py - - - name: Publish GitHub release asset - if: github.ref != 'refs/tags/local' - uses: softprops/action-gh-release@v1 - with: - files: release/${{ env.ZIP_NAME }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + publish-container: + needs: upload-build-artifact + uses: ./.github/workflows/publish-container.yml + secrets: inherit diff --git a/.github/workflows/upload-build-artifact.yml b/.github/workflows/upload-build-artifact.yml new file mode 100644 index 0000000..53f8a21 --- /dev/null +++ b/.github/workflows/upload-build-artifact.yml @@ -0,0 +1,60 @@ +name: Upload Build Artifacts + +on: + workflow_call: + +permissions: + contents: write + +jobs: + upload-artifact: + strategy: + fail-fast: false + matrix: + include: + - name: linux-amd64 + runner: ubuntu-24.04 + platform: linux + arch: amd64 + - name: linux-arm64 + runner: ubuntu-24.04-arm64 + platform: linux + arch: arm64 + runs-on: ${{ matrix.runner }} + env: + BUILD_DIR: build/${{ matrix.platform }}-${{ matrix.arch }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build linux container image + if: matrix.platform == 'linux' + run: | + docker build \ + --build-arg USERNAME=builder \ + --build-arg UID=$(id -u) \ + --build-arg GID=$(id -g) \ + -f .github/workflows/Dockerfile \ + -t sdl3_app:${{ matrix.platform }}-${{ matrix.arch }} . + + - name: Run linux build in container + if: matrix.platform == 'linux' + env: + BUILD_DIR: ${{ env.BUILD_DIR }} + run: | + docker run --rm \ + -e BUILD_DIR \ + -w /workspace \ + -v "${{ github.workspace }}:/workspace" \ + sdl3_app:${{ matrix.platform }}-${{ matrix.arch }} \ + bash -c 'set -euo pipefail + if [ -d "$BUILD_DIR" ]; then rm -rf "$BUILD_DIR"; fi + cp -a /conan_build "$BUILD_DIR" + cmake -S . -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release + cmake --build "$BUILD_DIR" --config Release' + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: build-${{ matrix.platform }}-${{ matrix.arch }} + path: ${{ env.BUILD_DIR }} diff --git a/.gitignore b/.gitignore index 98586b8..1d81239 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ venv/ env/ vendor/ +build/