Update Flask and pyinstaller, replace Flask's jsonify #7
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: 'Test and Release Yukon' | |
on: push | |
# Ensures that only one workflow is running at a time | |
concurrency: | |
group: ${{ github.workflow_sha }} | |
cancel-in-progress: true | |
jobs: | |
yukon-test: | |
name: Test Yukon | |
strategy: | |
matrix: | |
os: [ ubuntu-22.04, ubuntu-20.04, windows-2019-npcap ] | |
runs-on: ${{ matrix.os }} | |
env: | |
python_version: 3.11 | |
steps: | |
- name: Check out | |
uses: actions/checkout@v3 | |
- name: Install Python3 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.python_version }} | |
cache: "pip" | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
- name: Set architecture variables | |
run: | | |
if [ "$RUNNER_OS" == "Linux" ]; then | |
echo "yukon_activate=source venv/bin/activate" >> $GITHUB_ENV | |
elif [ "$RUNNER_OS" == "Windows" ]; then | |
echo "yukon_activate=venv/Scripts/activate.bat" >> $GITHUB_ENV | |
else | |
echo "${{ runner.os }} not supported" | |
exit 1 | |
fi | |
shell: bash | |
- name: Install dependencies | |
run: | | |
if [ "$RUNNER_OS" == "Linux" ]; then | |
sudo update-alternatives --install /usr/bin/python python /opt/hostedtoolcache/Python/${{ env.python_version }}.*/x64/bin/python${{ env.python_version }} 1 | |
sudo update-alternatives --install /usr/bin/python3 python3 /opt/hostedtoolcache/Python/${{ env.python_version }}.*/x64/bin/python${{ env.python_version }} 1 | |
fi | |
python3 -m venv venv | |
${{ env.yukon_activate }} | |
pip install wheel yakut | |
yakut compile -O.compiled ${{ env.master_path }} | |
pip install nox | |
pip install -r requirements.txt -r dev-requirements.txt | |
env: | |
master_path: https://github.com/OpenCyphal/public_regulated_data_types/archive/refs/heads/master.zip | |
shell: bash | |
- name: Test GUI (quality check) | |
run: | | |
${{ env.yukon_activate }} | |
nox -s mypy | |
nox -s black | |
nox -s pylint | |
nox -s pytest | |
yukon-build: | |
name: Build release | |
needs: yukon-test | |
if: contains(github.event.head_commit.message, '#release') || contains(github.ref, '/main') | |
strategy: | |
matrix: | |
os: [ubuntu-22.04, ubuntu-20.04, windows-2019-npcap] | |
runs-on: ${{ matrix.os }} | |
env: | |
python_version: 3.11 | |
outputs: | |
yukon_version: ${{ steps.release-version.outputs.yukon_version }} | |
steps: | |
- name: Check out | |
uses: actions/checkout@v3 | |
- name: Install Python3 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.python_version }} | |
cache: "pip" | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
- name: Set architecture variables | |
run: | | |
if [ "$RUNNER_OS" == "Linux" ]; then | |
echo "yukon_activate=source venv/bin/activate" >> $GITHUB_ENV | |
elif [ "$RUNNER_OS" == "Windows" ]; then | |
echo "yukon_activate=venv/Scripts/activate.bat" >> $GITHUB_ENV | |
else | |
echo "${{ runner.os }} not supported" | |
exit 1 | |
fi | |
shell: bash | |
- name: Install dependencies | |
run: | | |
if [ "$RUNNER_OS" == "Linux" ]; then | |
sudo update-alternatives --install /usr/bin/python python /opt/hostedtoolcache/Python/${{ env.python_version }}.*/x64/bin/python${{ env.python_version }} 1 | |
sudo update-alternatives --install /usr/bin/python3 python3 /opt/hostedtoolcache/Python/${{ env.python_version }}.*/x64/bin/python${{ env.python_version }} 1 | |
fi | |
python3 -m venv venv | |
${{ env.yukon_activate }} | |
pip install wheel yakut | |
yakut compile -O.compiled ${{ env.master_path }} | |
pip install nox | |
pip install -r requirements.txt -r dev-requirements.txt | |
env: | |
master_path: https://github.com/OpenCyphal/public_regulated_data_types/archive/refs/heads/master.zip | |
shell: bash | |
- name: Build release | |
run: | | |
${{ env.yukon_activate }} | |
python3 build_exe.py | |
- id: release-version | |
name: Extracting release version | |
run: echo "yukon_version=$(python3 -c 'from yukon.version import __version__; print(__version__)')" >> $GITHUB_OUTPUT | |
- name: Set artifact name | |
run: | | |
if [ "${{ matrix.os }}" == "ubuntu-22.04" ]; then | |
echo "architecture=linux-x86_64_ubuntu-22.04-manjaro" >> $GITHUB_ENV | |
elif [ "${{ matrix.os }}" == "ubuntu-20.04" ]; then | |
echo "architecture=linux-x86_64" >> $GITHUB_ENV | |
elif [ "${{ matrix.os }}" == "windows-2019-npcap" ]; then | |
echo "architecture=windows-x86_64" >> $GITHUB_ENV | |
else | |
echo "architecture=other" >> $GITHUB_ENV | |
fi | |
shell: bash | |
- name: Store artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.architecture }} | |
path: | | |
dist/Yukon | |
dist/Yukon.exe | |
retention-days: 1 | |
# | |
# Deploy artifacts to files.zubax.com fileserver | |
# | |
deploy-to-zubax: | |
name: Deploy to Zubax fileserver | |
needs: yukon-build | |
runs-on: ubuntu-latest | |
env: | |
yukon_product: org.opencyphal.yukon | |
yukon_version: ${{ needs.yukon-build.outputs.yukon_version }} | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
- name: Configure SSH | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "$SSH_KEY" > ~/.ssh/private.key | |
chmod 600 ~/.ssh/private.key | |
cat >>~/.ssh/config <<END | |
Host target | |
HostName $SSH_HOST | |
User $SSH_USER | |
IdentityFile ~/.ssh/private.key | |
StrictHostKeyChecking no | |
END | |
env: | |
SSH_HOST: ${{ secrets.SSH_HOST }} | |
SSH_USER: ${{ secrets.SSH_USERNAME }} | |
SSH_KEY: ${{ secrets.SSH_KEY }} | |
- name: Deploy the release to Zubax files | |
run: | | |
ssh target "if [ -d $TARGET_DIR ] | |
then | |
echo '$TARGET_DIR' | |
echo 'Release ${{ env.yukon_version }} already exists' | |
exit 1 | |
else | |
mkdir -p $TARGET_DIR | |
echo 'Creating new release directory at $TARGET_DIR' | |
fi" | |
scp -rp ./* target:$TARGET_DIR/ | |
env: | |
TARGET_DIR: /var/www/files/products/${{ env.yukon_product }}/releases/${{ env.yukon_version }} | |
# | |
# Deploy artifacts to GitHub Releases | |
# | |
deploy-to-gh-releases: | |
name: Deploy to GH Releases | |
needs: yukon-build | |
if: (github.event_name == 'push') && (github.ref == 'refs/heads/main') | |
runs-on: ubuntu-latest | |
env: | |
yukon_version: ${{ needs.yukon-build.outputs.yukon_version }} | |
steps: | |
- name: Make artifact directories | |
run: mkdir download artifacts | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: download | |
- name: Push version tag | |
id: tag_version | |
uses: mathieudutour/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
custom_tag: ${{ env.yukon_version }} | |
tag_prefix: '' | |
dry_run: true | |
- name: Gather artifacts | |
run: | | |
cd download | |
for artifact in $(find * -type f -print) | |
do | |
arch=$(echo $artifact | cut -d/ -f1) | |
base=$(echo $artifact | cut -d/ -f2 | cut -d. -f1) | |
ext=$(echo $artifact | cut -d/ -f2 | awk -F. '{print $2}') | |
if [[ $ext != '' ]]; then | |
cp -p $artifact ../artifacts/$base-$arch.$ext | |
else | |
cp -p $artifact ../artifacts/$base-$arch | |
fi | |
done | |
- name: Create a release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: artifacts/* | |
artifactErrorsFailBuild: true | |
tag: ${{ env.yukon_version }} | |
skipIfReleaseExists: true |