.NET #53
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will build a .NET project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
name: .NET | |
on: | |
pull_request: | |
branches: [ "master" ] | |
workflow_dispatch: | |
inputs: | |
version: | |
required: true | |
description: | |
required: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'pull_request' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --no-restore | |
- name: Test | |
run: dotnet test --no-build --verbosity normal | |
create_release: | |
if: github.event_name == 'workflow_dispatch' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ inputs.version }} | |
release_name: Release ${{ inputs.version }} | |
body: ${{ inputs.description }} | |
outputs: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
publish: | |
permissions: | |
contents: write | |
runs-on: ${{ matrix.config.os }} | |
needs: create_release | |
if: github.event_name == 'workflow_dispatch' # Only run on workflow_dispatch events | |
strategy: | |
matrix: | |
config: | |
- os: ubuntu-latest | |
rid: linux-x64 | |
- os: windows-latest | |
rid: win-x64 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- name: Publish | |
run: dotnet publish Pack3r.Console --self-contained -c Release -o release_dir -r ${{ matrix.config.rid }} | |
- name: Create Zip File | |
uses: papeloto/action-zip@v1 | |
with: | |
files: ./release_dir | |
dest: ./pack3r-release.zip | |
- name: Upload release asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create_release.outputs.upload_url }} | |
asset_path: ./pack3r-release.zip | |
asset_name: pack3r-${{ inputs.version }}-${{ matrix.config.rid }}.zip # Name of the release asset | |
asset_content_type: application/zip # Adjust the content type if necessary |