Skip to content

change platform because dotnet make arm platform not x64 #48

change platform because dotnet make arm platform not x64

change platform because dotnet make arm platform not x64 #48

Workflow file for this run

name: Build Cyz2Json
on:
push:
tags:
- 'v*'
workflow_dispatch: # Allows manual triggering
inputs:
version:
description: 'Version tag (e.g. v1.0.0)'
required: true
type: string
reason:
description: 'Reason for manual trigger'
required: false
default: 'Manual run'
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Set RID
id: set-rid
run: |
if [ "${{ matrix.os }}" == "windows-latest" ]; then
echo "rid=win-x64" >> $GITHUB_OUTPUT
elif [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
echo "rid=linux-x64" >> $GITHUB_OUTPUT
elif [ "${{ matrix.os }}" == "macos-latest" ]; then
echo "rid=osx-arm64" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Publish
run: dotnet publish Cyz2Json/Cyz2Json.csproj -c Release --self-contained true
- name: Copy License File
if: matrix.os == 'windows-latest'
run: Copy-Item LICENSE.txt -Destination "Cyz2Json/bin/Release/net8.0/win-x64/publish/"
shell: pwsh
- name: Copy License File
if: matrix.os != 'windows-latest'
run: cp LICENSE.txt Cyz2Json/bin/Release/net8.0/*/publish/
shell: bash
- name: Zip Release Files
if: matrix.os == 'windows-latest'
run: Compress-Archive -Path "./Cyz2Json/bin/Release/net8.0/*/*/" -DestinationPath "cyz2json-${{ matrix.os }}.zip"
shell: pwsh
- name: Zip Release Files
if: matrix.os != 'windows-latest'
# run: zip -r cyz2json-${{ matrix.os }}.zip ./Cyz2Json/bin/Release/net8.0/*/*/
run: cd Cyz2Json/bin/Release/net8.0/${{ steps.set-rid.outputs.rid }}/publish && zip -r ../../../../../../cyz2json-${{ matrix.os }}.zip ./*
shell: bash
- name: Check Release
id: check_release
uses: actions/github-script@v6
with:
script: |
const version = '${{ github.event.inputs.version || github.ref_name }}'
const reason = '${{ github.event.inputs.reason }}'
try {
const release = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: version
})
core.setOutput('upload_url', release.data.upload_url.split('{')[0])
} catch (error) {
const release = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: version,
name: 'Release ' + version,
body: reason
})
core.setOutput('upload_url', release.data.upload_url.split('{')[0])
}
# - name: Create Release
# id: create_release
# if: steps.check_release.outputs.result == ''
# uses: actions/create-release@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# tag_name: ${{ github.event.inputs.version || github.ref_name }}
# release_name: Release ${{ github.event.inputs.version || github.ref_name }}
# body: ${{ github.event.inputs.reason }}
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.check_release.outputs.upload_url }}?name=cyz2json-${{ matrix.os }}.zip # put in Download/vx.x.x
# upload_url: ${{ format('{0}/latest/assets{1}', github.api_url, '?name=cyz2json-') }}${{ matrix.os }}.zip # put in Download/latest
asset_path: cyz2json-${{ matrix.os }}.zip
asset_name: cyz2json-${{ matrix.os }}.zip
asset_content_type: application/zip