Update publish-dotnet-binaries.yml #118
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
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,linux-arm64" | |
- 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: Install unix requirements for arm64 build | |
if: matrix.target_os == 'linux' | |
run: | | |
sudo rm /etc/apt/sources.list | |
sudo rm /etc/apt/sources.list.d/ppaname-ppa-$(lsb_release -sc).list* | |
sudo apt-get update | |
sudo dpkg --add-architecture arm64 | |
sudo apt-get update && sudo apt-get install clang llvm binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu zlib1g-dev:arm64 -y | |
- 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" -v d | |
echo "Framework dependant: $release_name" | |
# Framework dependant | |
dotnet publish ./src/jsunmap.csproj --configuration Release --self-contained false --runtime "$target_arch" -o "$release_name" -v d | |
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: Publish | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: "jsunmap-*" | |