Skip to content

Update publish-dotnet-binaries.yml #127

Update publish-dotnet-binaries.yml

Update publish-dotnet-binaries.yml #127

name: Publish .NET Core binaries
on:
push:
branches:
- main
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
jobs:
release_and_publish:
name: Create release and publish
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
#arch: ["x64", "arm64"]
include:
- os: windows-latest
target_os: windows
arch_list: "win-x64,win-arm64"
- os: ubuntu-latest
target_os: linux
arch_list: "linux-x64"
- os: macos-latest
target_os: macos
arch_list: "osx-x64"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Get commit message windows
if: matrix.target_os == 'windows'
run: |
$COMMIT_MESSAGE = git log -1 --pretty=format:%s
Write-Host "::set-env name=COMMIT_MESSAGE::$COMMIT_MESSAGE"
- name: Get commit message unix
if: matrix.target_os != 'windows'
run: |
COMMIT_MESSAGE=$(git log -1 --pretty=format:%s)
echo "::set-env name=COMMIT_MESSAGE::$COMMIT_MESSAGE"
- name: Build
shell: bash
run: |
version=${{ github.run_number }}
IFS=',' read -ra matrix_arch_list <<< "${{ matrix.arch_list }}"
for arch in "${matrix_arch_list[@]}"; do
target_os_filename="${{ matrix.target_os }}-$arch"
release_name_standalone="jsunmap-$version-standalone-$target_os_filename"
release_name="jsunmap-$version-$target_os_filename"
target_arch="$arch"
echo "Arch: $target_arch"
echo "Self contained: $release_name_standalone"
dotnet restore ./src/jsunmap.sln
# Self contained
dotnet publish ./src/jsunmap.csproj --configuration Release --self-contained --runtime "$target_arch" -o "$release_name_standalone"
echo "Framework dependant: $release_name"
# Framework dependant
dotnet publish ./src/jsunmap.csproj --configuration Release --self-contained false --runtime "$target_arch" -o "$release_name"
if [[ "${{ matrix.target_os }}" == "windows" ]]; then
# Pack for standalone version
7z a -tzip "${release_name_standalone}.zip" "./${release_name_standalone}/*"
# Pack for Framework dependant version
7z a -tzip "${release_name}.zip" "./${release_name}/*"
else
tar czvf "${release_name_standalone}.tar.gz" "$release_name_standalone"
tar czvf "${release_name}.tar.gz" "$release_name"
fi
rm -r "$release_name_standalone"
rm -r "$release_name"
done
- name: Generate release tag
id: tag
run: |
echo "::set-output name=release_tag::UserBuild_$(date +"%Y.%m.%d_%H-%M")"
- name: Release files
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.release_tag }}
files: "jsunmap-*"