Skip to content

Commit af31915

Browse files
Add conditionals to only run Signing/Release steps at the correct times
Update Tooling Module Semver regex tested locally
1 parent 97f60a2 commit af31915

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

.github/workflows/build.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767

6868
env:
6969
# faux-ternary expression to select which platforms to build for each platform vs. duplicating step below.
70-
TARGET_PLATFORMS: ${{ matrix.platform != 'WinUI3' && 'all' || 'all-uwp' }}
70+
TARGET_PLATFORMS: all
7171
TEST_PLATFORM: ${{ matrix.platform != 'WinUI3' && 'UWP' || 'WinAppSdk' }}
7272
VERSION_PROPERTY: ${{ github.ref == 'refs/heads/main' && format('build.{0}', github.run_number) || format('pull-{0}.{1}', github.event.number, github.run_number) }}
7373

@@ -132,6 +132,15 @@ jobs:
132132
run: |
133133
echo "VERSION_DATE=$(git log -1 --format=%cd --date=format:%y%m%d)" >> $env:GITHUB_ENV
134134
135+
# Semver regex: https://regex101.com/r/Ly7O1x/3/
136+
- name: Format Date/Time of Release Package Version
137+
if: ${{ env.IS_RELEASE == 'true' }}
138+
run: |
139+
$ref = "${{ github.ref }}"
140+
$ref -match "^refs/heads/rel/(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
141+
echo "VERSION_DATE=$($matches['patch'])" >> $env:GITHUB_ENV
142+
echo "VERSION_PROPERTY=$($matches['prerelease'])" >> $env:GITHUB_ENV
143+
135144
- name: MSBuild
136145
run: >
137146
msbuild.exe /restore /nowarn:MSB4011
@@ -150,7 +159,7 @@ jobs:
150159

151160
# Push Pull Request Packages to our DevOps Artifacts Feed (see nuget.config)
152161
- name: Push Pull Request Packages
153-
if: ${{ env.IS_PR }}
162+
if: ${{ env.IS_PR == 'true' }}
154163
run: |
155164
dotnet nuget add source https://pkgs.dev.azure.com/dotnet/CommunityToolkit/_packaging/CommunityToolkit-PullRequests/nuget/v3/index.json `
156165
--name PullRequests `
@@ -216,7 +225,7 @@ jobs:
216225
217226
- name: Upload Package List
218227
uses: actions/upload-artifact@v3
219-
# TODO: if: ${{ env.IS_PR == false }}
228+
if: ${{ env.IS_PR == 'false' }}
220229
with:
221230
name: nuget-list
222231
if-no-files-found: error
@@ -226,7 +235,7 @@ jobs:
226235
# if we're not doing a PR build then we upload our packages so we can sign as a separate job.
227236
- name: Upload Packages as Artifacts
228237
uses: actions/upload-artifact@v3
229-
# TODO: if: ${{ env.IS_PR == false }}
238+
if: ${{ env.IS_PR == 'false' }}
230239
with:
231240
name: nuget-packages-${{ matrix.platform }}
232241
if-no-files-found: error
@@ -235,7 +244,7 @@ jobs:
235244
236245
sign:
237246
needs: [build]
238-
# TODO: if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/rel/') }}
247+
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/rel/') }}
239248
runs-on: windows-latest
240249
permissions:
241250
id-token: write # Required for requesting the JWT
@@ -283,17 +292,16 @@ jobs:
283292
--azure-key-vault-certificate "${{ secrets.SIGN_CERTIFICATE }}"
284293
--verbosity Information
285294
286-
# TODO: For now push to PR feed so we can validate if any of this works... change to MainLatest after
287295
- name: Push Signed Packages
288296
run: |
289-
dotnet nuget add source https://pkgs.dev.azure.com/dotnet/CommunityToolkit/_packaging/CommunityToolkit-PullRequests/nuget/v3/index.json `
290-
--name PullRequests `
297+
dotnet nuget add source https://pkgs.dev.azure.com/dotnet/CommunityToolkit/_packaging/CommunityToolkit-MainLatest/nuget/v3/index.json `
298+
--name MainLatest `
291299
--username dummy --password ${{ secrets.DEVOPS_PACKAGE_PUSH_TOKEN }}
292-
dotnet nuget push "**/*.nupkg" --api-key dummy --source PullRequests --skip-duplicate
300+
dotnet nuget push "**/*.nupkg" --api-key dummy --source MainLatest --skip-duplicate
293301
294302
- name: Upload Signed Packages as Artifacts (for release)
295303
uses: actions/upload-artifact@v3
296-
# TODO: if: ${{ env.IS_RELEASE }}
304+
if: ${{ env.IS_RELEASE == 'true' }}
297305
with:
298306
name: signed-nuget-packages-${{ matrix.platform }}
299307
if-no-files-found: error

tooling

0 commit comments

Comments
 (0)