Loop debugging #954
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create a Release | |
on: | |
push: | |
branches: | |
- master | |
defaults: | |
run: | |
shell: bash | |
env: | |
project-name: qBitrr | |
GREN_GITHUB_TOKEN: ${{ secrets.PAT }} | |
jobs: | |
bump_version: | |
name: Bump release version | |
runs-on: ubuntu-latest | |
if: ${{ startsWith(github.event.head_commit.message, '[patch]') || startsWith(github.event.head_commit.message, '[minor]')|| startsWith(github.event.head_commit.message, '[major]') }} | |
env: | |
RELEASE_TYPE: ${{ startsWith(github.event.head_commit.message, '[patch]') && 'patch' || startsWith(github.event.head_commit.message, '[minor]') && 'minor' || startsWith(github.event.head_commit.message, '[major]') && 'major' }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.PAT }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install bump2version setuptools wheel twine | |
- name: Retrieve current version | |
run: | | |
echo "Current version: $(python setup.py --version)" | |
echo "VERSION=$(python setup.py --version)" >> $GITHUB_OUTPUT | |
id: current_version | |
- name: Bump Patch Version | |
run: | | |
bump2version --current-version $(python setup.py --version) ${{ env.RELEASE_TYPE }} | |
- name: Retrieve new version | |
run: | | |
echo "VERSION=$(python setup.py --version)" >> $GITHUB_OUTPUT | |
id: new_version | |
- name: Import GPG key | |
uses: crazy-max/[email protected] | |
with: | |
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.PASSPHRASE }} | |
git_user_signingkey: true | |
git_commit_gpgsign: true | |
git_tag_gpgsign: true | |
id: import_gpg | |
- name: Git Auto Commit | |
uses: stefanzweifel/[email protected] | |
with: | |
commit_message: '[skip ci]Automated version bump: v${{ github.job.get_current_version.current_version.outputs.VERSION }} >> v${{ steps.new_version.outputs.VERSION }}' | |
tagging_message: v${{ steps.new_version.outputs.VERSION }} | |
commit_options: -S | |
commit_user_name: ${{ steps.import_gpg.outputs.name }} | |
commit_user_email: ${{ steps.import_gpg.outputs.email }} | |
commit_author: ${{ steps.import_gpg.outputs.name }} <${{ steps.import_gpg.outputs.email }}> | |
outputs: | |
RELEASE_TYPE: ${{ env.RELEASE_TYPE }} | |
NEW_RELEASE: ${{ steps.new_version.outputs.VERSION }} | |
release: | |
name: Create a GitHub Release | |
needs: [bump_version] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: master | |
token: ${{ secrets.PAT }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install setuptools wheel twine | |
- name: Import GPG key | |
uses: crazy-max/[email protected] | |
with: | |
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.PASSPHRASE }} | |
git_user_signingkey: true | |
git_commit_gpgsign: true | |
git_tag_gpgsign: true | |
id: import_gpg | |
- uses: ModeSevenIndustrialSolutions/action-automatic-releases@latest | |
with: | |
repo_token: ${{ secrets.PAT }} | |
prerelease: false | |
automatic_release_tag: v${{needs.bump_version.outputs.NEW_RELEASE}} | |
title: v${{needs.bump_version.outputs.NEW_RELEASE}} | |
release_hash: | |
name: Update The Version Hash | |
needs: [bump_version, release] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.PAT }} | |
fetch-depth: 0 | |
ref: master | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install setuptools wheel twine | |
- name: Get git hash | |
run: | | |
echo "Current Hash: $(git rev-parse --short HEAD)" | |
echo "HASH=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
id: git_hash | |
- name: Update git hash | |
run: | | |
sed -i -e 's/git_hash = \".*\"/git_hash = \"${{ steps.git_hash.outputs.HASH }}\"/g' ./qBitrr/bundled_data.py | |
- name: Import GPG key | |
uses: crazy-max/[email protected] | |
with: | |
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.PASSPHRASE }} | |
git_user_signingkey: true | |
git_commit_gpgsign: true | |
git_tag_gpgsign: true | |
id: import_gpg | |
- name: Git Auto Commit | |
uses: stefanzweifel/[email protected] | |
with: | |
commit_message: '[skip ci] Update Release Hash for v${{needs.bump_version.outputs.NEW_RELEASE}}' | |
commit_options: -S | |
commit_user_name: ${{ steps.import_gpg.outputs.name }} | |
commit_user_email: ${{ steps.import_gpg.outputs.email }} | |
commit_author: ${{ steps.import_gpg.outputs.name }} <${{ steps.import_gpg.outputs.email }}> | |
outputs: | |
RELEASE_HASH: ${{ steps.git_hash.outputs.HASH }} | |
publish: | |
name: Publish to PyPi | |
needs: [bump_version, release, release_hash, docker_image] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: master | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build wheel | |
- name: Build package | |
run: python -m build | |
- name: Publish package | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
package: | |
name: Build Binaries | |
needs: [bump_version, release, release_hash, docker_image] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
python: | |
- 3.10.11 | |
os: | |
- windows-latest | |
- macOS-latest | |
- ubuntu-latest | |
arch: | |
- x86 | |
- x64 | |
- arm64 | |
exclude: | |
- os: ubuntu-latest | |
arch: x86 | |
- os: ubuntu-latest | |
arch: arm64 | |
- os: macOS-latest | |
arch: x64 | |
- os: macOS-latest | |
arch: x86 | |
- os: windows-latest | |
arch: arm64 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: master | |
fetch-depth: 0 | |
- name: Install Homebrew dependencies | |
if: runner.os == 'MacOS' | |
run: | | |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
- name: Set up Python ${{ matrix.python }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python}} | |
architecture: ${{ matrix.arch }} | |
- name: Install APT dependencies | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update | |
sudo apt-get install libsdl2-dev | |
- name: Set archive name | |
run: | | |
ARCHIVE_NAME=${{ env.project-name }}-${{ needs.release_hash.outputs.RELEASE_HASH }}-${{ matrix.os }}-${{ matrix.arch }} | |
echo "Archive name set to: $ARCHIVE_NAME" | |
echo "NAME=$ARCHIVE_NAME" >> $GITHUB_OUTPUT | |
id: archieve | |
- name: Install Python dependencies | |
run: | | |
python -m pip install -U pip | |
python -m pip install -U setuptools==69.5.1 | |
python -m pip install -U wheel | |
python -m pip install -r requirements.dev.txt | |
- name: Run PyInstaller | |
env: | |
PYTHONOPTIMIZE: 1 # Enable optimizations as if the -O flag is given. | |
PYTHONHASHSEED: 42 # Try to ensure deterministic results. | |
PYTHONUNBUFFERED: 1 | |
run: | | |
pyinstaller build.spec | |
# This step exists for debugging. Such as checking if data files were included correctly by PyInstaller. | |
- name: List distribution files | |
run: | | |
find dist | |
# Archive the PyInstaller build using the appropriate tool for the platform. | |
- name: Tar files | |
if: runner.os != 'Windows' | |
run: | | |
tar --format=ustar -czvf ${{ steps.archieve.outputs.NAME }}.tar.gz dist/ | |
- name: Archive files | |
if: runner.os == 'Windows' | |
shell: pwsh | |
run: | | |
Compress-Archive dist/* ${{ steps.archieve.outputs.NAME }}.zip | |
# Upload archives as artifacts, these can be downloaded from the GitHub actions page. | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: automated-build-${{ steps.archieve.outputs.NAME }} | |
path: ${{ steps.archieve.outputs.NAME }}.* | |
retention-days: 7 | |
if-no-files-found: error | |
- name: Upload release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.PAT }} | |
file: ${{ steps.archieve.outputs.NAME }}.* | |
file_glob: true | |
tag: v${{needs.bump_version.outputs.NEW_RELEASE}} | |
overwrite: true | |
docker_image_arm: | |
name: Build ARM Docker Image | |
needs: [bump_version, release, release_hash] | |
runs-on: ubuntu-latest | |
steps: | |
- id: string | |
uses: ASzc/change-string-case-action@v6 | |
with: | |
string: ${{ github.repository }} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: master | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.REG_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
feramance/qbitrr | |
ghcr.io/${{ steps.string.outputs.lowercase }} | |
tags: | | |
type=edge | |
- name: Build and push | |
env: | |
DOCKER_BUILDKIT: 1 | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
platforms: linux/arm64 | |
push: true | |
tags: feramance/qbitrr:nightly-arm,feramance/qbitrr:latest-arm,feramance/qbitrr:v${{needs.bump_version.outputs.NEW_RELEASE}}-arm,ghcr.io/${{ steps.string.outputs.lowercase }}:nightly-arm,ghcr.io/${{ steps.string.outputs.lowercase }}:latest-arm,ghcr.io/${{ steps.string.outputs.lowercase }}:v${{needs.bump_version.outputs.NEW_RELEASE}}-arm | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
docker_image: | |
name: Build Docker Image | |
needs: [bump_version, release, release_hash] | |
runs-on: ubuntu-latest | |
steps: | |
- id: string | |
uses: ASzc/change-string-case-action@v6 | |
with: | |
string: ${{ github.repository }} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: master | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.REG_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
feramance/qbitrr | |
ghcr.io/${{ steps.string.outputs.lowercase }} | |
tags: | | |
type=edge | |
- name: Build and push | |
env: | |
DOCKER_BUILDKIT: 1 | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
platforms: linux/amd64 | |
push: true | |
tags: feramance/qbitrr:nightly,feramance/qbitrr:latest,feramance/qbitrr:v${{needs.bump_version.outputs.NEW_RELEASE}},ghcr.io/${{ steps.string.outputs.lowercase }}:nightly,ghcr.io/${{ steps.string.outputs.lowercase }}:latest,ghcr.io/${{ steps.string.outputs.lowercase }}:v${{needs.bump_version.outputs.NEW_RELEASE}} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
change_logs: | |
name: Generate Change Logs and Release Notes | |
needs: [bump_version, release, release_hash, docker_image, publish] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: master | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: latest | |
- run: npm install github-release-notes -g | |
- name: Release Notes and Change logs | |
run: | | |
gren release | |
gren changelog | |
- name: Import GPG key | |
uses: crazy-max/[email protected] | |
with: | |
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.PASSPHRASE }} | |
git_user_signingkey: true | |
git_commit_gpgsign: true | |
git_tag_gpgsign: true | |
id: import_gpg | |
- name: Git Auto Commit | |
uses: stefanzweifel/[email protected] | |
with: | |
commit_message: '[skip ci] Update CHANGELOG.md and Release Notes for v${{needs.bump_version.outputs.NEW_RELEASE}}' | |
commit_options: -S | |
commit_user_name: ${{ steps.import_gpg.outputs.name }} | |
commit_user_email: ${{ steps.import_gpg.outputs.email }} | |
commit_author: ${{ steps.import_gpg.outputs.name }} <${{ steps.import_gpg.outputs.email }}> |