Skip to content

Commit c119bf3

Browse files
committed
Improve GH Action for release
1 parent 6a1741a commit c119bf3

File tree

1 file changed

+36
-10
lines changed

1 file changed

+36
-10
lines changed

.github/workflows/dotnet-build.yml

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
os: [windows-latest, macos-15]
6060
steps:
6161
- name: Checkout code
62-
uses: actions/checkout@main
62+
uses: actions/checkout@v4
6363

6464
- name: Set Latest Xcode Version
6565
if: runner.os == 'macOS'
@@ -104,28 +104,33 @@ jobs:
104104
os: [windows-latest, macos-15]
105105
steps:
106106
- name: Checkout code
107-
uses: actions/checkout@main
107+
uses: actions/checkout@v4
108108

109109
- name: Set NuGet Version to Tag Number
110-
if: startsWith(github.ref, 'refs/tags/') && !endsWith(github.ref, '-mediaelement')
111-
run: echo "NugetPackageVersion=${{ github.ref }}" >> $GITHUB_ENV
110+
if: startsWith(github.ref, 'refs/tags/') && (!endsWith(github.ref, '-mediaelement') && !endsWith(github.ref, '-camera') && !endsWith(github.ref, '-maps'))
111+
run: echo "NugetPackageVersion=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
112+
shell: bash
112113

113114
- name: Set NuGet Version to Tag Number for Camera
114115
if: startsWith(github.ref, 'refs/tags/') && endsWith(github.ref, '-camera')
115-
run: echo "NugetPackageVersionCamera=${{ github.ref }}" >> $GITHUB_ENV
116+
run: echo "NugetPackageVersionCamera=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
117+
shell: bash
116118

117119
- name: Set NuGet Version to Tag Number for MediaElement
118120
if: startsWith(github.ref, 'refs/tags/') && endsWith(github.ref, '-mediaelement')
119-
run: echo "NugetPackageVersionMediaElement=${{ github.ref }}" >> $GITHUB_ENV
121+
run: echo "NugetPackageVersionMediaElement=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
122+
shell: bash
120123

121124
- name: Set NuGet Version to Tag Number for Maps
122125
if: startsWith(github.ref, 'refs/tags/') && endsWith(github.ref, '-maps')
123-
run: echo "NugetPackageVersionMaps=${{ github.ref }}" >> $GITHUB_ENV
126+
run: echo "NugetPackageVersionMaps=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
127+
shell: bash
124128

125129
- name: Set NuGet Version to PR Version
126130
if: ${{ github.event_name == 'pull_request' }}
127131
run: |
128132
echo "NugetPackageVersion=${{ env.CurrentSemanticVersionBase }}-build-${{ github.event.pull_request.number }}.${{ github.run_number }}+${{ github.sha }}"
133+
echo "NugetPackageVersionCamera=${{ env.CurrentSemanticVersionBase }}-build-${{ github.event.pull_request.number }}.${{ github.run_number }}+${{ github.sha }}"
129134
echo "NugetPackageVersionMediaElement=${{ env.CurrentSemanticVersionBase }}-build-${{ github.event.pull_request.number }}.${{ github.run_number }}+${{ github.sha }}"
130135
echo "NugetPackageVersionMaps=${{ env.CurrentSemanticVersionBase }}-build-${{ github.event.pull_request.number }}.${{ github.run_number }}+${{ github.sha }}"
131136
shell: bash
@@ -258,7 +263,7 @@ jobs:
258263

259264
sign:
260265
needs: [build_library]
261-
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/rel/') }}
266+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
262267
runs-on: windows-latest
263268
permissions:
264269
id-token: write # Required for requesting the JWT
@@ -281,6 +286,27 @@ jobs:
281286
with:
282287
name: packages
283288
path: ./packages
289+
290+
- name: Remove MediaElement package if that is not being released
291+
if: startsWith(github.ref, 'refs/tags/') && !endsWith(github.ref, '-mediaelement')
292+
run: |
293+
${{ github.workspace }}/packages/**/*.nupkg | Where-Object { $_ -notmatch "CommunityToolkit.Maui.MediaElement" } | Remove-Item -Force
294+
295+
- name: Remove Camera package if that is not being released
296+
if: startsWith(github.ref, 'refs/tags/') && !endsWith(github.ref, '-camera')
297+
run: |
298+
${{ github.workspace }}/packages/**/*.nupkg | Where-Object { $_ -notmatch "CommunityToolkit.Maui.Camera" } | Remove-Item -Force
299+
300+
- name: Remove Maps package if that is not being released
301+
if: startsWith(github.ref, 'refs/tags/') && !endsWith(github.ref, '-maps')
302+
run: |
303+
${{ github.workspace }}/packages/**/*.nupkg | Where-Object { $_ -notmatch "CommunityToolkit.Maui.Maps" } | Remove-Item -Force
304+
305+
- name: Remove Core & Main package if that is not being released
306+
if: startsWith(github.ref, 'refs/tags/') && (!endsWith(github.ref, '-mediaelement') && !endsWith(github.ref, '-camera') && !endsWith(github.ref, '-maps'))
307+
run: |
308+
${{ github.workspace }}/packages/**/*.nupkg | Where-Object { $_ -notmatch "CommunityToolkit.Maui" } | Remove-Item -Force
309+
${{ github.workspace }}/packages/**/*.nupkg | Where-Object { $_ -notmatch "CommunityToolkit.Maui.Core" } | Remove-Item -Force
284310
285311
- name: Install Signing Tool
286312
run: dotnet tool install --tool-path ./tools sign --version 0.9.1-beta.23356.1
@@ -293,7 +319,7 @@ jobs:
293319
--file-list "${{ github.workspace }}/SignClientFileList.txt"
294320
--timestamp-url "http://timestamp.digicert.com"
295321
--publisher-name ".NET Foundation"
296-
--description "Community Toolkit MAUI"
322+
--description ".NET MAUI Community Toolkit"
297323
--description-url "https://github.com/CommunityToolkit/Maui"
298324
--azure-key-vault-url "${{ secrets.SIGN_KEY_VAULT_URL }}"
299325
--azure-key-vault-client-id ${{ secrets.SIGN_CLIENT_ID }}
@@ -311,7 +337,7 @@ jobs:
311337
${{ github.workspace }}/packages/**/*.nupkg
312338
313339
release:
314-
if: ${{ startsWith(github.ref, 'refs/heads/rel/') }}
340+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
315341
needs: [sign]
316342
environment: nuget-release-gate # This gates this job until manually approved
317343
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)