|
| 1 | +name: release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: ["v*"] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + |
| 10 | +jobs: |
| 11 | + release: |
| 12 | + runs-on: windows-latest |
| 13 | + env: |
| 14 | + WINDOWS_CERTIFICATE_BASE64: ${{ secrets.WINDOWS_CERTIFICATE_BASE64 }} |
| 15 | + WINDOWS_CERTIFICATE_PASSWORD: ${{ secrets.WINDOWS_CERTIFICATE_PASSWORD }} |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v7 |
| 18 | + with: |
| 19 | + persist-credentials: false |
| 20 | + - uses: actions/setup-python@v6 |
| 21 | + with: |
| 22 | + python-version: "3.12" |
| 23 | + - name: Verify tag matches package version |
| 24 | + shell: pwsh |
| 25 | + run: | |
| 26 | + $expected = "v$(python -c 'import plexmuxy; print(plexmuxy.__version__)')" |
| 27 | + if ($env:GITHUB_REF_NAME -ne $expected) { throw "Tag $env:GITHUB_REF_NAME does not match $expected" } |
| 28 | + - run: python -m pip install -e ".[dev,build,gui]" cyclonedx-bom |
| 29 | + - name: Install Inno Setup |
| 30 | + run: choco install innosetup -y --no-progress |
| 31 | + - run: python -m pytest -m "not integration" --basetemp .pytest-tmp/release -o cache_dir=.pytest-tmp/cache |
| 32 | + - run: python -m build |
| 33 | + - name: Generate PyInstaller version-info resource |
| 34 | + shell: python |
| 35 | + run: | |
| 36 | + import re, pathlib |
| 37 | + version = pathlib.Path("plexmuxy/VERSION").read_text(encoding="utf-8").strip() |
| 38 | + m = re.match(r"^(\d+)\.(\d+)\.(\d+)", version) |
| 39 | + if not m: |
| 40 | + raise SystemExit(f"Cannot parse version '{version}' as MAJOR.MINOR.PATCH") |
| 41 | + filevers = f"{int(m[1])}, {int(m[2])}, {int(m[3])}, 0" |
| 42 | + info = f"""# UTF-8 |
| 43 | + # |
| 44 | + VSVersionInfo( |
| 45 | + ffi=FixedFileInfo( |
| 46 | + filevers=({filevers}), |
| 47 | + prodvers=({filevers}), |
| 48 | + mask=0x3f, |
| 49 | + flags=0x0, |
| 50 | + OS=0x40004, |
| 51 | + fileType=0x1, |
| 52 | + subtype=0x0, |
| 53 | + date=(0, 0) |
| 54 | + ), |
| 55 | + kids=[ |
| 56 | + StringFileInfo([ |
| 57 | + StringTable( |
| 58 | + u'040904B0', |
| 59 | + [StringStruct(u'CompanyName', u'PlexMuxy contributors'), |
| 60 | + StringStruct(u'FileDescription', u'PlexMuxy'), |
| 61 | + StringStruct(u'FileVersion', u'{version}'), |
| 62 | + StringStruct(u'InternalName', u'plexmuxy'), |
| 63 | + StringStruct(u'LegalCopyright', u'MIT License'), |
| 64 | + StringStruct(u'OriginalFilename', u'plexmuxy-gui.exe'), |
| 65 | + StringStruct(u'ProductName', u'PlexMuxy'), |
| 66 | + StringStruct(u'ProductVersion', u'{version}')]) |
| 67 | + ]), |
| 68 | + VarFileInfo([VarStruct(u'Translation', [1033, 1200])]) |
| 69 | + ] |
| 70 | + ) |
| 71 | + """ |
| 72 | + pathlib.Path("packaging").mkdir(exist_ok=True) |
| 73 | + pathlib.Path("packaging/version_info.txt").write_text(info, encoding="utf-8") |
| 74 | + - run: python -m PyInstaller --clean --noconfirm plexmuxy-cli.spec |
| 75 | + - run: python -m PyInstaller --clean --noconfirm plexmuxy-gui.spec |
| 76 | + - name: Sign portable executables when a certificate is configured |
| 77 | + if: env.WINDOWS_CERTIFICATE_BASE64 != '' |
| 78 | + shell: pwsh |
| 79 | + run: | |
| 80 | + $certificate = Join-Path $env:RUNNER_TEMP "plexmuxy-signing.pfx" |
| 81 | + [IO.File]::WriteAllBytes($certificate, [Convert]::FromBase64String($env:WINDOWS_CERTIFICATE_BASE64)) |
| 82 | + try { |
| 83 | + Get-ChildItem dist -Recurse -Filter *.exe | ForEach-Object { |
| 84 | + signtool sign /fd SHA256 /td SHA256 /tr http://timestamp.digicert.com /f $certificate /p $env:WINDOWS_CERTIFICATE_PASSWORD $_.FullName |
| 85 | + } |
| 86 | + } finally { |
| 87 | + Remove-Item -Force -ErrorAction SilentlyContinue $certificate |
| 88 | + } |
| 89 | + - name: Build Windows installer with fixed application identity |
| 90 | + shell: pwsh |
| 91 | + run: | |
| 92 | + $version = python -c "import plexmuxy; print(plexmuxy.__version__)" |
| 93 | + iscc "/DMyAppVersion=$version" packaging/plexmuxy.iss |
| 94 | + - name: Sign installer when a certificate is configured |
| 95 | + if: env.WINDOWS_CERTIFICATE_BASE64 != '' |
| 96 | + shell: pwsh |
| 97 | + run: | |
| 98 | + $certificate = Join-Path $env:RUNNER_TEMP "plexmuxy-signing.pfx" |
| 99 | + [IO.File]::WriteAllBytes($certificate, [Convert]::FromBase64String($env:WINDOWS_CERTIFICATE_BASE64)) |
| 100 | + try { |
| 101 | + Get-ChildItem dist -File -Filter *-setup.exe | ForEach-Object { |
| 102 | + signtool sign /fd SHA256 /td SHA256 /tr http://timestamp.digicert.com /f $certificate /p $env:WINDOWS_CERTIFICATE_PASSWORD $_.FullName |
| 103 | + } |
| 104 | + } finally { |
| 105 | + Remove-Item -Force -ErrorAction SilentlyContinue $certificate |
| 106 | + } |
| 107 | + - name: Generate release SBOM |
| 108 | + run: python -m cyclonedx_py environment --output-format JSON --output-file dist/plexmuxy-sbom.cdx.json |
| 109 | + - name: Package executables and checksums |
| 110 | + shell: pwsh |
| 111 | + run: | |
| 112 | + Compress-Archive -Path dist/plexmuxy/* -DestinationPath dist/plexmuxy-windows-x64.zip |
| 113 | + Compress-Archive -Path dist/plexmuxy-gui/* -DestinationPath dist/plexmuxy-gui-windows-x64.zip |
| 114 | + $artifacts = Get-ChildItem dist -File |
| 115 | + $manifest = [ordered]@{ |
| 116 | + version = (python -c "import plexmuxy; print(plexmuxy.__version__)") |
| 117 | + commit = $env:GITHUB_SHA |
| 118 | + python = (python --version) |
| 119 | + artifacts = @($artifacts | ForEach-Object { [ordered]@{ name = $_.Name; size = $_.Length; sha256 = (Get-FileHash -Algorithm SHA256 -LiteralPath $_.FullName).Hash.ToLower() } }) |
| 120 | + } |
| 121 | + $manifest | ConvertTo-Json -Depth 5 | Set-Content -Encoding utf8 dist/release-manifest.json |
| 122 | + Get-ChildItem dist -File | Where-Object Name -ne 'SHA256SUMS.txt' | ForEach-Object { |
| 123 | + $hash = (Get-FileHash -Algorithm SHA256 -LiteralPath $_.FullName).Hash.ToLower() |
| 124 | + "$hash $($_.Name)" | Add-Content -Encoding ascii dist/SHA256SUMS.txt |
| 125 | + } |
| 126 | + - name: Create GitHub release |
| 127 | + shell: pwsh |
| 128 | + env: |
| 129 | + GH_TOKEN: ${{ github.token }} |
| 130 | + run: gh release create $env:GITHUB_REF_NAME (Get-ChildItem dist -File | ForEach-Object FullName) --verify-tag --generate-notes --title "PlexMuxy $env:GITHUB_REF_NAME" |
| 131 | + |
| 132 | + publish-pypi: |
| 133 | + name: Publish source and wheel with PyPI Trusted Publishing |
| 134 | + needs: release |
| 135 | + runs-on: ubuntu-latest |
| 136 | + environment: |
| 137 | + name: pypi |
| 138 | + url: https://pypi.org/p/plexmuxy |
| 139 | + permissions: |
| 140 | + id-token: write |
| 141 | + steps: |
| 142 | + - uses: actions/checkout@v7 |
| 143 | + with: |
| 144 | + persist-credentials: false |
| 145 | + - uses: actions/setup-python@v6 |
| 146 | + with: |
| 147 | + python-version: "3.12" |
| 148 | + - run: python -m pip install build |
| 149 | + - run: python -m build |
| 150 | + - uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b |
| 151 | + |
0 commit comments