Skip to content

Patch20250318: testing #326

Patch20250318: testing

Patch20250318: testing #326

name: Build and Publish
on:
workflow_run:
workflows: [ "Run Tests" ]
branches:
- develop
- testing
types:
- completed
push:
branches:
- main
pull_request:
branches:
- develop
- testing
types:
- closed
jobs:
pre-build-setup:
runs-on: ubuntu-20.04
if: github.event.pull_request.merged == true # Runs only if PR is merged
outputs:
branch: ${{steps.extract_branch.outputs.branch}}
steps:
- name: Extract Branch Name
id: extract_branch
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
- name: Extract PR Summary and Versions
id: extract_content
run: |
PR_BODY="${{ github.event.pull_request.body }}"
# Extract Summary
echo "$PR_BODY" | awk '/## Summary/{flag=1; next} /^## /{flag=0} flag' > PR_SUMMARY.md
echo "" >> PR_SUMMARY.md
# Extract Versions
echo "$PR_BODY" | awk '/## Versions/{flag=1; next} /^## /{flag=0} flag' > PR_VERSIONS.md
echo "" >> PR_VERSIONS.md
# Read extracted content
PILOT_VERSION=$(grep -oP '(?<=- Pilot Release Version: ).*' PR_VERSIONS.md | tr -d '\r')
COMPATIBLE_VERSION=$(grep -oP '(?<=- Compatible Version: ).*' PR_VERSIONS.md | tr -d '\r')
# Handle missing values
PILOT_VERSION=${PILOT_VERSION:-"Unknown"}
COMPATIBLE_VERSION=${COMPATIBLE_VERSION:-"Unknown"}
# Create a structured release message
echo "## Release Notes" > RELEASE_MESSAGE.md
echo "" >> RELEASE_MESSAGE.md
echo "### Summary" >> RELEASE_MESSAGE.md
cat PR_SUMMARY.md >> RELEASE_MESSAGE.md
echo "" >> RELEASE_MESSAGE.md
echo "### Versions" >> RELEASE_MESSAGE.md
echo "- **Pilot Release Version:** $PILOT_VERSION" >> RELEASE_MESSAGE.md
echo "- **Compatible Version:** $COMPATIBLE_VERSION" >> RELEASE_MESSAGE.md
- name: Upload Release Message as Artifact
uses: actions/upload-artifact@v4
with:
name: release-message
path: RELEASE_MESSAGE.md
push-binary-linux:
needs: [ pre-build-setup ]
if: ${{ needs.pre-build-setup.outputs.branch == 'testing' || needs.pre-build-setup.outputs.branch == 'develop'}}
runs-on: ubuntu-20.04
outputs:
upload_url: ${{steps.create_release.outputs.upload_url}}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ needs.pre-build-setup.outputs.branch }}
- name: Download Release Message Artifact
uses: actions/download-artifact@v4
with:
name: release-message
- name: Download Release Message Artifact
uses: actions/download-artifact@v4
with:
name: release-message
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.10.12
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.8.3
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Set up cache
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-linux-${{ hashFiles('**/poetry.lock') }}
- name: Ensure cache is healthy
if: steps.cached-poetry-dependencies.outputs.cache-hit == 'true'
run: timeout 10s poetry run pip --version || rm -rf .venv
- name: Install dependencies
run: poetry install --no-interaction
- name: Build default binary
run: poetry run pyinstaller -F --distpath ./app/bundled_app/linux --specpath ./app/build/linux --workpath ./app/build/linux --paths=./.venv/lib/python3.10/site-packages ./app/pilotcli.py -n ${{ github.sha }}
- name: Rename default output file
run: mv "./app/bundled_app/linux/${{ github.sha }}" "./app/bundled_app/linux/pilotcli_linux"
- name: Enable cloud mode
run: touch ./app/ENABLE_CLOUD_MODE
- name: Build cloud binary
run: poetry run pyinstaller -F --distpath ./app/bundled_app/linux --specpath ./app/build/linux --workpath ./app/build/linux --paths=./.venv/lib/python3.9/site-packages --add-binary=$(pwd)/app/ENABLE_CLOUD_MODE:. ./app/pilotcli.py -n ${{ github.sha }}
- name: Rename cloud output file
run: mv "./app/bundled_app/linux/${{ github.sha }}" "./app/bundled_app/linux/pilotcli_cloud"
- name: Set version in env
run: poetry run echo "TAG_VERSION=`poetry version --short`" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ env.TAG_VERSION }}
name: Release ${{ needs.pre-build-setup.outputs.branch }} ${{ env.TAG_VERSION }}
body_path: RELEASE_MESSAGE.md
draft: false
prerelease: false
target_commitish: ${{ needs.pre-build-setup.outputs.branch }}
files: |
./app/bundled_app/linux/pilotcli_linux
./app/bundled_app/linux/pilotcli_cloud
push-binary-macos:
needs: [ push-binary-linux ]
if: ${{ needs.pre-build-setup.outputs.branch == 'main' || needs.pre-build-setup.outputs.branch == 'develop'}}
runs-on: macos-13
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ needs.pre-build-setup.outputs.branch }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.10.12
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.8.3
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Set up cache
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-linux-${{ hashFiles('**/poetry.lock') }}
- name: Ensure cache is healthy
if: steps.cached-poetry-dependencies.outputs.cache-hit == 'true'
run: timeout 10s poetry run pip --version || rm -rf .venv
- name: Install dependencies
run: poetry install --no-interaction
- name: Build binary
run: poetry run pyinstaller -F --distpath ./app/bundled_app/macos --specpath ./app/build/macos --workpath ./app/build/macos --paths=./.venv/lib/python3.10/site-packages ./app/pilotcli.py -n ${{ github.sha }}
- name: Upload Release Binary
id: upload-release-binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.push-binary-linux.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./app/bundled_app/macos/${{ github.sha }}
asset_name: pilotcli_macos
asset_content_type: application/octet-stream
push-binary-windows:
needs: [ push-binary-linux ]
if: ${{ needs.pre-build-setup.outputs.branch == 'main' || needs.pre-build-setup.outputs.branch == 'develop'}}
runs-on: windows-2022
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ needs.pre-build-setup.outputs.branch }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Create virtual environment
run: |
python -m venv .venv
- name: Set up cache
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-windows-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: |
.\.venv\Scripts\Activate
pip install poetry==1.8.3
poetry shell
poetry install --no-interaction --extras "windows" --only main
shell: pwsh
- name: Build binary
run: |
.\.venv\Scripts\Activate
poetry run pyinstaller -F --distpath ./app/bundled_app/windows --specpath ./app/build/windows --workpath ./app/build/windows --paths=./.venv/lib/python3.10/site-packages ./app/pilotcli.py -n ${{ github.sha }}
shell: pwsh
- name: Upload Release Binary
id: upload-release-binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.push-binary-linux.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./app/bundled_app/windows/${{ github.sha }}.exe
asset_name: pilotcli_windows.exe
asset_content_type: application/octet-stream