DiscordChatExporter/.github/workflows/main.yml

157 lines
4.2 KiB
YAML
Raw Normal View History

2022-04-21 18:13:36 -04:00
name: main
on: [push, pull_request]
jobs:
test:
runs-on: windows-latest
permissions:
contents: read
2022-04-21 18:13:36 -04:00
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
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"
--
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
needs: test
runs-on: windows-latest
permissions:
actions: write
contents: read
2022-04-21 18:13:36 -04:00
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
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: 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
2023-01-13 15:30:20 -05:00
uses: softprops/action-gh-release@v1
2022-04-21 18:13:36 -04:00
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
2023-01-13 15:30:20 -05:00
files: |
DiscordChatExporter.Cli.zip
DiscordChatExporter.zip
2022-04-21 18:13:36 -04:00
body: |
[Changelog](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/Changelog.md)
notify:
needs: deploy
runs-on: ubuntu-latest
permissions:
contents: read
2022-04-21 18:13:36 -04:00
steps:
- name: Get release version
2023-04-05 12:17:43 -04:00
id: get-version
uses: tyrrrz/action-get-tag@v1
2022-04-21 18:13:36 -04:00
- 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
{
2023-04-05 12:17:43 -04:00
"content": "**DiscordChatExporter** new version released!\nVersion: `${{ steps.get-version.outputs.tag }}`\nChangelog: <https://github.com/Tyrrrz/DiscordChatExporter/blob/${{ steps.get-version.outputs.tag }}/Changelog.md>"
}