Skip to content

v2.5.0 - Silly bugs! #29

v2.5.0 - Silly bugs!

v2.5.0 - Silly bugs! #29

Workflow file for this run

name: Notify on release
on:
release:
types: [published]
jobs:
nuget:
if: github.event.release.prerelease == false
runs-on: windows-2022
env:
EXILED_REFERENCES_URL: https://exmod-team.github.io/SL-References/Dev.zip
SL_REFERENCES: ${{ github.workspace }}/refs
EXILED_REFERENCES: ${{ github.workspace }}/refs
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Dotnet
uses: actions/setup-dotnet@v4.0.1
with:
dotnet-version: 9.0.x
- name: Get References
shell: pwsh
run: |
Invoke-WebRequest -Uri ${{ env.EXILED_REFERENCES_URL }} -OutFile ${{ github.workspace }}/References.zip
Expand-Archive -Path References.zip -DestinationPath ${{ env.SL_REFERENCES }} -Force
- name: Rename Assembly-CSharp (because Exiled removes the normal version)
shell: pwsh
run: |
$destination = "${{ env.SL_REFERENCES }}/Assembly-CSharp.dll"
if (-Not (Test-Path $destination)) {
Move-Item -Path "${{ env.SL_REFERENCES }}/Assembly-CSharp-Publicized.dll" -Destination $destination
}
- name: Build
run: dotnet build -c Release ${{ github.workspace }}/DiscordLab.Bot/DiscordLab.Bot.csproj
- name: Clear artifacts
run: |
if (Test-Path "${{ github.workspace }}/artifacts") { Remove-Item -Path "${{ github.workspace }}/artifacts" -Recurse -Force }
New-Item -Path "${{ github.workspace }}/artifacts" -ItemType Directory
shell: pwsh
- name: Pack
run: dotnet pack -c Release --no-build ${{ github.workspace }}/DiscordLab.Bot/DiscordLab.Bot.csproj --output ${{ github.workspace }}/artifacts
- name: Publish
run: |
$nupkg = Get-ChildItem -Path "${{ github.workspace }}/artifacts" -Filter *.nupkg | Select-Object -First 1 -ExpandProperty FullName
dotnet nuget push "$nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
shell: pwsh
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
notify:
if: github.event.release.prerelease == false
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get files from release, convert into role pings and notify.
shell: pwsh
run: |
$releaseId = ${{ github.event.release.id }}
$releaseUrl = "https://api.github.com/repos/${{ github.repository }}/releases/$releaseId/assets"
$assets = Invoke-RestMethod -Uri $releaseUrl
$releasePath = "${{ github.workspace }}/release"
if (-Not (Test-Path -Path $releasePath)) {
New-Item -ItemType Directory -Path $releasePath
}
foreach ($asset in $assets) {
$assetUrl = $asset.browser_download_url
$assetName = $asset.name
Invoke-WebRequest -Uri $assetUrl -OutFile "$releasePath/$assetName"
}
$roleMap = @{
"DiscordLab.Bot" = "1326565513392033844"
"DiscordLab.BotStatus" = "1326565625249660990"
"DiscordLab.ConnectionLogs" = "1326565678601212016"
"DiscordLab.DeathLogs" = "1326565793856622628"
"DiscordLab.Moderation" = "1326565923242639492"
"DiscordLab.StatusChannel" = "1326565978125107211"
"DiscordLab.Administration" = "1327362549368361000"
"DiscordLab.RoundLogs" = "1327631517769531453"
}
$releaseFiles = Get-ChildItem -Path $releasePath
$rolePings = @()
foreach ($file in $releaseFiles) {
$fileName = [System.IO.Path]::GetFileNameWithoutExtension($file.Name)
if ($roleMap.ContainsKey($fileName)) {
$rolePings += "<@&$($roleMap[$fileName])>"
}
}
$rolePingString = $rolePings -join " "
echo "role_pings=$rolePingString" >> $GITHUB_OUTPUT
$webhookUrl = "${{ secrets.DISCORD_WEBHOOK }}"
$releaseTag = "${{ github.ref }}"
$repositoryUrl = "${{ github.server_url }}/${{ github.repository }}"
$releaseMessage = "New release available! $rolePingString`n$repositoryUrl/releases/tag/$releaseTag"
$body = @{
content = $releaseMessage
} | ConvertTo-Json
Invoke-RestMethod -Uri $webhookUrl -Method Post -Body $body -ContentType "application/json"