Skip to content

Commit

Permalink
Debug GH actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jordantgh committed Oct 14, 2023
1 parent 250ea03 commit c788c0c
Showing 1 changed file with 40 additions and 143 deletions.
183 changes: 40 additions & 143 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,154 +1,51 @@
name: Build PyQt5 App
name: Debug GitHub Actions

on:
push:
branches: [ main ]
branches:
- main

env:
POETRY_VERSION: 1.4.1
PACKAGE_NAME: metaanalyser
PACKAGE_VERSION: 0.1.0

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.11.1]

steps:
- name: Checkout code
uses: actions/checkout@v3

# Setup Python environment
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

# Install system libraries for Linux
- name: Install Linux system libraries
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y xvfb x11-utils libxkbcommon-x11-0

# Install Poetry
- name: Install Poetry on Linux
if: runner.os == 'Linux'
run: |
curl -sSL https://install.python-poetry.org | python3 - --version ${{ env.POETRY_VERSION }}
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install Poetry on macOS
if: runner.os == 'macOS'
run: |
curl -sSL https://install.python-poetry.org | python3 - --version ${{ env.POETRY_VERSION }}
echo "$HOME/Library/Application Support/pypoetry/venv/bin" >> $GITHUB_PATH
- name: Install Poetry on Windows
if: runner.os == 'Windows'
run: |
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python3 - --version ${{ env.POETRY_VERSION }}
echo "$env:APPDATA\Python\Scripts" | Out-File -FilePath $env:GITHUB_PATH -Append
# Install dependencies
- name: Install dependencies
run: |
poetry install
# Install Chrome for Playwright (Mac/Linux)
- name: Install Chrome for Playwright (Mac/Linux)
if: runner.os != 'Windows'
run: |
export PLAYWRIGHT_BROWSERS_PATH=0
poetry run playwright install chromium
- name: Install Chrome for Playwright (Windows)
if: runner.os == 'Windows'
run: |
$env:PLAYWRIGHT_BROWSERS_PATH="0"
poetry run playwright install chromium
# Build PyQt5 app binary with PyInstaller
- name: Build with PyInstaller
run: |
poetry run pyinstaller --onefile --name ${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }} app/main.py
# Package the binary
- name: Package Binary on Mac/Linux
if: runner.os != 'Windows'
run: tar czvf ${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}_${{ runner.os }}.tar.gz -C dist ${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}

- name: Package Binary on Windows
if: runner.os == 'Windows'
run: Compress-Archive -Path .\dist\${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}.exe -DestinationPath .\${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}_windows.zip

# Upload the packaged binary as an artifact for Mac/Linux
- name: Upload Mac/Linux Binary as Artifact
if: runner.os != 'Windows'
uses: actions/upload-artifact@v2
with:
name: ${{ runner.os }}-binary
path: '*.tar.gz'

# Upload the packaged binary as an artifact for Windows
- name: Upload Windows Binary as Artifact
if: runner.os == 'Windows'
uses: actions/upload-artifact@v2
with:
name: windows-binary
path: '*.zip'

release:
needs: build
debug:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Download all compiled artifacts
uses: actions/download-artifact@v2
with:
path: ./artifacts

- name: Create Public Release
run: |
RESPONSE=$(curl -s -X POST \
-H "Authorization: token ${{ secrets.GH_TOKEN }}" \
-d '{
"tag_name": "v${{ env.PACKAGE_VERSION }}",
"target_commitish": "main",
"name": "Release v${{ env.PACKAGE_VERSION }}",
"body": "First public release.",
"draft": true,
"prerelease": true
}' \
https://api.github.com/repos/jordantgh/meta-analyser-rc/releases)
echo "Full API Response: $RESPONSE"
UPLOAD_URL=$(echo "$RESPONSE" | jq -r '.upload_url')
echo "UPLOAD_URL=${UPLOAD_URL}" >> $GITHUB_ENV
# Upload assets to the public repo
- name: Upload Public Release Asset for Linux
run: |
UPLOAD_URL=$(echo $RESPONSE | jq -r '.upload_url')
curl -s -X POST "${UPLOAD_URL/{?name,label}/?name=${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}_Linux.tar.gz}" \
-H "Authorization: token ${{ secrets.GH_TOKEN }}" \
-H "Content-Type: application/gzip" \
--data-binary @./artifacts/Linux-binary/${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}_Linux.tar.gz
- name: Upload Public Release Asset for Mac
run: |
UPLOAD_URL=$(echo $RESPONSE | jq -r '.upload_url')
curl -s -X POST "${UPLOAD_URL/{?name,label}/?name=${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}_macOS.tar.gz" \
-H "Authorization: token ${{ secrets.GH_TOKEN }}" \
-H "Content-Type: application/gzip" \
--data-binary @./artifacts/macOS-binary/${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}_macOS.tar.gz
- name: Upload Public Release Asset for Windows
run: |
UPLOAD_URL=$(echo $RESPONSE | jq -r '.upload_url')
curl -s -X POST "${UPLOAD_URL/{?name,label}/?name=${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}_windows.zip" \
-H "Authorization: token ${{ secrets.GH_TOKEN }}" \
-H "Content-Type: application/zip" \
--data-binary @./artifacts/windows-binary/${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}_windows.zip
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Create Dummy File
run: echo "This is a dummy file" > dummy_file.txt

- name: Create Public Release
run: |
RESPONSE=$(curl -s -X POST \
-H "Authorization: token ${{ secrets.GH_TOKEN }}" \
-d '{
"tag_name": "v${{ env.PACKAGE_VERSION }}",
"target_commitish": "main",
"name": "Release v${{ env.PACKAGE_VERSION }}",
"body": "Debugging release.",
"draft": true,
"prerelease": true
}' \
https://api.github.com/repos/${{ github.repository }}/releases)
echo "Full API Response: $RESPONSE"
UPLOAD_URL=$(echo "$RESPONSE" | jq -r '.upload_url')
echo "UPLOAD_URL=${UPLOAD_URL}" >> $GITHUB_ENV
- name: Debug UPLOAD_URL
run: |
echo "Original UPLOAD_URL: $UPLOAD_URL"
UPLOAD_URL="${UPLOAD_URL/\{?name,label\}/?name=${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}_Linux.tar.gz}"
echo "Modified UPLOAD_URL: $UPLOAD_URL"
- name: Upload Dummy File to Release
run: |
curl -s -X POST "$UPLOAD_URL" \
-H "Authorization: token ${{ secrets.GH_TOKEN }}" \
-H "Content-Type: text/plain" \
--data-binary @dummy_file.txt

0 comments on commit c788c0c

Please sign in to comment.