This repository has been archived by the owner on Jun 4, 2024. It is now read-only.
create master #98
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 master | |
on: | |
push: | |
branches: | |
- master-image-test | |
tags: | |
- master-v* | |
workflow_dispatch: | |
schedule: | |
# every months on the 1st | |
- cron: '0 6 1 * *' | |
jobs: | |
build: | |
name: master image build | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: setup environ vars | |
shell: python | |
run: | | |
import os | |
import datetime | |
GITHUB_ENV = os.getenv("GITHUB_ENV") | |
GITHUB_EVENT_NAME = os.getenv("GITHUB_EVENT_NAME", "") | |
GITHUB_REF = os.getenv("GITHUB_REF") | |
GITHUB_SHA = os.getenv("GITHUB_SHA") | |
GITHUB_WORKSPACE = os.getenv("GITHUB_WORKSPACE") | |
TAG = GITHUB_REF.split("/", 2)[-1] if GITHUB_REF.startswith("refs/tags/") else None | |
SCOMMIT = GITHUB_SHA[0:7] | |
DATE = datetime.date.today().strftime("%Y-%m-%d") | |
if TAG and TAG.startswith("master-v"): | |
UPDATES = {"BUILDTYPE": "release", "OUT_IMG": "kiwix-hotspot_master_{date}.img".format(date=DATE)} | |
else: | |
UPDATES = {"BUILDTYPE": "CI", "OUT_IMG": "kiwix-hotspot_master_{date}_{scommit}.img".format(date=DATE, scommit=SCOMMIT)} | |
# append new environ vars to GITHUB_ENV | |
lines = "\n".join(["{k}={v}".format(k=k, v=v) for k, v in UPDATES.items()]) | |
print("Updating GITHUB_ENV:\n-----\n{lines}\n-----".format(lines=lines)) | |
with open(GITHUB_ENV, "a") as fh: | |
fh.write(lines) | |
- name: verify image name | |
run : echo $OUT_IMG | |
- name: decrypt SSH key | |
env: | |
ssh_key: ${{ secrets.ssh_key }} | |
run: | | |
echo "$ssh_key" | base64 -d > ${HOME}/ssh_key | |
chmod 600 ${HOME}/ssh_key | |
mkdir -p ~/.ssh | |
chmod 700 ~/.ssh | |
ssh-keyscan -p 30022 tmp.kiwix.org >> ${HOME}/.ssh/known_hosts | |
ssh-keyscan -p 30022 master.download.kiwix.org >> ${HOME}/.ssh/known_hosts | |
chmod 644 ${HOME}/.ssh/known_hosts | |
- name: test upload | |
run: | | |
echo "from workflow" > test-file | |
scp -P 30022 -i ${HOME}/ssh_key test-file ci@tmp.kiwix.org:/data/tmp/ci/test-file | |
- name: install system deps | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install -y locales openssh-client wget zip unzip tar build-essential python3-dev libdbus-1-dev libdbus-glib-1-dev libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0 | |
- name: checkout code | |
uses: actions/checkout@v1 | |
- name: setup python version | |
uses: actions/setup-python@v1 | |
with: | |
python-version: '3.7' | |
- name: download custom kernel | |
run: | | |
wget https://drive.offspot.it/creator/bundled-in-creator/vexpress-boot.zip | |
unzip vexpress-boot.zip | |
- name: download static Qemu | |
run: | | |
wget https://drive.offspot.it/creator/bundled-in-creator/qemu-5.2.0-linux-x86_64.tar.gz | |
tar xvf qemu-5.2.0-linux-x86_64.tar.gz | |
- name: download etcher-cli (packaging only) | |
run: | | |
wget https://drive.offspot.it/creator/bundled-in-creator/balena-etcher-cli-1.4.8-linux-x64.tar.gz | |
mkdir -p etcher-cli | |
tar xf balena-etcher-cli-1.4.8-linux-x64.tar.gz -C etcher-cli --strip-components=1 | |
- name: download aria2c (packaging only) | |
run: | | |
wget https://drive.offspot.it/creator/bundled-in-creator/aria2c-linux64.zip | |
unzip aria2c-linux64.zip | |
rm aria2c-linux64.zip | |
wget https://drive.offspot.it/creator/bundled-in-creator/ca-certificates.crt | |
- name: install python deps | |
run: | | |
pip install --upgrade pip wheel | |
pip install -r requirements-linux.txt | |
python -c "import gi ; print(gi.__file__)" | |
pip install -U pyinstaller | |
- name: compile app | |
run: pyinstaller --log-level=DEBUG kiwix-hotspot-linux.spec | |
- name: build master image | |
env: | |
QEMU_CPU: 2 | |
run: dist/kiwix-hotspot image --ram 6G --root 7 --size 8 --out ${OUT_IMG} | |
- name: ZIP master image | |
run: zip -9 ${OUT_IMG}.zip ${OUT_IMG} | |
- name: Display ZIP details | |
run: | | |
ls -l * | |
openssl dgst -sha256 ${OUT_IMG}.zip | |
- name: upload master image to CI | |
run: scp -P 30022 -i ${HOME}/ssh_key -c aes128-ctr ${OUT_IMG}.zip ci@master.download.kiwix.org:/data/tmp/ci/hotspot-master/ | |
if: env.BUILDTYPE == 'CI' | |
- name: upload master image to release folder | |
run: scp -P 30022 -i ${HOME}/ssh_key -c aes128-ctr ${OUT_IMG}.zip ci@master.download.kiwix.org:/data/download/release/kiwix-hotspot/master/ | |
if: env.BUILDTYPE == 'release' |