|
| 1 | +# Release Build Workflow |
| 2 | +# Automatically builds Windows executable and creates GitHub release when a version tag is pushed |
| 3 | + |
| 4 | +name: Release Build |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + tags: |
| 9 | + - 'v*' |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + build-windows: |
| 16 | + name: Build Windows Executable |
| 17 | + runs-on: windows-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout code |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Set up Python |
| 24 | + uses: actions/setup-python@v5 |
| 25 | + with: |
| 26 | + python-version: '3.12' |
| 27 | + |
| 28 | + - name: Install dependencies |
| 29 | + run: | |
| 30 | + python -m pip install --upgrade pip |
| 31 | + pip install -r requirements.txt |
| 32 | + pip install pyinstaller |
| 33 | +
|
| 34 | + - name: Run tests |
| 35 | + run: | |
| 36 | + pytest tests/test_release_smoke.py -v |
| 37 | +
|
| 38 | + - name: Build executable |
| 39 | + run: | |
| 40 | + pyinstaller --onefile --name TechCompressor --console techcompressor/cli.py |
| 41 | +
|
| 42 | + - name: Test executable |
| 43 | + run: | |
| 44 | + dist\TechCompressor.exe --version |
| 45 | + dist\TechCompressor.exe --help |
| 46 | +
|
| 47 | + - name: Get version from tag |
| 48 | + id: get_version |
| 49 | + shell: bash |
| 50 | + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 51 | + |
| 52 | + - name: Create release ZIP |
| 53 | + run: | |
| 54 | + Compress-Archive -Path dist\TechCompressor.exe -DestinationPath dist\TechCompressor-${{ steps.get_version.outputs.VERSION }}-Windows-x64.zip |
| 55 | +
|
| 56 | + - name: Upload artifact |
| 57 | + uses: actions/upload-artifact@v4 |
| 58 | + with: |
| 59 | + name: windows-executable |
| 60 | + path: | |
| 61 | + dist/TechCompressor.exe |
| 62 | + dist/TechCompressor-*.zip |
| 63 | +
|
| 64 | + build-linux: |
| 65 | + name: Build Linux Executable |
| 66 | + runs-on: ubuntu-latest |
| 67 | + |
| 68 | + steps: |
| 69 | + - name: Checkout code |
| 70 | + uses: actions/checkout@v4 |
| 71 | + |
| 72 | + - name: Set up Python |
| 73 | + uses: actions/setup-python@v5 |
| 74 | + with: |
| 75 | + python-version: '3.12' |
| 76 | + |
| 77 | + - name: Install dependencies |
| 78 | + run: | |
| 79 | + python -m pip install --upgrade pip |
| 80 | + pip install -r requirements.txt |
| 81 | + pip install pyinstaller |
| 82 | +
|
| 83 | + - name: Run tests |
| 84 | + run: | |
| 85 | + pytest tests/test_release_smoke.py -v |
| 86 | +
|
| 87 | + - name: Build executable |
| 88 | + run: | |
| 89 | + pyinstaller --onefile --name techcompressor --console techcompressor/cli.py |
| 90 | +
|
| 91 | + - name: Test executable |
| 92 | + run: | |
| 93 | + chmod +x dist/techcompressor |
| 94 | + dist/techcompressor --version |
| 95 | + dist/techcompressor --help |
| 96 | +
|
| 97 | + - name: Get version from tag |
| 98 | + id: get_version |
| 99 | + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 100 | + |
| 101 | + - name: Create release tarball |
| 102 | + run: | |
| 103 | + cd dist |
| 104 | + tar -czvf techcompressor-${{ steps.get_version.outputs.VERSION }}-Linux-x64.tar.gz techcompressor |
| 105 | +
|
| 106 | + - name: Upload artifact |
| 107 | + uses: actions/upload-artifact@v4 |
| 108 | + with: |
| 109 | + name: linux-executable |
| 110 | + path: | |
| 111 | + dist/techcompressor |
| 112 | + dist/techcompressor-*.tar.gz |
| 113 | +
|
| 114 | + create-release: |
| 115 | + name: Create GitHub Release |
| 116 | + runs-on: ubuntu-latest |
| 117 | + needs: [build-windows, build-linux] |
| 118 | + |
| 119 | + steps: |
| 120 | + - name: Checkout code |
| 121 | + uses: actions/checkout@v4 |
| 122 | + |
| 123 | + - name: Download Windows artifact |
| 124 | + uses: actions/download-artifact@v4 |
| 125 | + with: |
| 126 | + name: windows-executable |
| 127 | + path: dist/windows |
| 128 | + |
| 129 | + - name: Download Linux artifact |
| 130 | + uses: actions/download-artifact@v4 |
| 131 | + with: |
| 132 | + name: linux-executable |
| 133 | + path: dist/linux |
| 134 | + |
| 135 | + - name: Get version from tag |
| 136 | + id: get_version |
| 137 | + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 138 | + |
| 139 | + - name: Create Release |
| 140 | + uses: softprops/action-gh-release@v2 |
| 141 | + with: |
| 142 | + name: TechCompressor ${{ steps.get_version.outputs.VERSION }} |
| 143 | + draft: false |
| 144 | + prerelease: false |
| 145 | + generate_release_notes: true |
| 146 | + files: | |
| 147 | + dist/windows/TechCompressor-*.zip |
| 148 | + dist/linux/techcompressor-*.tar.gz |
| 149 | + env: |
| 150 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments