Builder #47
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: Builder | |
on: | |
workflow_dispatch: | |
inputs: | |
TEST_VARIABLES: | |
description: "(Debug) Test variable moved accross jobs and steps" | |
type: boolean | |
required: true | |
default: false | |
# ONE_FILE: | |
# description: "ONE FILE (Nuitka)" | |
# type: boolean | |
# required: true | |
# default: false | |
NO_WINDOWS: | |
description: "No Windows" | |
type: boolean | |
required: true | |
default: false | |
DO_NOT_CREATE_RELEASE: | |
description: "Do not create release" | |
type: boolean | |
required: true | |
default: false | |
DO_NOT_MOVE_ARTIFACTS: | |
description: "Do not upload/download the artifacts" | |
type: boolean | |
required: true | |
default: false | |
DO_NOT_COMPILE_CREATE_DUMMY: | |
description: "Do not compile, create a dummy" | |
type: boolean | |
required: true | |
default: false | |
env: | |
MAIN_PY: "main.py" | |
REQFILE: "requirements.txt" | |
THE_NAME: "shled" | |
jobs: | |
job-build: | |
name: Build and upload executable binary | |
strategy: | |
matrix: | |
os: [ ubuntu-20.04 , windows-2019 ] | |
runs-on: ${{ matrix.os }} | |
steps: | |
# - name: Check if on Windows | |
# if: ${{ contains(matrix.os,'windows') == true && inputs.NO_WINDOWS == true }} | |
# run: exit 1 | |
- name: Download repo | |
uses: actions/checkout@v4 | |
with: | |
path: repo | |
- name: Setup Python | |
if: $${{ inputs.DO_NOT_COMPILE_CREATE_DUMMY == false }} | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.9.6" | |
- name: Setup Python (project dependencies) | |
if: $${{ inputs.DO_NOT_COMPILE_CREATE_DUMMY == false }} | |
working-directory: repo | |
run: | | |
pip install -r "${{ env.REQFILE }}" | |
- name: Setup Python (install Nuitka for Linux) | |
if: $${{ contains(matrix.os,'windows') == false && inputs.DO_NOT_COMPILE_CREATE_DUMMY == false }} | |
run: | | |
python -m pip install nuitka | |
- name: Setup Python (install Nuitka for Windows) | |
# https://github.com/Nuitka/Nuitka/issues/3015 | |
# Latest version does not work, and factory version either, trying out on 2.3.11 | |
if: $${{ contains(matrix.os,'windows') == true && inputs.DO_NOT_COMPILE_CREATE_DUMMY == false }} | |
run: | | |
python -m pip install nuitka==2.3.11 | |
- name: Build dummy | |
if: $${{ inputs.DO_NOT_COMPILE_CREATE_DUMMY == true }} | |
working-directory: repo | |
run: | | |
mkdir -p the-output/main.dist/ | |
echo "test" > the-output/main.dist/test.dummy | |
- name: Build for Linux | |
if: ${{ contains(matrix.os,'windows') == false && inputs.DO_NOT_COMPILE_CREATE_DUMMY == false }} | |
working-directory: repo | |
run: | | |
python -m nuitka --onefile --follow-imports --assume-yes-for-downloads --remove-output --output-dir="the-output" --output-filename="${{ env.THE_NAME }}.bin" "main.py" | |
# run: | | |
# python -m nuitka --standalone --assume-yes-for-downloads "main.py" --output-dir="the-output" --output-filename="${{ env.THE_NAME }}.bin" | |
- name: Build for Linux (after) | |
if: ${{ contains(matrix.os,'windows') == false && inputs.DO_NOT_CREATE_RELEASE == true && inputs.DO_NOT_COMPILE_CREATE_DUMMY == false }} | |
working-directory: repo | |
run: | | |
echo "[ LINKING ]" | |
ldd "the-output/main.dist/${{ env.THE_NAME }}.bin" | |
echo "[ CONTENTS ]" | |
find the-output | |
- name: Build for Windows | |
if: ${{ contains(matrix.os,'windows') == true && inputs.DO_NOT_COMPILE_CREATE_DUMMY == false }} | |
working-directory: repo | |
run: | | |
python -m nuitka --onefile --follow-imports --assume-yes-for-downloads --remove-output --output-dir="the-output" --output-filename="${{ env.THE_NAME }}.exe" "main.py" | |
# run: | | |
# python -m nuitka --standalone --assume-yes-for-downloads "main.py" --output-dir="the-output" --output-filename="${{ env.THE_NAME }}.exe" | |
- name: Build for Windows (after) | |
if: ${{ contains(matrix.os,'windows') == true && inputs.DO_NOT_CREATE_RELEASE == true && inputs.DO_NOT_COMPILE_CREATE_DUMMY == false }} | |
working-directory: repo | |
run: | | |
dir the-output | |
dir the-output/main.dist | |
- uses: actions/upload-artifact@v3 | |
if: ${{ inputs.DO_NOT_MOVE_ARTIFACTS == false }} | |
with: | |
if-no-files-found: error | |
name: "${{ matrix.os }}" | |
path: | | |
./repo/the-output/${{ env.THE_NAME }}.bin | |
./repo/the-output/${{ env.THE_NAME }}.exe | |
# ./repo/the-output/main.dist | |
job-release: | |
name: Create release | |
needs: [job-build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get exact date | |
id: step_date | |
run: | | |
echo "VAR_DATE=$(date +%Y-%m-%d-%H-%M-%S)" >> $GITHUB_OUTPUT | |
- name: (dbg) Printing date | |
if: $${{ inputs.TEST_VARIABLES == true }} | |
run: echo "${{ steps.step_date.outputs.VAR_DATE }}" | |
- name: Create release | |
if: ${{ inputs.DO_NOT_CREATE_RELEASE == false }} | |
id: step_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
with: | |
tag_name: "${{ steps.step_date.outputs.VAR_DATE }}" | |
release_name: "${{ steps.step_date.outputs.VAR_DATE }}" | |
draft: false | |
prerelease: false | |
- name: Write data to NOTES | |
run: | | |
echo "" > NOTES.txt | |
echo "THE_URL=${{ steps.step_release.outputs.upload_url }}" >> NOTES.txt | |
echo "THE_DATE=${{ steps.step_date.outputs.VAR_DATE }}" >> NOTES.txt | |
echo "{" | |
cat NOTES.txt | |
echo "}" | |
- name: Upload NOTES | |
uses: actions/upload-artifact@v3 | |
with: | |
name: "NOTES" | |
path: "NOTES.txt" | |
if-no-files-found: error | |
job-attach: | |
name: Attach artifact as an asset | |
needs: [job-release] | |
strategy: | |
max-parallel: 2 | |
matrix: | |
binary: [ubuntu-20.04 , windows-2019 ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download repo (again) | |
uses: actions/checkout@v4 | |
with: | |
path: repo | |
- name: Download Notes | |
uses: actions/download-artifact@v3 | |
with: | |
name: "NOTES" | |
- name: Recover from Notes | |
id: step_notes | |
run: | | |
cat NOTES.txt | |
cat NOTES.txt >> $GITHUB_OUTPUT | |
- name: (dbg) Test Notes | |
if: $${{ inputs.TEST_VARIABLES == true }} | |
run: | | |
echo "CURRENT DATE = ${{ steps.step_notes.outputs.THE_DATE }}" | |
echo "UPLOAD URL = ${{ steps.step_notes.outputs.THE_URL }}" | |
- name: Download artifact | |
if: ${{ inputs.DO_NOT_MOVE_ARTIFACTS == false }} | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ matrix.binary }} | |
path: "${{ env.THE_NAME }}" | |
- name: Create the package | |
if: ${{ inputs.DO_NOT_MOVE_ARTIFACTS == false }} | |
run: | | |
cp -v repo/config.yaml "${{ env.THE_NAME }}/config.yaml" | |
mkdir -v "${{ env.THE_NAME }}/sources" | |
cp -v repo/htmx.min.js "${{ env.THE_NAME }}/sources/htmx.min.js" | |
cp -v repo/custom.css "${{ env.THE_NAME }}/sources/custom.css" | |
echo "${{ steps.step_notes.outputs.THE_DATE }}" > "${{ env.THE_NAME }}/README.md" | |
cat repo/README.md >> "${{ env.THE_NAME }}/README.md" | |
zip -0 -r "${{ env.THE_NAME }}-${{ matrix.binary }}.zip" "${{ env.THE_NAME }}" | |
echo "[ CONTENTS] " | |
find . | |
echo "[ SIZE ]" | |
du -h "${{ env.THE_NAME }}" | |
- name: Attach the artifact | |
if: ${{ inputs.DO_NOT_CREATE_RELEASE == false }} | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
with: | |
upload_url: "${{ steps.step_notes.outputs.THE_URL }}" | |
asset_path: "${{ env.THE_NAME }}-${{ matrix.binary }}.zip" | |
asset_name: "${{ env.THE_NAME }}-${{ matrix.binary }}.zip" | |
asset_content_type: application/octet-stream | |