-
Notifications
You must be signed in to change notification settings - Fork 40
167 lines (134 loc) · 5.69 KB
/
beta.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Beta
on:
push:
branches:
- main
workflow_dispatch:
jobs:
beta:
runs-on: windows-latest
steps:
- name: Git - Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Version
id: version
run: |
# Get the current date
$DATE = Get-Date -Format "yyyy.Md"
# Get the current hour and minute without leading zero for the hour
# Get the current hour and minute
$HOUR = [int](Get-Date -Format "HH") # Convert hour to integer to strip any leading zero
# If the hour is 0 (midnight), set it to an empty string
if ($HOUR -eq 0) {
$HOUR = ''
}
$MINUTE = Get-Date -Format "mm" # Keep minutes as-is
# Construct the time, omitting hour if it's empty
$TIME = "$HOUR$MINUTE"
# Construct the version using DATE and TIME
$VERSION = "$DATE.$TIME"
Write-Output "Generated version: $VERSION"
# Export version as an output
echo "version=$VERSION" >> $env:GITHUB_OUTPUT
- name: Version - Update project files
uses: vers-one/[email protected]
with:
file: "src/**/*.csproj"
version: ${{ steps.version.outputs.version }}
- name: Release - Delete unpublished
uses: hugo19941994/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Release - Notes
uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ github.token }}
with:
name: 'Sidekick v${{ steps.version.outputs.version }}'
tag: 'v${{ steps.version.outputs.version }}'
version: 'v${{ steps.version.outputs.version }}'
publish: false
prerelease: true
- name: Environment - Build Number
uses: myci-actions/export-env-var@1
with:
name: BUILD_NUMBER
value: ${{ steps.version.outputs.version }}
- name: Environment - Github Token
uses: myci-actions/export-env-var@1
with:
name: GITHUB_TOKEN
value: ${{ github.token }}
- name: .NET - Setup
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.x
- name: .NET - Tests
shell: pwsh
run: |
dotnet restore
dotnet build --no-restore
dotnet test --no-build --verbosity normal
- name: .NET - Publish
shell: pwsh
run: |
$version = "${{ steps.version.outputs.version }}"
Write-Output "Version: $version"
dotnet publish src/Sidekick.Protocol/Sidekick.Protocol.csproj -p:PublishProfile=Build
dotnet publish src/Sidekick.Wpf/Sidekick.Wpf.csproj -c Release --self-contained true -r win-x64 -o ./Publish
- name: Velopack
shell: pwsh
run: |
$version = "${{ steps.version.outputs.version }}"
Write-Output "Version: $version"
dotnet tool install -g vpk
vpk download github --repoUrl https://github.com/Sidekick-Poe/Sidekick --channel windows-beta
vpk pack --packId Sidekick --packVersion $version --packDir Publish --channel windows-beta
# Delete the nupkg file
Get-ChildItem -Path ./Releases -Filter *.nupkg -Recurse | Remove-Item -Force
vpk upload github --repoUrl https://github.com/Sidekick-Poe/Sidekick --channel windows-beta --pre --merge --releaseName "Sidekick v$version" --tag v$version --token ${{ github.token }}
- name: ClickOnce - Git Key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.DEPLOY_BETA_KEY }}
- name: ClickOnce
shell: pwsh
run: |
$version = "${{ steps.version.outputs.version }}"
Write-Output "Version: $version"
# Find MSBuild.
$msBuildPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" `
-latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe `
-prerelease | select-object -first 1
Push-Location "src/Sidekick.Wpf"
& $msBuildPath Sidekick.Wpf.csproj /target:Publish /property:PublishProfile=ClickOnceBeta /property:ApplicationVersion=$version
Pop-Location
# Clone `gh-pages` branch.
git config --global url."https://user:${{ secrets.GITHUB_TOKEN }}@github".insteadOf https://github
git config --global user.name github-actions
git config --global user.email [email protected]
git clone $deployRepository -b gh-pages --single-branch "ClickOnce"
$deployRepository = "[email protected]:Sidekick-Poe/Sidekick-Beta.git"
Write-Output "Deploy repository: $deployRepository"
# Clone `gh-pages` branch.
git clone $deployRepository -b gh-pages --single-branch "dist"
Push-Location "dist"
try {
Write-Output "Removing previous files..."
if (Test-Path "Application Files") {
Remove-Item -Path "Application Files" -Recurse
}
if (Test-Path "Sidekick.application") {
Remove-Item -Path "Sidekick.application"
}
Write-Output "Copying new files..."
Copy-Item -Path "../src/Sidekick.Wpf/bin/publish/Application Files","../src/Sidekick.Wpf/bin/publish/Sidekick.application" -Destination . -Recurse
# Stage and commit.
git add -A
git commit -m "Update to v$version"
# git push
} finally {
Pop-Location
}