Update dotnet.yml #44
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: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
workflow_dispatch: # This allows manual triggering of the workflow | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' # Only run on push events | |
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 | |
release: | |
permissions: | |
contents: write | |
runs-on: ${{ matrix.config.os }} | |
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: | |
# - shell: powershell | |
# run: | | |
# "mypath" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append | |
- 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: Read version from repository using Powershell | |
id: read-file-ps | |
shell: powershell | |
run: | | |
$content = Get-Content -Path version.txt -Raw | |
"outputContent=$content" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append | |
working-directory: ${{ github.workspace }} | |
- name: Create release | |
if: matrix.config.rid == 'linux-x64' | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v0.0.2 # Specify your desired tag name here | |
release_name: Release v0.0.2 # Specify your desired release name here | |
body: | | |
TODO | |
- name: Upload release asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./pack3r-release.zip | |
asset_name: pack3r-${{ matrix.config.rid }}.zip # Name of the release asset | |
asset_content_type: application/zip # Adjust the content type if necessary |