Skip to content

Build and Release

Build and Release #114

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 }}
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_ENV
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Tag version
run: git tag ${{ env.version }}
- name: Push Tags
run: git push origin --tags
- name: Install dependencies
run: dotnet restore
- name: Publish Single File
run: dotnet publish -c Release -p:PublishSingleFile=true -p:DebugType=none -o ./publish/${{ matrix.platform }}
- name: Publish Single File 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 -R ./publish
# - name: Create Archives for Linux and MacOS
# if: matrix.platform != 'win-x64'
# run: |
# mkdir -p ./archives
# cd ./publish/${{ matrix.platform }}
# tar -czf ../../archives/extractor-${{ matrix.platform }}.tar.gz *
# cd ../${{ matrix.platform }}-no-runtime
# tar -czf ../../archives/extractor-${{ matrix.platform }}-no-runtime.tar.gz *
# 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: release-${{ matrix.platform }}
path: ./publish/${{ matrix.platform }}
- name: Upload Archives without .NET Runtime
uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.platform }}-no-runtime
path: ./publish/${{ matrix.platform }}-no-runtime
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download Archives
uses: actions/download-artifact@v4
- name: List downloaded files
run: ls -l