Skip to content

Commit e367b42

Browse files
authored
Publish release workflow (#3020)
* Fixing variables * Addming missing token. Ignoring warnings when no screenshots present * Fixing file paths * Specifying GH repo for the CLI * Attempting to zip demo app * Wildcard nuget packages * Removing label for release artifacts * Fixing issue with globbing * Adding release notes generation * Indent script * Fixing powershell property access * Setting title * Collapsing steps to make writing release notes file simplere. * Adding release publish workflow Disabling publish for testing
1 parent b633198 commit e367b42

File tree

4 files changed

+78
-24
lines changed

4 files changed

+78
-24
lines changed

.github/actions/build-and-test/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@ runs:
4242
with:
4343
name: Screenshots-${{ github.run_number }}
4444
path: ${{ github.workspace }}/MaterialDesignThemes.UITests/bin/${{ inputs.buildConfiguration }}/net7.0-windows/Screenshots
45+
if-no-files-found: ignore

.github/workflows/prepare_release.yml

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ env:
1414
mdixColorsVersion: '2.1.0'
1515
mdixMahAppsVersion: '0.2.6'
1616
mdixVersion: '4.7.0'
17+
# Needed for GitHub CLI
18+
GH_TOKEN: ${{ github.token }}
1719

1820
jobs:
1921
collect_contributors:
2022
runs-on: ubuntu-latest
21-
name: Get a list of contributors
23+
name: Generate Release Notes
2224
steps:
2325
- name: Get Contributors
2426
id: get-contribs
@@ -29,8 +31,24 @@ jobs:
2931
repository-owner: 'MaterialDesignInXAML'
3032
token: ${{ github.token }}
3133

32-
- name: Show Contributors
33-
run: echo "${{ steps.get-contribs.outputs.contributors }}"
34+
- name: Generate Release Notes
35+
shell: pwsh
36+
run: |
37+
$response = gh api --method POST -H "Accept: application/vnd.github+json" /repos/${{ github.repository }}/releases/generate-notes -f tag_name='v${{ inputs.milestone }}'
38+
$json = $response | ConvertFrom-Json
39+
$releaseNotes = $json.body
40+
$contributors = "${{ steps.get-contribs.outputs.contributors }}"
41+
$releaseNotes | Out-File -Append "ReleaseNotes.md"
42+
"`n" | Out-File -Append "ReleaseNotes.md"
43+
$contributors | Out-File -Append "ReleaseNotes.md"
44+
cat "ReleaseNotes.md"
45+
46+
- name: Upload Release Notes
47+
uses: actions/upload-artifact@v2
48+
with:
49+
name: ReleaseNotes
50+
path: "ReleaseNotes.md"
51+
3452

3553
build_artifacts:
3654
name: Build artifacts
@@ -50,7 +68,7 @@ jobs:
5068

5169
- name: Build NuGets
5270
shell: pwsh
53-
run: .\Scripts\BuildNugets.ps1 -MDIXVersion ${{ inputs.mdixVersion }} -MDIXMahAppsVersion ${{ inputs.mdixMahAppsVersion }} -MDIXColorsVersion ${{ inputs.mdixColorsVersion }}
71+
run: .\Scripts\BuildNugets.ps1 -MDIXVersion ${{ env.mdixVersion }} -MDIXMahAppsVersion ${{ env.mdixMahAppsVersion }} -MDIXColorsVersion ${{ env.mdixColorsVersion }}
5472

5573
- name: Upload NuGets
5674
uses: actions/upload-artifact@v2
@@ -82,6 +100,16 @@ jobs:
82100
name: DemoApp
83101
path: demo-app
84102

103+
- name: Zip Demo App
104+
run: zip -r DemoApp.zip demo-app/*
105+
106+
- name: Download Release Notes
107+
uses: actions/download-artifact@v3
108+
with:
109+
name: ReleaseNotes
110+
85111
- name: Create Release
112+
shell: pwsh
86113
run: |
87-
gh release create v${{ inputs.milestone }} --generate-notes '/nugets#NuGets' '/demo-app#Demo App'
114+
# We can't use glob pattern because of this bug https://github.com/cli/cli/issues/5099
115+
gh release create v${{ inputs.milestone }} --repo '${{ github.repository }}' --draft --latest --title "${{ inputs.milestone }}" --notes-file ReleaseNotes.md (Get-Item '${{ github.workspace }}/nugets/*.nupkg') '${{ github.workspace }}/DemoApp.zip'

.github/workflows/publish_release.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Release Published
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish_nugets:
9+
runs-on: ubuntu-latest
10+
name: Publish NuGets
11+
12+
steps:
13+
- name: Download Release Artifacts
14+
shell: pwsh
15+
run: |
16+
$release = (gh api -H "Accept: application/vnd.github+json" /repos/${{ github.repository }}/releases/tags/github.ref_name) | ConvertFrom-Json
17+
18+
foreach($asset in $release.assets) {
19+
if ($asset.name.EndsWith(".nupkg")){
20+
Write-Host "Downloading $($asset.id) - $($asset.name)"
21+
gh api -H "Accept: application/octet-stream" "/repos/${{ github.repository }}/releases/assets/$($asset.id)" | Out-File $asset.name
22+
}
23+
}
24+
25+

.github/workflows/release.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ on:
44
workflow_dispatch:
55
schedule:
66
- cron: '0 9 * * *'
7-
push:
8-
tags:
9-
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
7+
# push:
8+
# tags:
9+
# - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
1010

1111
env:
1212
solution: MaterialDesignToolkit.Full.sln
@@ -63,20 +63,20 @@ jobs:
6363
echo "mdixColorsVersion=${{ env.mdixColorsVersion }}-ci${{ github.run_number }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf-8 -Append
6464
echo "mdixMahAppsVersion=${{ env.mdixMahAppsVersion }}-ci${{ github.run_number }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf-8 -Append
6565
66-
- name: Push Artifacts
67-
uses: ./.github/actions/push-artifacts
68-
timeout-minutes: 10
69-
with:
70-
mdixVersion: ${{ env.mdixVersion }}
71-
mdixColorsVersion: ${{ env.mdixColorsVersion }}
72-
mdixMahAppsVersion: ${{ env.mdixMahappsVersion }}
73-
demoAppPath: "MainDemo.Wpf/bin/${{ env.buildConfiguration }}"
74-
nugetKey: ${{ secrets.PAT }}
66+
# - name: Push Artifacts
67+
# uses: ./.github/actions/push-artifacts
68+
# timeout-minutes: 10
69+
# with:
70+
# mdixVersion: ${{ env.mdixVersion }}
71+
# mdixColorsVersion: ${{ env.mdixColorsVersion }}
72+
# mdixMahAppsVersion: ${{ env.mdixMahappsVersion }}
73+
# demoAppPath: "MainDemo.Wpf/bin/${{ env.buildConfiguration }}"
74+
# nugetKey: ${{ secrets.PAT }}
7575

76-
- name: Update latest tag
77-
if: ${{ github.event_name != 'push' }}
78-
run: |
79-
git config user.name github-actions
80-
git config user.email [email protected]
81-
git tag -f nightly_release master
82-
git push -f --tags
76+
# - name: Update latest tag
77+
# if: ${{ github.event_name != 'push' }}
78+
# run: |
79+
# git config user.name github-actions
80+
# git config user.email [email protected]
81+
# git tag -f nightly_release master
82+
# git push -f --tags

0 commit comments

Comments
 (0)