DiscordChatExporter/.github/workflows/main.yml

142 lines
4.6 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
2023-10-04 08:41:48 -04:00
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # 4.1.0
2022-04-21 18:13:36 -04:00
- name: Install .NET
2023-10-04 08:41:48 -04:00
uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # 3.2.0
2022-04-21 18:13:36 -04:00
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-10-24 08:13:30 -04:00
env:
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
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
- name: Upload coverage
2023-10-04 08:41:48 -04:00
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # 3.1.4
2022-04-21 18:13:36 -04:00
with:
token: ${{ secrets.CODECOV_TOKEN }}
pack:
2023-10-24 08:13:30 -04:00
strategy:
matrix:
app: [DiscordChatExporter.Cli, DiscordChatExporter.Gui]
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
2023-10-04 08:41:48 -04:00
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # 4.1.0
2022-04-21 18:13:36 -04:00
- name: Install .NET
2023-10-04 08:41:48 -04:00
uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # 3.2.0
2022-04-21 18:13:36 -04:00
with:
2022-12-07 18:44:26 -05:00
dotnet-version: 7.0.x
2022-04-21 18:13:36 -04:00
2023-10-24 08:13:30 -04:00
- name: Publish app
2023-05-10 17:59:08 -04:00
run: >
2023-10-24 08:13:30 -04:00
dotnet publish ${{ matrix.app }}
--output ${{ matrix.app }}/publish/
2023-05-10 17:59:08 -04:00
--configuration Release
2022-04-21 18:13:36 -04:00
2023-10-24 08:13:30 -04:00
- name: Upload artifacts
2023-10-04 08:41:48 -04:00
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # 3.1.3
2022-04-21 18:13:36 -04:00
with:
2023-10-24 08:13:30 -04:00
name: ${{ matrix.app }}
path: ${{ matrix.app }}/publish/
2022-04-21 18:13:36 -04:00
deploy:
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
2023-10-24 08:13:30 -04:00
needs:
- test
- pack
2023-10-24 08:13:30 -04:00
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)
2023-10-04 08:41:48 -04:00
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # 3.0.2
2022-04-21 18:13:36 -04:00
with:
2022-04-30 09:04:57 -04:00
name: DiscordChatExporter.Cli
2023-10-24 08:13:30 -04:00
path: DiscordChatExporter.Cli/
2022-04-21 18:13:36 -04:00
2022-04-21 19:10:00 -04:00
- name: Download artifacts (GUI)
2023-10-04 08:41:48 -04:00
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # 3.0.2
2022-04-21 18:13:36 -04:00
with:
2023-10-24 08:13:30 -04:00
name: DiscordChatExporter.Gui
path: DiscordChatExporter.Gui/
2022-04-21 18:13:36 -04:00
- name: Create package (CLI)
2023-10-25 17:03:55 -04:00
# Change into the artifacts directory to avoid including the directory itself in the zip archive
working-directory: DiscordChatExporter.Cli/
run: zip -r ../DiscordChatExporter.Cli.zip .
2022-04-21 18:13:36 -04:00
- name: Create package (GUI)
2023-10-25 17:03:55 -04:00
# Change into the artifacts directory to avoid including the directory itself in the zip archive
working-directory: DiscordChatExporter.Gui/
run: zip -r ../DiscordChatExporter.Gui.zip .
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"
2023-10-24 08:13:30 -04:00
"DiscordChatExporter.Gui.zip#DiscordChatExporter.zip"
2023-06-08 18:20:47 -04:00
--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-10-05 07:51:15 -04:00
uses: tyrrrz/action-http-request@64c70c67f5ebc54d4c7ea09cbe3553322778afd5 # 1.1.2
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",
2023-10-17 09:18:44 -04:00
"content": "**${{ github.event.repository.name }}** v${{ github.ref_name }} has been released!\n🔗 [Download](<${{ github.event.repository.html_url }}/releases/tag/${{ github.ref_name }}>) • [Changelog](<${{ github.event.repository.html_url }}/blob/${{ github.ref_name }}/Changelog.md>)"
2023-10-04 12:57:35 -04:00
}
retry-count: 5