From 247c9494ca84dd32e1261b82ec14244255b554ba Mon Sep 17 00:00:00 2001 From: Artur Stolear Date: Wed, 22 Nov 2023 13:15:25 +0100 Subject: [PATCH] #3727 - Update GitHub workflows and add Winget release This commit revamps multiple GitHub action workflows to improve the release process. It adds the capability to publish releases to Winget. Also, it enhances workflows' structure for handling releases through repository dispatches. Changes bring a more organized, efficient approach for publishing to different platforms. --- .github/workflows/ci.yml | 11 +++++++++- .github/workflows/docs.yml | 8 +++---- .github/workflows/homebrew.yml | 38 ++++++++++++++++++++++++-------- .github/workflows/release.yml | 15 +++++++++---- .github/workflows/winget.yml | 40 ++++++++++++++++++++++++++++++++++ build/CI.sln | 1 + 6 files changed, 95 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/winget.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b9801734cf..548d2f49ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ on: - '!docs/**' repository_dispatch: - types: [ release ] + types: [ ci-release ] env: DOTNET_ROLL_FORWARD: "Major" @@ -133,3 +133,12 @@ jobs: name: '[Release]' shell: pwsh run: dotnet run/release.dll --target=PublishRelease + - + name: '[Publish Release]' + if: ${{ github.event_name == 'repository_dispatch' }} + uses: peter-evans/repository-dispatch@v2 + with: + token: ${{ secrets.RELEASE_GITHUB_TOKEN }} + repository: ${{ github.repository }} + event-type: publish-release + client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "tag": "${{ github.event.client_payload.tag }}"}' \ No newline at end of file diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 79debc03b0..1f52da1ec9 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -3,7 +3,7 @@ name: Verify & Publish Docs on: workflow_dispatch: repository_dispatch: - types: [release] + types: [ publish-release ] push: branches: - main @@ -90,7 +90,7 @@ jobs: validate: name: Validates Html - needs: [prepare] + needs: [ prepare ] runs-on: ubuntu-latest steps: - @@ -126,7 +126,7 @@ jobs: publish: name: Publish docs - needs: [validate] + needs: [ validate ] runs-on: windows-latest env: GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} @@ -147,7 +147,7 @@ jobs: dotnet run/docs.dll --target=GenerateSchemas - name: '[Publish Documentation]' - if: ${{ github.event_name == 'push' }} + if: ${{ github.event_name == 'repository_dispatch' }} shell: pwsh run: dotnet run/docs.dll --target=PublishDocs - diff --git a/.github/workflows/homebrew.yml b/.github/workflows/homebrew.yml index 672a3e2f3c..12cfa22056 100644 --- a/.github/workflows/homebrew.yml +++ b/.github/workflows/homebrew.yml @@ -1,9 +1,14 @@ -name: Homebrew +name: Publish to Homebrew on: workflow_dispatch: + inputs: + tag-name: + description: 'The git tag name to bump the formula to' + required: true repository_dispatch: - types: [release] + types: [ publish-release ] + permissions: contents: read @@ -14,10 +19,25 @@ jobs: name: Bump Homebrew formula runs-on: macos-latest steps: - - uses: dawidd6/action-homebrew-bump-formula@v3 - with: - # GitHub token, required, not the default one - token: ${{secrets.RELEASE_GITHUB_TOKEN}} - # Formula name, required - formula: gitversion - tag: ${{ github.event.client_payload.ref }} + - name: Get version + id: get-version + shell: pwsh + run: | + $version = "${{ github.event.client_payload.tag }}" + if ($version -eq "") { + $version = "${{ github.event.inputs.tag-name }}" + } + "version=$version" >> $env:GITHUB_OUTPUT + - + uses: mislav/bump-homebrew-formula-action@v3 + name: Bump Homebrew formula + with: + formula-name: gitversion + tag-name: ${{ steps.get-version.outputs.version }} + download-url: https://github.com/GitTools/GitVersion/archive/refs/tags/${{ steps.get-version.outputs.version }}.tar.gz + commit-message: | + {{formulaName}} {{version}} + + For additional details see https://github.com/GitTools/GitVersion/releases/tag/${{ steps.get-version.outputs.version }} + env: + COMMITTER_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4bd8823675..ef705217a7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,17 +1,24 @@ name: Release on: release: - types: [published] + types: [ published ] jobs: release: - name: Trigger Build flow + name: Trigger ci flow runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Get version + id: get-version + shell: pwsh + run: | + # Finding the version from release tag + $VERSION="${{ github.ref }}".Replace("refs/tags/", "") + "version=$VERSION" >> $env:GITHUB_OUTPUT - uses: peter-evans/repository-dispatch@v2 with: token: ${{ secrets.RELEASE_GITHUB_TOKEN }} repository: ${{ github.repository }} - event-type: release - client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}' + event-type: ci-release + client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "tag": "${{ steps.get-version.outputs.version }}"}' \ No newline at end of file diff --git a/.github/workflows/winget.yml b/.github/workflows/winget.yml new file mode 100644 index 0000000000..0d558a475a --- /dev/null +++ b/.github/workflows/winget.yml @@ -0,0 +1,40 @@ +name: Publish to Winget + +on: + workflow_dispatch: + inputs: + tag-name: + description: 'The git tag name to bump the formula to' + required: true + repository_dispatch: + types: [ publish-release ] + +permissions: + contents: read + +jobs: + homebrew: + permissions: + contents: none + name: Bump winget manifest + runs-on: ubuntu-latest + steps: + - name: Get version + id: get-version + shell: pwsh + run: | + $version = "${{ github.event.client_payload.tag }}" + if ($version -eq "") { + $version = "${{ github.event.inputs.tag-name }}" + } + + $url = "https://github.com/GitTools/GitVersion/releases/download/{0}/gitversion-win-{1}-{0}.zip" + $urls = @(($url -f $version, "x64"), ($url -f $version, "arm64")) -Join "," + + $run_args = "update --id GitTools.GitVersion --version $version --urls $urls --token ${{ secrets.RELEASE_GITHUB_TOKEN }} --submit" + "version=$version" >> $env:GITHUB_OUTPUT + "run_args=$run_args" >> $env:GITHUB_OUTPUT + + - uses: michidk/run-komac@v1 + with: + args: '${{ steps.get-version.outputs.run_args }}' \ No newline at end of file diff --git a/build/CI.sln b/build/CI.sln index 1208929bd6..63f7bdf2bf 100644 --- a/build/CI.sln +++ b/build/CI.sln @@ -40,6 +40,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{ ..\.github\workflows\_publish.yml = ..\.github\workflows\_publish.yml ..\.github\workflows\_unit_tests.yml = ..\.github\workflows\_unit_tests.yml ..\.github\workflows\stale.yml = ..\.github\workflows\stale.yml + ..\.github\workflows\winget.yml = ..\.github\workflows\winget.yml EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "actions", "actions", "{A9B92261-AB9C-47D6-A8A7-616A5A62B063}"