DiscordChatExporter/.github/workflows/main.yml

155 lines
4.8 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
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:
# Fixed version, workaround for https://github.com/dotnet/core/issues/7176
dotnet-version: 6.0.100
- 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' }}
run: dotnet test --configuration Release --logger GitHubActions --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
env:
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
DISCORD_TOKEN_BOT: true
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
2022-08-13 07:13:09 -04:00
package:
2022-04-21 18:13:36 -04:00
needs: test
runs-on: windows-latest
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:
# Fixed version, workaround for https://github.com/dotnet/core/issues/7176
dotnet-version: 6.0.100
- name: Publish (CLI)
run: dotnet publish DiscordChatExporter.Cli/ -o DiscordChatExporter.Cli/bin/Publish/ --configuration Release
- name: Publish (GUI)
run: dotnet publish DiscordChatExporter.Gui/ -o DiscordChatExporter.Gui/bin/Publish/ --configuration Release
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
2022-04-21 18:13:36 -04:00
path: DiscordChatExporter.Cli/bin/Publish/
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/bin/Publish/
deploy:
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
2022-08-13 07:13:09 -04:00
needs: package
2022-04-21 18:13:36 -04:00
runs-on: ubuntu-latest
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)
2022-04-30 09:04:57 -04:00
run: Compress-Archive -Path DiscordChatExporter.Cli/* -DestinationPath DiscordChatExporter.Cli.zip -Force
2022-04-21 18:13:36 -04:00
shell: pwsh
- name: Create package (GUI)
2022-04-30 09:04:57 -04:00
run: Compress-Archive -Path DiscordChatExporter.Gui/* -DestinationPath DiscordChatExporter.Gui.zip -Force
2022-04-21 18:13:36 -04:00
shell: pwsh
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: |
[Changelog](https://github.com/Tyrrrz/DiscordChatExporter/blob/master/Changelog.md)
draft: false
prerelease: false
- name: Upload release asset (CLI)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
2022-04-30 09:04:57 -04:00
asset_name: DiscordChatExporter.Cli.zip
asset_path: DiscordChatExporter.Cli.zip
2022-04-21 18:13:36 -04:00
asset_content_type: application/zip
- name: Upload release asset (GUI)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_name: DiscordChatExporter.zip
2022-04-30 09:04:57 -04:00
asset_path: DiscordChatExporter.Gui.zip
2022-04-21 18:13:36 -04:00
asset_content_type: application/zip
notify:
needs: deploy
runs-on: ubuntu-latest
steps:
- name: Get release version
id: get_version
uses: dawidd6/action-get-tag@v1
- name: Notify Discord
uses: satak/webrequest-action@v1.2.4
with:
url: ${{ secrets.DISCORD_WEBHOOK }}
method: POST
headers: |
{
"ContentType": "application/json; charset=UTF-8"
}
payload: |
{
"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>"
2022-08-13 07:13:09 -04:00
}