|
| 1 | +name: Build Standalone Binaries |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: ["v*"] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + include: |
| 15 | + - os: ubuntu-latest |
| 16 | + artifact: ossguard-linux-amd64 |
| 17 | + pyinstaller_args: "" |
| 18 | + - os: macos-latest |
| 19 | + artifact: ossguard-macos-arm64 |
| 20 | + pyinstaller_args: "" |
| 21 | + - os: windows-latest |
| 22 | + artifact: ossguard-windows-amd64.exe |
| 23 | + pyinstaller_args: "" |
| 24 | + |
| 25 | + runs-on: ${{ matrix.os }} |
| 26 | + |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v6 |
| 29 | + |
| 30 | + - uses: actions/setup-python@v6 |
| 31 | + with: |
| 32 | + python-version: "3.12" |
| 33 | + |
| 34 | + - name: Install dependencies |
| 35 | + run: | |
| 36 | + pip install -e . |
| 37 | + pip install pyinstaller |
| 38 | +
|
| 39 | + - name: Build binary |
| 40 | + run: | |
| 41 | + pyinstaller --onefile --name ossguard --clean \ |
| 42 | + --hidden-import ossguard.analyzers \ |
| 43 | + --hidden-import ossguard.generators \ |
| 44 | + --hidden-import ossguard.parsers \ |
| 45 | + --hidden-import ossguard.apis \ |
| 46 | + --collect-submodules ossguard \ |
| 47 | + src/ossguard/cli.py |
| 48 | + shell: bash |
| 49 | + |
| 50 | + - name: Rename artifact |
| 51 | + run: | |
| 52 | + if [ "${{ runner.os }}" = "Windows" ]; then |
| 53 | + mv dist/ossguard.exe "dist/${{ matrix.artifact }}" |
| 54 | + else |
| 55 | + mv dist/ossguard "dist/${{ matrix.artifact }}" |
| 56 | + fi |
| 57 | + shell: bash |
| 58 | + |
| 59 | + - name: Upload artifact |
| 60 | + uses: actions/upload-artifact@v7 |
| 61 | + with: |
| 62 | + name: ${{ matrix.artifact }} |
| 63 | + path: dist/${{ matrix.artifact }} |
| 64 | + |
| 65 | + release: |
| 66 | + needs: build |
| 67 | + runs-on: ubuntu-latest |
| 68 | + permissions: |
| 69 | + contents: write |
| 70 | + steps: |
| 71 | + - name: Download all artifacts |
| 72 | + uses: actions/download-artifact@v8 |
| 73 | + |
| 74 | + - name: Generate checksums |
| 75 | + run: | |
| 76 | + mkdir -p release |
| 77 | + for dir in ossguard-*; do |
| 78 | + cp "$dir"/* release/ 2>/dev/null || true |
| 79 | + done |
| 80 | + cd release |
| 81 | + sha256sum * > checksums-sha256.txt |
| 82 | +
|
| 83 | + - name: Upload to GitHub Release |
| 84 | + uses: softprops/action-gh-release@v2 |
| 85 | + with: |
| 86 | + files: release/* |
| 87 | + fail_on_unmatched_files: false |
0 commit comments