Skip to content

Update publish-dotnet-binaries.yml #51

Update publish-dotnet-binaries.yml

Update publish-dotnet-binaries.yml #51

name: Publish .NET Core binaries
on:
push:
branches:
- main
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
jobs:
create_publish:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get commit message
run: |
$COMMIT_MESSAGE = git log -1 --pretty=format:%s
Write-Host "::set-env name=COMMIT_MESSAGE::$COMMIT_MESSAGE"
#COMMIT_MESSAGE=$(git log -1 --pretty=format:%s)
#echo "::set-env name=COMMIT_MESSAGE::$COMMIT_MESSAGE"
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.BUILD_KEY }}
with:
tag_name: v${{ github.run_number }}
release_name: Release v${{ github.run_number }}
body: |
Auto release.
${{ env.COMMIT_MESSAGE }}
draft: false
prerelease: false
- name: Variable
run: |
echo "::set-output name=upload_url::${{ steps.create_release.outputs.upload_url }}"
publish_windows:
runs-on: windows-latest
needs: [create_publish]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.x
- name: Create paths
run: |
md build
md release
- name: Compile binaries
run: |
$RUNTIMES = @("win-x64","win-arm64")
dotnet restore ./src/jsunmap.sln
dotnet build ./src/jsunmap.sln --configuration Release /p:WarningLevel=0
foreach ($RUNTIME in $RUNTIMES) {
echo "building $RUNTIME"
dotnet publish ./src/jsunmap.csproj --configuration Release --self-contained --runtime $RUNTIME --verbosity quiet -p:PublishTrimmed=true -o ./build/$RUNTIME /p:WarningLevel=0
Compress-Archive -Path ./build/$RUNTIME -DestinationPath ./release/JsUnMap-${{ github.run_number }}-$RUNTIME.zip
}
ls ./release/
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.BUILD_KEY }}
with:
upload_url: ${{ needs.create_publish.outputs.upload_url }}
asset_path: |
./release/JsUnMap-${{ github.run_number }}-win-x64.zip
./release/JsUnMap-${{ github.run_number }}-win-arm64.zip
asset_name: |
JsUnMap-${{ github.run_number }}-win-x64.zip
JsUnMap-${{ github.run_number }}-win-arm64.zip
asset_content_type: |
application/zip
application/zip
publish_linux:
runs-on: linux-latest
needs: [create_publish,publish_windows]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.x
- name: Create paths
run: |
md build
md release
- name: Compile binaries
run: |
$RUNTIMES = @("linux-x64","linux-arm64",)
dotnet restore ./src/jsunmap.sln
dotnet build ./src/jsunmap.sln --configuration Release /p:WarningLevel=0
foreach ($RUNTIME in $RUNTIMES) {
echo "building $RUNTIME"
dotnet publish ./src/jsunmap.csproj --configuration Release --self-contained --runtime $RUNTIME --verbosity quiet -p:PublishTrimmed=true -o ./build/$RUNTIME /p:WarningLevel=0
Compress-Archive -Path ./build/$RUNTIME -DestinationPath ./release/JsUnMap-${{ github.run_number }}-$RUNTIME.zip
}
ls ./release/
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.BUILD_KEY }}
with:
upload_url: ${{ needs.create_publish.outputs.upload_url }}
asset_path: |
./release/JsUnMap-${{ github.run_number }}-linux-x64.zip
./release/JsUnMap-${{ github.run_number }}-linux-arm64.zip
asset_name: |
JsUnMap-${{ github.run_number }}-linux-x64.zip
JsUnMap-${{ github.run_number }}-linux-arm64.zip
asset_content_type: |
application/zip
application/zip