From b22e15d26dfa740fd5fc2d7e775768859353c612 Mon Sep 17 00:00:00 2001 From: Alexander Reichert Date: Tue, 9 Jan 2024 19:00:58 +0100 Subject: [PATCH] github: add workflows for pr, develop, release --- .github/workflows/build.yml | 43 +++++++++++++++++++++ .github/workflows/deploy.yml | 41 ++++++++++++++++++++ .github/workflows/develop.workflow.yml | 20 ++++++++++ .github/workflows/pull-request.workflow.yml | 13 +++++++ .github/workflows/release.workflow.yml | 20 ++++++++++ .github/workflows/test.yml | 26 +++++++++++++ 6 files changed, 163 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/develop.workflow.yml create mode 100644 .github/workflows/pull-request.workflow.yml create mode 100644 .github/workflows/release.workflow.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..c6970b6 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,43 @@ +name: Build + +on: + workflow_call: + inputs: + build-type: + required: true + type: string + +jobs: + build: + runs-on: ubuntu-22.04 + container: flecspublic.azurecr.io/flecs-build + + strategy: + matrix: + arch: ["amd64", "armhf", "arm64"] + + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: "CMake: Configure" + run: | + cmake -G Ninja -B build/${{ matrix.arch }} -DARCH=${{ matrix.arch }} -DCMAKE_BUILD_TYPE=${{ inputs.build-type }} -DCMAKE_INSTALL_PREFIX=out/${{ matrix.arch }} + - name: "CMake: Build" + run: | + cmake --build build/${{ matrix.arch }} + - name: "CMake: Install" + run: | + cmake --build build/${{ matrix.arch }} --target install + - name: "CMake: Packages" + run: | + cmake --build build/${{ matrix.arch }} --target package + - name: "Archive packages" + uses: actions/upload-artifact@v3 + with: + name: packages_${{ matrix.arch }} + path: | + build/${{ matrix.arch }}/*.deb + build/${{ matrix.arch }}/*.tar.gz + build/${{ matrix.arch }}/latest_* + retention-days: 1 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..1879e8e --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,41 @@ +name: Deploy + +on: + workflow_call: + inputs: + deploy-type: + required: true + type: string + +jobs: + test: + runs-on: ubuntu-22.04 + + steps: + - name: Download packages + uses: actions/download-artifact@v3 + with: + path: build/ + + - name: Azure Login + uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + - name: Deploy packages and latest files + uses: azure/CLI@v1 + with: + azcliversion: 2.53.0 + inlineScript: | + for i in `find build/ -mindepth 1 -maxdepth 1 -name "*.deb"`; do \ + echo "Uploading ${i}"; \ + az storage blob upload --account-name flecs --container-name flecs-dl --name ${{ inputs.deploy-type }}/libflunder/deb/$(basename ${i}) --file ${i} --overwrite + done + for i in `find build/ -mindepth 1 -maxdepth 1 -name "*.tar.gz"`; do \ + echo "Uploading ${i}"; \ + az storage blob upload --account-name flecs --container-name flecs-dl --name ${{ inputs.deploy-type }}/libflunder/tgz/$(basename ${i}) --file ${i} --overwrite + done + for i in `find build/ -mindepth 1 -maxdepth 1 -name "latest_*"`; do \ + echo "Uploading ${i}"; \ + az storage blob upload --account-name flecs --container-name flecs-dl --name ${{ inputs.deploy-type }}/libflunder/$(basename ${i}) --file ${i} --overwrite + done diff --git a/.github/workflows/develop.workflow.yml b/.github/workflows/develop.workflow.yml new file mode 100644 index 0000000..71186f8 --- /dev/null +++ b/.github/workflows/develop.workflow.yml @@ -0,0 +1,20 @@ +name: Develop + +on: + workflow_dispatch: + push: + branches: [main] + +jobs: + build: + uses: ./.github/workflows/build.yml + with: + build-type: Debug + test: + uses: ./.github/workflows/test.yml + deploy: + needs: [build, test] + uses: ./.github/workflows/deploy.yml + with: + deploy-type: dev + secrets: inherit diff --git a/.github/workflows/pull-request.workflow.yml b/.github/workflows/pull-request.workflow.yml new file mode 100644 index 0000000..582606a --- /dev/null +++ b/.github/workflows/pull-request.workflow.yml @@ -0,0 +1,13 @@ +name: Pull request + +on: + pull_request: + branches: [main] + +jobs: + build: + uses: ./.github/workflows/build.yml + with: + build-type: Debug + test: + uses: ./.github/workflows/test.yml diff --git a/.github/workflows/release.workflow.yml b/.github/workflows/release.workflow.yml new file mode 100644 index 0000000..20cec94 --- /dev/null +++ b/.github/workflows/release.workflow.yml @@ -0,0 +1,20 @@ +name: Release + +on: + workflow_dispatch: + release: + types: [published] + +jobs: + build: + uses: ./.github/workflows/build.yml + with: + build-type: Release + test: + uses: ./.github/workflows/test.yml + deploy: + needs: [build, test] + uses: ./.github/workflows/deploy.yml + with: + deploy-type: public + secrets: inherit diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..f9d5cfe --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,26 @@ +name: Test + +on: + workflow_call: + +jobs: + test: + runs-on: ubuntu-22.04 + container: flecspublic.azurecr.io/flecs-build + + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: "CMake: Configure" + run: | + cmake -G Ninja -B build/test -DCMAKE_BUILD_TYPE=RelWithDebInfo -DFLECS_BUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=out/test + - name: "CMake: Build" + run: | + cmake --build build/test + - name: "CMake: Test" + run: | + cmake --build build/test --target test + - name: "CMake: Coverage" + run: | + cmake --build build/test --target coverage