1- name : .NET
1+ name : Build Pre-Release
22
33on :
44 push :
@@ -17,11 +17,16 @@ jobs:
1717 - name : Setup .NET
1818 uses : actions/setup-dotnet@v4
1919 with :
20- dotnet-version : 6.0.x
21- - name : Publish for Linux-x64
22- run : dotnet publish -c Release -r linux-x64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -p:PublishReadyToRun=true -o app/linux-x64
23- - name : Publish for Windows-x64
24- run : dotnet publish -c Release -r win-x64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -p:PublishReadyToRun=true -o app/win-x64
20+ dotnet-version : 8.0.x
21+ - name : Publish
22+ run : |
23+ dotnet publish -c Release -r linux-x64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -o app/linux-x64
24+ dotnet publish -c Release -r win-x64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -o app/win-x64
25+ dotnet publish -c Release -r linux-arm64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -o app/linux-arm64
26+ cd app
27+ find . -type f -name 'appsettings.Example.json' -execdir mv {} appsettings.json \;
28+ find . -maxdepth 1 -type d ! -name '.' | xargs -I {} sh -c 'cd "{}" && zip -r "../${{ github.ref_name }}-$(basename {}).zip" *'
29+ find . -maxdepth 1 -type d ! -name '.' -exec rm -rf {} +
2530 - name : Upload artifacts
2631 uses : actions/upload-artifact@v3
2732 with :
3944 with :
4045 name : app
4146 path : app
42-
43- - name : Zip artifact
44- run : |
45- cd app
46- mv linux-x64/appsettings.Example.json linux-x64/appsettings.json
47- zip -r linux-x64.zip linux-x64/*
48- mv win-x64/appsettings.Example.json win-x64/appsettings.json
49- zip -r win-x64.zip win-x64/*
5047
5148 - name : Create Release
5249 id : create_release
@@ -59,27 +56,27 @@ jobs:
5956 draft : false
6057 prerelease : true
6158
62- - name : Upload Release Asset for Linux-x64
63- id : upload_linux
64- uses : actions/upload-release-asset@v1
65- env :
66- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
67- with :
68- upload_url : ${{ steps.create_release.outputs.upload_url }}
69- asset_path : app/linux-x64.zip
70- asset_name : linux-x64.zip
71- asset_content_type : application/zip
72-
73- - name : Upload Release Asset for Windows-x64
74- id : upload_win
75- uses : actions/upload-release-asset@v1
76- env :
77- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
59+ - name : Upload ZIP files to Release
60+ id : upload_zip
61+ uses : actions/github-script@v3
7862 with :
79- upload_url : ${{ steps.create_release.outputs.upload_url }}
80- asset_path : app/win-x64.zip
81- asset_name : win-x64.zip
82- asset_content_type : application/zip
63+ github-token : ${{secrets.GITHUB_TOKEN}}
64+ script : |
65+ const path = require('path');
66+ const fs = require('fs');
67+ const release_id = '${{ steps.create_release.outputs.id }}';
68+ for (let file of await fs.readdirSync('app/')) {
69+ if (path.extname(file) === '.zip') {
70+ console.log('uploadReleaseAsset', file);
71+ await github.repos.uploadReleaseAsset({
72+ owner: context.repo.owner,
73+ repo: context.repo.repo,
74+ release_id: release_id,
75+ name: file,
76+ data: await fs.readFileSync(`app/${file}`)
77+ });
78+ }
79+ }
8380
8481 cleanup :
8582 name : Cleanup
0 commit comments