Reduce repetition in workflows using matrices

pull/1149/head
Tyrrrz 1 year ago
parent c607c6f307
commit 692438d10c

@ -44,7 +44,9 @@ jobs:
pack: pack:
strategy: strategy:
matrix: matrix:
app: [DiscordChatExporter.Cli, DiscordChatExporter.Gui] app:
- DiscordChatExporter.Cli
- DiscordChatExporter.Gui
runs-on: windows-latest runs-on: windows-latest
permissions: permissions:
@ -72,7 +74,7 @@ jobs:
name: ${{ matrix.app }} name: ${{ matrix.app }}
path: ${{ matrix.app }}/publish/ path: ${{ matrix.app }}/publish/
deploy: release:
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }} if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
needs: needs:
@ -81,43 +83,57 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
actions: read
contents: write contents: write
steps: steps:
- name: Download artifacts (CLI) - name: Create release
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # 3.0.2 env:
with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: DiscordChatExporter.Cli run: >
path: DiscordChatExporter.Cli/ gh release create "${{ github.ref_name }}"
--repo "${{ github.event.repository.full_name }}"
--title "${{ github.ref_name }}"
--notes "[Changelog](${{ github.event.repository.html_url }}/blob/${{ github.ref_name }}/Changelog.md)"
--verify-tag
- name: Download artifacts (GUI) deploy:
strategy:
matrix:
app:
- DiscordChatExporter.Cli
- DiscordChatExporter.Gui
include:
- app: DiscordChatExporter.Cli
asset: DiscordChatExporter.Cli
- app: DiscordChatExporter.Gui
# GUI asset isn't suffixed, unlike the CLI asset
asset: DiscordChatExporter
needs: release
runs-on: ubuntu-latest
permissions:
actions: read
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # 3.0.2 uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # 3.0.2
with: with:
name: DiscordChatExporter.Gui name: ${{ matrix.app }}
path: DiscordChatExporter.Gui/ path: ${{ matrix.app }}/
- name: Create package (CLI)
# 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 .
- name: Create package (GUI) - name: Create package
# Change into the artifacts directory to avoid including the directory itself in the zip archive # Change into the artifacts directory to avoid including the directory itself in the zip archive
working-directory: DiscordChatExporter.Gui/ working-directory: ${{ matrix.app }}/
run: zip -r ../DiscordChatExporter.Gui.zip . run: zip -r ../${{ matrix.asset }}.zip .
- name: Create release - name: Create release
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: > run: >
gh release create "${{ github.ref_name }}" gh release upload "${{ github.ref_name }}"
"DiscordChatExporter.Cli.zip" "${{ matrix.asset }}.zip"
"DiscordChatExporter.Gui.zip#DiscordChatExporter.zip"
--repo "${{ github.event.repository.full_name }}" --repo "${{ github.event.repository.full_name }}"
--title "${{ github.ref_name }}"
--notes "[Changelog](${{ github.event.repository.html_url }}/blob/${{ github.ref_name }}/Changelog.md)"
--verify-tag
notify: notify:
needs: deploy needs: deploy

Loading…
Cancel
Save