DiscordChatExporter/.github/workflows/main.yml

127 lines
3.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:
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' }}
run: dotnet test --configuration Release --logger GitHubActions --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
env:
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
- 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:
2022-12-07 18:44:26 -05:00
dotnet-version: 7.0.x
2022-04-21 18:13:36 -04:00
- 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)
2023-01-13 15:30:20 -05:00
run: Compress-Archive -Path DiscordChatExporter.Gui/* -DestinationPath DiscordChatExporter.zip -Force
2022-04-21 18:13:36 -04:00
shell: pwsh
- 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
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>"
2023-05-02 12:20:23 -04:00
}