diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b008b15..6b85cae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,8 @@ on: pull_request: push: branches: [main, mine] + release: + types: [published] jobs: test: @@ -55,9 +57,22 @@ jobs: - name: Build exe shell: powershell + env: + BOTTY_NO_RENAME: '1' run: | C:\Miniconda\condabin\conda.bat activate botty - python build.py --conda_path C:\Miniconda --random_name + python build.py --conda_path C:\Miniconda + + - name: Prepare release zip + shell: powershell + run: | + $BOTTY_DIR = Get-ChildItem -Directory -Name | Where-Object { $_ -match '^botty_v' } | Select-Object -First 1 + Write-Host "Botty dir: $BOTTY_DIR" + Get-ChildItem -Path $BOTTY_DIR -Recurse | Select-Object -Property FullName, Length + $ZIP = "${BOTTY_DIR}.zip" + Compress-Archive -Path "${BOTTY_DIR}\*" -DestinationPath $ZIP -Force + Write-Host "Release zip: $ZIP" + Get-Item $ZIP | Select-Object -Property FullName, Length - name: Upload build artifacts uses: actions/upload-artifact@v4 @@ -65,3 +80,12 @@ jobs: name: botty-build path: botty_v*/ retention-days: 7 + + - name: Upload to Release + if: github.event_name == 'release' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: bash + run: | + BOTTY_DIR=$(ls -d botty_v* | head -1) + gh release upload "${{ github.event.release.tag_name }}" "${BOTTY_DIR}.zip" --clobber diff --git a/build.py b/build.py index e39dd26..fed473e 100644 --- a/build.py +++ b/build.py @@ -97,8 +97,9 @@ if __name__ == "__main__": new_name = ''.join(random.choices(string.ascii_letters, k=random.randint(6, 14))) os.rename(f'{botty_dir}/main.exe', f'{botty_dir}/{new_name}.exe') - # Always rename main.exe to avoid Warden flagging the obvious name - if not args.random_name: + # Rename main.exe to avoid Warden flagging the obvious name + # In CI/production builds (env BOTTY_NO_RENAME=1) keep main.exe as-is + if not args.random_name and not os.environ.get("BOTTY_NO_RENAME"): new_name = ''.join(random.choices(string.ascii_lowercase + string.digits, k=8)) os.rename(f'{botty_dir}/main.exe', f'{botty_dir}/{new_name}.exe') print(f"Renamed main.exe -> {new_name}.exe")