Skip to content

Commit 04fa485

Browse files
committed
Build and release demo application
1 parent 8520b3d commit 04fa485

1 file changed

Lines changed: 84 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Build and release demo
2+
3+
on:
4+
push
5+
6+
jobs:
7+
build:
8+
9+
runs-on: windows-latest
10+
11+
permissions:
12+
contents: write
13+
14+
steps:
15+
16+
- name: Checkout
17+
uses: actions/checkout@v5
18+
19+
- name: Add msbuild to PATH
20+
uses: microsoft/setup-msbuild@v2
21+
with:
22+
msbuild-architecture: x64
23+
24+
- name: Build x86
25+
run: msbuild -restore -p:RestorePackagesConfig=true -p:Configuration=Release -p:Platform=x86 -clp:ForceConsoleColor -warnaserror ${{ github.workspace }}\Demo\Demo.slnx
26+
27+
- name: Build x64
28+
run: msbuild -restore -p:RestorePackagesConfig=true -p:Configuration=Release -p:Platform=x64 -clp:ForceConsoleColor -warnaserror ${{ github.workspace }}\Demo\Demo.slnx
29+
30+
- name: Build ARM64
31+
run: msbuild -restore -p:RestorePackagesConfig=true -p:Configuration=Release -p:Platform=ARM64 -clp:ForceConsoleColor -warnaserror ${{ github.workspace }}\Demo\Demo.slnx
32+
33+
- name: Prepare artifacts for release
34+
run: |
35+
Copy-Item -Path ${{ github.workspace }}/Demo/Packaging/AppPackages/Packaging_1.0.0.0_x86_Test/Packaging_1.0.0.0_x86.msix -Destination ./artifacts/MyApplication_x86.msix
36+
Copy-Item -Path ${{ github.workspace }}/Demo/Packaging/AppPackages/Packaging_1.0.0.0_x64_Test/Packaging_1.0.0.0_x64.msix -Destination ./artifacts/MyApplication_x64.msix
37+
Copy-Item -Path ${{ github.workspace }}/Demo/Packaging/AppPackages/Packaging_1.0.0.0_ARM64_Test/Packaging_1.0.0.0_ARM64.msix -Destination ./artifacts/MyApplication_ARM64.msix
38+
39+
- name: Delete all previous releases and tags
40+
env:
41+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
run: |
43+
# Get a list of all existing releases and extract tag names
44+
# Use --json flag to get machine-readable, structured data
45+
$releasesJson = gh release list --json name,tagName
46+
47+
# Parse the JSON output in PowerShell
48+
$releases = $releasesJson | ConvertFrom-Json
49+
50+
foreach ($release in $releases) {
51+
Write-Host "Deleting release: $release.name"
52+
# Delete the release and its associated tag
53+
gh release delete "$release.tagName" -y --cleanup-tag
54+
}
55+
56+
- name: Generate release name
57+
id: dynamic_version
58+
run: |
59+
# Get current date in YYYY-MM-DD format (colons are not allowed in tag/release names)
60+
$currentDate = Get-Date -Format 'yyyy-MM-dd'
61+
# Get the short commit SHA (first 7 characters) from the built-in GITHUB_SHA variable
62+
$commitHashShort = "${{ github.sha }}".Substring(0, 7)
63+
$releaseName = "Demo Application Release $currentDate-$commitHashShort"
64+
65+
# Make these variables available as outputs for subsequent steps
66+
echo "release_name=$releaseName" >> $env:GITHUB_OUTPUT
67+
68+
- name: Publish release
69+
uses: softprops/action-gh-release@v2
70+
with:
71+
tag_name: latest
72+
name: ${{ steps.dynamic_version.outputs.release_name }}
73+
body: |
74+
Latest demo application MSIX package automatically built by GitHub Actions.
75+
76+
Since it is unsigned, it can only be installed on Windows 11 using the following command in an elevated PowerShell for testing purposes.
77+
78+
```powershell
79+
Add-AppxPackage -Path MyApplication.msix -AllowUnsigned
80+
```
81+
82+
draft: false
83+
prerelease: false
84+
files: artifacts/*

0 commit comments

Comments
 (0)