From b528cf2e298822945909016d4ccb161e687cc2c4 Mon Sep 17 00:00:00 2001 From: Lucas Girouard-Stranks <519592+lithiumtoast@users.noreply.github.com> Date: Sat, 5 Aug 2023 22:32:49 -0400 Subject: [PATCH] Update GitHub actions --- .github/workflows/bindgen.yml | 7 ++- .github/workflows/build.yml | 21 ++++--- .github/workflows/commit.yml | 6 +- .../workflows/{pr.yml => pull-request.yml} | 0 .github/workflows/release.yml | 55 +++++++++++++++++++ 5 files changed, 76 insertions(+), 13 deletions(-) rename .github/workflows/{pr.yml => pull-request.yml} (100%) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/bindgen.yml b/.github/workflows/bindgen.yml index 4441ac2..4416c18 100644 --- a/.github/workflows/bindgen.yml +++ b/.github/workflows/bindgen.yml @@ -1,6 +1,7 @@ name: "Bindgen" on: + workflow_dispatch: workflow_call: jobs: @@ -14,7 +15,7 @@ jobs: platform: - { name: Windows, os: windows-latest, rid: win } - { name: macOS, os: macos-latest, rid: osx } - - { name: Linux, os: ubuntu-20.04, rid: linux } + - { name: Linux, os: ubuntu-latest, rid: linux } steps: - name: "Clone Git repository" @@ -28,7 +29,7 @@ jobs: - name: "Read C code: Linux dependencies" if: runner.os == 'Linux' - run: sudo apt-get install gcc-aarch64-linux-gnu + run: sudo apt-get update && sudo apt-get install gcc-aarch64-linux-gnu - name: "Read C code: extract ${{ matrix.platform.rid }}" shell: bash @@ -112,4 +113,4 @@ jobs: uses: actions/upload-artifact@v2 with: name: "bindgen-cs" - path: "./src/cs/production/ImGui/PInvoke.gen.cs" + path: "./src/cs/production/Interop.ImGui/PInvoke.gen.cs" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0a0e5a7..b723a77 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,7 @@ -name: "Build .NET solution" +name: "Build" on: + workflow_dispatch: workflow_call: push: tags: @@ -29,16 +30,20 @@ jobs: with: submodules: "recursive" + - name: "Install C2CS" + shell: bash + run: dotnet tool install --global bottlenoselabs.C2CS.Tool + + - name: "Get C2CS version" + shell: bash + run: echo "C2CS_VERSION=$(c2cs --version)" >> $GITHUB_ENV + - name: "Cache native libraries" id: cache-libs uses: actions/cache@v3 with: path: "./lib" - key: "libs-${{ matrix.platform.rid }}-${{ hashFiles('ext/cimgui/**/*') }}-${{ hashFiles('src/c/**/*') }}" - - - name: "Install C2CS" - shell: bash - run: dotnet tool install --global bottlenoselabs.C2CS.Tool + key: "libs-${{ matrix.platform.rid }}-${{ hashFiles('ext/cimgui/**/*') }}-${{ hashFiles('src/c/**/*') }}-${{ hashFiles('bindgen/**/*') }}-${{ env.C2CS_VERSION }}" - name: "Build native libraries" if: steps.cache-libs.outputs.cache-hit != 'true' @@ -59,6 +64,8 @@ jobs: - name: "Clone Git repository" uses: actions/checkout@master + with: + submodules: 'true' - name: "Download native libraries (win-x64)" uses: actions/download-artifact@v1 @@ -86,5 +93,5 @@ jobs: path: "./src/cs/production/ImGui" - name: ".NET Build" - run: dotnet build "./src/cs" + run: dotnet build "./src/cs" --nologo --verbosity minimal --configuration Release -p:PackageVersion="$(date +'%Y.%m.%d')" diff --git a/.github/workflows/commit.yml b/.github/workflows/commit.yml index abf8ead..65905e5 100644 --- a/.github/workflows/commit.yml +++ b/.github/workflows/commit.yml @@ -1,4 +1,4 @@ -name: "Commit generated C# code" +name: "Commit generated code" on: workflow_call: @@ -22,11 +22,11 @@ jobs: uses: actions/download-artifact@v1 with: name: "bindgen-cs" - path: "./src/cs/production/ImGui" + path: "./src/cs/production/Interop.ImGui" - name: "Add + commit + push (if necessary)" uses: EndBug/add-and-commit@v7 with: author_name: 'lithiumtoast' - author_email: 'lithiumtoast@users.noreply.github.com' + author_email: '519592+lithiumtoast@users.noreply.github.com' message: "Update C# bindings" diff --git a/.github/workflows/pr.yml b/.github/workflows/pull-request.yml similarity index 100% rename from .github/workflows/pr.yml rename to .github/workflows/pull-request.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..5a6bd1a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,55 @@ +name: "Release" +on: + workflow_dispatch: + schedule: + - cron: "0 0 1 * *" # First day of every month + +jobs: + + build-job: + name: "Build" + uses: "./.github/workflows/build.yml" + + release-job: + name: "Release .NET solution" + needs: [build-job] + runs-on: ubuntu-latest + steps: + + - name: "Clone Git repository" + uses: actions/checkout@master + with: + submodules: "recursive" + + - name: "Download native libraries (win-x64)" + uses: actions/download-artifact@v1 + with: + name: "native-libraries-win-x64" + path: "./lib" + + - name: "Download native libraries (osx)" + uses: actions/download-artifact@v1 + with: + name: "native-libraries-osx" + path: "./lib" + + - name: "Download native libraries (linux-x64)" + uses: actions/download-artifact@v1 + with: + name: "native-libraries-linux-x64" + path: "./lib" + + - name: ".NET pack" + run: dotnet pack "./src/cs" --nologo --verbosity minimal --configuration Release -p:PackageVersion="$(date +'%Y.%m.%d')" -p:RepositoryBranch="${{ github.head_ref || github.ref_name }}" -p:RepositoryCommit="${{ github.sha }}" + + - name: "Upload packages to MyGet" + if: github.event_name == 'workflow_dispatch' + env: + MYGET_ACCESS_TOKEN: ${{ secrets.MYGET_ACCESS_TOKEN }} + run: dotnet nuget push "./nupkg/**/*.nupkg" --source https://www.myget.org/F/bottlenoselabs/api/v3/index.json --skip-duplicate --api-key $MYGET_ACCESS_TOKEN + + - name: "Upload packages to NuGet" + if: github.event_name == 'schedule' + env: + NUGET_ACCESS_TOKEN: ${{ secrets.NUGET_ACCESS_TOKEN }} + run: dotnet nuget push "./nupkg/**/*.nupkg" --source https://api.nuget.org/v3/index.json --skip-duplicate --api-key $NUGET_ACCESS_TOKEN