Skip to content

Commit

Permalink
#3727 - Update GitHub workflows and add Winget release
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
arturcic committed Nov 22, 2023
1 parent 1004b75 commit f64f2ec
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 18 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
- '!docs/**'

repository_dispatch:
types: [ release ]
types: [ ci-release ]

env:
DOTNET_ROLL_FORWARD: "Major"
Expand Down Expand Up @@ -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 }}"}'
8 changes: 4 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Verify & Publish Docs
on:
workflow_dispatch:
repository_dispatch:
types: [release]
types: [ publish-release ]
push:
branches:
- main
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:

validate:
name: Validates Html
needs: [prepare]
needs: [ prepare ]
runs-on: ubuntu-latest
steps:
-
Expand Down Expand Up @@ -126,7 +126,7 @@ jobs:

publish:
name: Publish docs
needs: [validate]
needs: [ validate ]
runs-on: windows-latest
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
Expand All @@ -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
-
Expand Down
38 changes: 29 additions & 9 deletions .github/workflows/homebrew.yml
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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 }}
15 changes: 11 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}"}'
40 changes: 40 additions & 0 deletions .github/workflows/winget.yml
Original file line number Diff line number Diff line change
@@ -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 }}'
1 change: 1 addition & 0 deletions build/CI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit f64f2ec

Please sign in to comment.