DiscordChatExporter/.github/workflows/main.yml

152 lines
4.3 KiB
YAML
Raw Normal View History

2022-04-21 18:13:36 -04:00
name: main
on: [push, pull_request]
2023-09-21 13:18:16 -04:00
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
2022-04-21 18:13:36 -04:00
jobs:
test:
runs-on: windows-latest
permissions:
contents: read
2022-04-21 18:13:36 -04:00
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install .NET
uses: actions/setup-dotnet@v2
with:
2022-12-07 18:44:26 -05:00
dotnet-version: 7.0.x
2022-04-21 18:13:36 -04:00
- name: Run tests
# Tests need access to secrets, so we can't run them against PRs because of limited trust
if: ${{ github.event_name != 'pull_request' }}
2023-05-10 17:59:08 -04:00
run: >
dotnet test
--configuration Release
--logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true"
--collect:"XPlat Code Coverage"
--
2023-05-29 18:31:46 -04:00
RunConfiguration.CollectSourceInformation=true
2023-05-10 17:59:08 -04:00
DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
2022-04-21 18:13:36 -04:00
env:
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
pack:
2022-04-21 18:13:36 -04:00
runs-on: windows-latest
permissions:
actions: write
contents: read
2022-04-21 18:13:36 -04:00
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install .NET
uses: actions/setup-dotnet@v2
with:
2022-12-07 18:44:26 -05:00
dotnet-version: 7.0.x
2022-04-21 18:13:36 -04:00
- name: Publish (CLI)
2023-05-10 17:59:08 -04:00
run: >
dotnet publish DiscordChatExporter.Cli
--output DiscordChatExporter.Cli/publish/
2023-05-10 17:59:08 -04:00
--configuration Release
2022-04-21 18:13:36 -04:00
- name: Publish (GUI)
2023-05-10 17:59:08 -04:00
run: >
dotnet publish DiscordChatExporter.Gui
--output DiscordChatExporter.Gui/publish/
2023-05-10 17:59:08 -04:00
--configuration Release
2022-04-21 18:13:36 -04:00
2022-04-21 19:10:00 -04:00
- name: Upload artifacts (CLI)
2022-04-21 18:13:36 -04:00
uses: actions/upload-artifact@v3
with:
2022-04-30 09:04:57 -04:00
name: DiscordChatExporter.Cli
path: DiscordChatExporter.Cli/publish/
2022-04-21 18:13:36 -04:00
2022-04-21 19:10:00 -04:00
- name: Upload artifacts (GUI)
2022-04-21 18:13:36 -04:00
uses: actions/upload-artifact@v3
with:
name: DiscordChatExporter
path: DiscordChatExporter.Gui/publish/
2022-04-21 18:13:36 -04:00
deploy:
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
needs:
- test
- pack
2022-04-21 18:13:36 -04:00
runs-on: ubuntu-latest
permissions:
actions: read
contents: write
2022-04-21 18:13:36 -04:00
steps:
2022-04-21 19:10:00 -04:00
- name: Download artifacts (CLI)
2022-04-21 18:13:36 -04:00
uses: actions/download-artifact@v3
with:
2022-04-30 09:04:57 -04:00
name: DiscordChatExporter.Cli
path: DiscordChatExporter.Cli
2022-04-21 18:13:36 -04:00
2022-04-21 19:10:00 -04:00
- name: Download artifacts (GUI)
2022-04-21 18:13:36 -04:00
uses: actions/download-artifact@v3
with:
name: DiscordChatExporter
2022-04-30 09:04:57 -04:00
path: DiscordChatExporter.Gui
2022-04-21 18:13:36 -04:00
- name: Create package (CLI)
shell: pwsh
2023-05-10 17:59:08 -04:00
run: >
Compress-Archive
-Path DiscordChatExporter.Cli/*
-DestinationPath DiscordChatExporter.Cli.zip
-Force
2022-04-21 18:13:36 -04:00
- name: Create package (GUI)
shell: pwsh
2023-05-10 17:59:08 -04:00
run: >
Compress-Archive
-Path DiscordChatExporter.Gui/*
-DestinationPath DiscordChatExporter.zip
-Force
2022-04-21 18:13:36 -04:00
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2023-05-27 16:28:37 -04:00
run: >
2023-06-08 18:20:47 -04:00
gh release create "${{ github.ref_name }}"
"DiscordChatExporter.Cli.zip"
"DiscordChatExporter.zip"
--repo "${{ github.event.repository.full_name }}"
--title "${{ github.ref_name }}"
--notes "[Changelog](${{ github.event.repository.html_url }}/blob/${{ github.ref_name }}/Changelog.md)"
2023-05-27 16:28:37 -04:00
--verify-tag
2022-04-21 18:13:36 -04:00
notify:
needs: deploy
runs-on: ubuntu-latest
permissions:
contents: read
2022-04-21 18:13:36 -04:00
steps:
- name: Notify Discord
2023-04-05 12:17:43 -04:00
uses: tyrrrz/action-http-request@v1
2022-04-21 18:13:36 -04:00
with:
url: ${{ secrets.DISCORD_WEBHOOK }}
method: POST
headers: |
2023-05-02 12:20:23 -04:00
Content-Type: application/json; charset=UTF-8
2023-04-06 04:01:45 -04:00
body: |
2022-04-21 18:13:36 -04:00
{
"avatar_url": "https://raw.githubusercontent.com/${{ github.event.repository.full_name }}/${{ github.ref_name }}/favicon.png",
"content": "**${{ github.event.repository.name }}** new version released!\nVersion: `${{ github.ref_name }}`\nChangelog: <${{ github.event.repository.html_url }}/blob/${{ github.ref_name }}/Changelog.md>"
}