44 push :
55 tags :
66 - ' v*' # Run workflow on version tags, e.g. v1.0.0
7+ workflow_dispatch :
8+ inputs :
9+ tag_name :
10+ description : ' Version tag for this release (e.g. v1.0.0)'
11+ required : true
12+ default : ' v1.0.0'
713
814jobs :
9- create-release :
10- runs-on : ubuntu-latest
11- outputs :
12- upload_url : ${{ steps.create_release.outputs.upload_url }}
13- steps :
14- - name : Create Release
15- id : create_release
16- uses : actions/create-release@v1
17- env :
18- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
19- with :
20- tag_name : ${{ github.ref }}
21- release_name : Release ${{ github.ref }}
22- draft : false
23- prerelease : false
24-
2515 build-and-release :
26- needs : create-release
2716 runs-on : ${{ matrix.os }}
2817 strategy :
18+ fail-fast : false
2919 matrix :
3020 include :
3121 - os : windows-latest
@@ -40,10 +30,12 @@ jobs:
4030
4131 steps :
4232 - name : Checkout code
43- uses : actions/checkout@v3
33+ uses : actions/checkout@v2
34+ with :
35+ fetch-depth : 0 # Necessario per accedere ai tag
4436
4537 - name : Set up Python
46- uses : actions/setup-python@v4
38+ uses : actions/setup-python@v2
4739 with :
4840 python-version : ' 3.9'
4941
@@ -54,31 +46,97 @@ jobs:
5446 if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
5547 shell : bash
5648
49+ - name : Determine tag name
50+ id : get_tag
51+ run : |
52+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
53+ echo "::set-output name=tag::${{ github.event.inputs.tag_name }}"
54+ else
55+ echo "::set-output name=tag::${GITHUB_REF#refs/tags/}"
56+ fi
57+ shell : bash
58+
5759 - name : Build with PyInstaller
5860 run : |
5961 pyinstaller go-dispatch-proxy-gui.spec
60-
62+ # Debug: Stampa il contenuto della directory corrente e della directory dist se esiste
63+ ls -la
64+ if [ -d "dist" ]; then ls -la dist; fi
65+ shell : bash
66+
67+ # Usiamo una logica più sicura per gli archivi
6168 - name : Archive Windows build
6269 if : matrix.os == 'windows-latest'
6370 run : |
64- powershell Compress-Archive -Path dist/* -DestinationPath ${{ matrix.asset_name }}${{ matrix.asset_extension }}
65-
71+ # Crea una directory per gli archivi
72+ mkdir -p artifacts
73+ # Verifica se dist esiste e contiene file
74+ if (Test-Path -Path "dist") {
75+ if (Get-ChildItem -Path "dist" | Where-Object { !$_.PSIsContainer }) {
76+ Compress-Archive -Path "dist/*" -DestinationPath "artifacts/${{ matrix.asset_name }}${{ matrix.asset_extension }}"
77+ } else {
78+ echo "dist directory is empty or contains only subdirectories"
79+ dir dist
80+ # Crea un file vuoto per non far fallire l'upload
81+ New-Item -Path "artifacts/build-log.txt" -ItemType "file" -Value "Build resulted in empty dist directory"
82+ }
83+ } else {
84+ echo "dist directory does not exist"
85+ dir
86+ # Crea un file vuoto per non far fallire l'upload
87+ New-Item -Path "artifacts/build-log.txt" -ItemType "file" -Value "Build failed to create dist directory"
88+ }
89+ shell : pwsh
90+
6691 - name : Archive Linux build
6792 if : matrix.os == 'ubuntu-latest'
6893 run : |
69- tar -C dist -czvf ${{ matrix.asset_name }}${{ matrix.asset_extension }} .
70-
94+ # Crea una directory per gli archivi
95+ mkdir -p artifacts
96+ # Verifica se dist esiste e contiene file
97+ if [ -d "dist" ] && [ "$(ls -A dist)" ]; then
98+ tar -czvf artifacts/${{ matrix.asset_name }}${{ matrix.asset_extension }} -C dist .
99+ else
100+ echo "dist directory does not exist or is empty"
101+ ls -la
102+ # Crea un file vuoto per non far fallire l'upload
103+ echo "Build failed to create proper dist directory" > artifacts/build-log.txt
104+ fi
105+ shell : bash
106+
71107 - name : Archive macOS build
72108 if : matrix.os == 'macos-latest'
73109 run : |
74- ditto -c -k --keepParent dist ${{ matrix.asset_name }}${{ matrix.asset_extension }}
110+ # Crea una directory per gli archivi
111+ mkdir -p artifacts
112+ # Verifica se dist esiste e contiene file
113+ if [ -d "dist" ] && [ "$(ls -A dist)" ]; then
114+ ditto -c -k --keepParent dist artifacts/${{ matrix.asset_name }}${{ matrix.asset_extension }}
115+ else
116+ echo "dist directory does not exist or is empty"
117+ ls -la
118+ # Crea un file vuoto per non far fallire l'upload
119+ echo "Build failed to create proper dist directory" > artifacts/build-log.txt
120+ fi
121+ shell : bash
122+
123+ # Carica gli archivi come artefatti (opzionale, utile per debug)
124+ - name : Upload build artifacts
125+ uses : actions/upload-pages-artifact@v3
126+ with :
127+ name : release-${{ matrix.os }}
128+ path : artifacts/
75129
76- - name : Upload Release Asset
77- uses : actions/upload-release-asset@v1
130+ # Crea o aggiorna la release e carica gli asset
131+ - name : Create/Update Release
132+ uses : softprops/action-gh-release@v1
78133 env :
79134 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
80135 with :
81- upload_url : ${{ needs.create-release.outputs.upload_url }}
82- asset_path : ./${{ matrix.asset_name }}${{ matrix.asset_extension }}
83- asset_name : ${{ matrix.asset_name }}${{ matrix.asset_extension }}
84- asset_content_type : application/octet-stream
136+ tag_name : ${{ steps.get_tag.outputs.tag }}
137+ name : Release ${{ steps.get_tag.outputs.tag }}
138+ draft : false
139+ prerelease : false
140+ files : |
141+ artifacts/${{ matrix.asset_name }}${{ matrix.asset_extension }}
142+ artifacts/build-log.txt
0 commit comments