Skip to content

Build and Release

Build and Release #136

name: Build and Release
on:
workflow_dispatch:
push:
branches:
- main
paths:
- '**.csproj'
- 'Program.cs'
- 'icon.ico'
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
platform: linux-x64
- os: windows-latest
platform: win-x64
- os: macos-latest
platform: osx-x64
runs-on: ${{ matrix.os }}
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Get Project Version
id: version
run: echo "version=$(sed -n 's:.*<Version>\(.*\)</Version>.*:\1:p' ./metadata-extractor-cli.csproj)" >> $GITHUB_OUTPUT
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Tag version
run: git tag ${{ steps.version.outputs.version }}
- name: Push Tags
run: git push origin --tags
- name: Install dependencies
run: dotnet restore
- name: Publish Single File Executable
run: dotnet publish -c Release -p:PublishSingleFile=true -p:DebugType=none -o ./publish/${{ matrix.platform }}
- name: Publish Single File Executable without .NET Runtime
run: dotnet publish -c Release -p:PublishSingleFile=true -p:SelfContained=false -p:DebugType=none -o ./publish/${{ matrix.platform }}-no-runtime
- name: List Publish Directory
run: ls -l ./publish
- name: Create Archives for Linux and MacOS
if: matrix.platform != 'win-x64'
run: |
mkdir -p ./archives
cd ./publish/${{ matrix.platform }}
zip -r ../../archives/extractor-${{ matrix.platform }}.zip *
cd ../${{ matrix.platform }}-no-runtime
zip -r ../../archives/extractor-${{ matrix.platform }}-no-runtime.zip *
cd ../..
shell: bash
- name: Create Archives for Windows (use powershell)
if: matrix.platform == 'win-x64'
run: |
mkdir .\archives
cd .\publish\${{ matrix.platform }}
Compress-Archive -Path * -DestinationPath ..\..\archives\extractor-${{ matrix.platform }}.zip
cd ..\${{ matrix.platform }}-no-runtime
Compress-Archive -Path * -DestinationPath ..\..\archives\extractor-${{ matrix.platform }}-no-runtime.zip
cd ..\..
shell: powershell
- name: List Archives
run: ls -l ./archives
- name: Upload Archives
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }}
path: ./archives/
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download Archives
uses: actions/download-artifact@v4
with:
path: archives
merge-multiple: true
- name: List downloaded files
run: ls -l -R
- name: Create Release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.DYGNITORZ_TOKEN_OLD }}
with:
tag_name: ${{ needs.build.outputs.version }}
files: |
./archives/*