From 89b8cc354a504e174e448994ae7ab0113908ed38 Mon Sep 17 00:00:00 2001 From: raldone01 Date: Thu, 7 Mar 2024 23:15:46 +0100 Subject: [PATCH] Add a github workflow. --- .github/actions/project_build/action.yml | 35 +++++++ .github/workflows/meson.yml | 27 ------ .github/workflows/pull_requests.yml | 21 +++++ .github/workflows/releases.yml | 113 +++++++++++++++++++++++ 4 files changed, 169 insertions(+), 27 deletions(-) create mode 100644 .github/actions/project_build/action.yml delete mode 100644 .github/workflows/meson.yml create mode 100644 .github/workflows/pull_requests.yml create mode 100644 .github/workflows/releases.yml diff --git a/.github/actions/project_build/action.yml b/.github/actions/project_build/action.yml new file mode 100644 index 0000000..463c5bb --- /dev/null +++ b/.github/actions/project_build/action.yml @@ -0,0 +1,35 @@ +name: "Build with Meson and Ninja" +description: "Checks out code, sets up Python, and builds using Meson and Ninja" +inputs: + python-version: + description: "Python version to use" + required: true + default: "3.x" +runs: + using: "composite" + steps: + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: ${{ inputs.python-version }} + + - name: Install libraries + # run: apk add --no-cache vulkan-loader-dev libdrm-dev libpng-dev ninja-build meson + run: sudo apt-get install libvulkan-dev libdrm-dev libpng-dev ninja-build + shell: bash + + - name: Install Meson and Ninja + run: pip install meson + shell: bash + + - name: Configure build with Meson on linux + env: + # Customize the meson build type here (release, debug, debugoptimized, etc.) + BUILD_TYPE: release + run: | + meson setup builddir --buildtype=${{env.BUILD_TYPE}} + shell: bash + + - name: Compile + run: meson compile -C builddir + shell: bash diff --git a/.github/workflows/meson.yml b/.github/workflows/meson.yml deleted file mode 100644 index 11d9ff3..0000000 --- a/.github/workflows/meson.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: meson - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -env: - # Customize the meson build type here (release, debug, debugoptimized, etc.) - BUILD_TYPE: release - -jobs: - build: - runs-on: debian-latest - - steps: - - uses: actions/checkout@v3 - - - name: Configure CMake - # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. - # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: meson setup ${{github.workspace}}/build . --buildtype=${{env.BUILD_TYPE}} - - - name: Build - # Build your program with the given configuration - run: meson compile -C ${{github.workspace}}/build diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml new file mode 100644 index 0000000..379b194 --- /dev/null +++ b/.github/workflows/pull_requests.yml @@ -0,0 +1,21 @@ +name: Verify Pull Request + +permissions: + contents: read + +on: + pull_request: + branches: + - master + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + + - name: Build project action + uses: ./.github/actions/project_build diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml new file mode 100644 index 0000000..df12b38 --- /dev/null +++ b/.github/workflows/releases.yml @@ -0,0 +1,113 @@ +name: Release Releases for dxvk-tests + +permissions: + contents: write + +on: + push: + branches: + - master + tags: + - v[0-9]+.* + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + build_artifacts: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + + - name: Build project action + uses: ./.github/actions/project_build + + - name: Rename linux build artifacts + run: | + mv builddir/vkcube builddir/vkcube-linux + shell: bash + + - name: Upload build artifacts + uses: actions/upload-artifact@v2 + with: + name: build + path: | + builddir/vkcube-linux + if-no-files-found: error + + do_release: + runs-on: ubuntu-latest + needs: build_artifacts + + steps: + - name: Unpack build artifacts + uses: actions/download-artifact@v2 + with: + name: build + path: builddir + + - name: Delete existing latest_build Pre-Release + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { data: releases } = await github.rest.repos.listReleases({ + owner: context.repo.owner, + repo: context.repo.repo, + }); + for (const release of releases) { + if (release.prerelease && release.name.startsWith('Latest build of branch')) { + await github.rest.repos.deleteRelease({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: release.id, + }); + } + } + const { data: tags } = await github.rest.git.listMatchingRefs({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: 'tags/latest_build', + }); + if (tags.length > 0) + await github.rest.git.deleteRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: 'tags/latest_build', + }); + + - name: Check Tag Format + id: check_tag + if: startsWith(github.ref, 'refs/tags/') # Ensure this runs for tags only + run: | + if [[ "${{ github.ref_name }}" =~ ^v[0-9]+.*$ ]]; then + echo "tag_matches=true" >> $GITHUB_OUTPUT + else + echo "tag_matches=false" >> $GITHUB_OUTPUT + fi + shell: bash + + - name: Create latest build Pre-Release + if: steps.check_tag.outputs.tag_matches != 'true' + uses: ncipollo/release-action@v1 + with: + prerelease: true + draft: false + allowUpdates: true + removeArtifacts: true + name: Latest build of branch ${{ github.ref_name }} + commit: ${{ github.ref }} + tag: latest_build + artifacts: | + builddir/* + + - name: Create Tagged Release + if: steps.check_tag.outputs.tag_matches == 'true' + uses: ncipollo/release-action@v1 + with: + prerelease: false + removeArtifacts: true + name: Release ${{ github.ref_name }} + tag: ${{ github.ref_name }} + artifacts: | + builddir/*