Skip to content

Commit 96ae865

Browse files
committed
Build binaries using github actions (#58)
1 parent bb516f7 commit 96ae865

25 files changed

+3876
-3461
lines changed

.gitattributes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Always use lf lineendings
2+
* text=auto
3+
4+
# Always use lf lineendings for py, js, and vue files
5+
*.js text eol=lf
6+
*.vue text eol=lf
7+
*.py text eol=lf

.github/workflows/deploy.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
name: "Build and deploy"
3+
4+
"on":
5+
push:
6+
branches:
7+
- master
8+
- release/*
9+
10+
jobs:
11+
build:
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
os:
16+
- windows-2019
17+
- macos-10.15
18+
- ubuntu-18.04
19+
steps:
20+
- uses: actions/checkout@v2
21+
22+
- name: Install node
23+
uses: actions/setup-node@v2
24+
with:
25+
node-version: '12'
26+
27+
- name: Setup Python for Ubuntu
28+
run: |
29+
sudo apt-get install -y \
30+
python3 python3-dev python3-pip python3-venv python3-all \
31+
dh-python debhelper devscripts dput software-properties-common \
32+
python3-distutils python3-setuptools python3-wheel python3-stdeb
33+
if: startsWith(matrix.os, 'ubuntu')
34+
35+
- name: Build binary for Ubuntu
36+
run: |
37+
python3 -m venv env
38+
source env/bin/activate
39+
make build-quick
40+
if: startsWith(matrix.os, 'ubuntu')
41+
42+
- name: Setup Python for not Ubuntu
43+
uses: actions/setup-python@v2
44+
with:
45+
python-version: 3.6
46+
if: startsWith(matrix.os, 'ubuntu') == false
47+
48+
- name: Build binary for not Ubuntu
49+
run: make build-quick
50+
if: startsWith(matrix.os, 'ubuntu') == false
51+
52+
- uses: actions/upload-artifact@v2
53+
with:
54+
name: ${{ matrix.os }}
55+
path: |
56+
dist/*.pkg
57+
dist/*.exe
58+
dist/install_linux.bash
59+
dist/*.deb
60+
if-no-files-found: error
61+
retention-days: 1
62+
63+
deploy:
64+
runs-on: ubuntu-latest
65+
needs: build
66+
67+
steps:
68+
- uses: actions/checkout@v2
69+
70+
- name: Configure AWS credentials
71+
uses: aws-actions/configure-aws-credentials@v1
72+
with:
73+
aws-access-key-id: ${{ secrets.AWS_S3_FS_ACCESS_KEY_ID }}
74+
aws-secret-access-key: ${{ secrets.AWS_S3_FS_SECRET_ACCESS_KEY }}
75+
aws-region: eu-west-1
76+
77+
- name: Download artifacts
78+
uses: actions/download-artifact@v2
79+
with:
80+
path: ./dist
81+
82+
- name: Set version
83+
run: |
84+
echo "VERSION=v$(jq --raw-output .version < package.json)" >> $GITHUB_ENV
85+
echo "S3_CP=aws s3 cp --acl public-read" >> $GITHUB_ENV
86+
echo "S3_SYNC=aws s3 sync --acl public-read" >> $GITHUB_ENV
87+
88+
- name: Upload fs to S3
89+
run: |
90+
$S3_CP dist/ubuntu*/install_linux.bash s3://codegradefs/$VERSION/install_linux.bash
91+
$S3_CP dist/ubuntu*/python3-fusepy*.deb s3://codegradefs/$VERSION/linux/python3-fusepy.deb
92+
$S3_CP dist/ubuntu*/python3-codegrade-fs*_all.deb s3://codegradefs/$VERSION/linux/python3-codegrade-fs_all.deb
93+
$S3_CP dist/ubuntu*/codegrade-fs*_amd64.deb s3://codegradefs/$VERSION/linux/codegrade-fs_amd64.deb
94+
$S3_CP dist/ubuntu*/codegrade-fs*_i386.deb s3://codegradefs/$VERSION/linux/codegrade-fs_i386.deb
95+
96+
$S3_CP dist/windows*/*.exe s3://codegradefs/$VERSION/codegrade_filesystem_installer.exe
97+
$S3_CP dist/mac*/*.pkg s3://codegradefs/$VERSION/codegrade_filesystem_installer.pkg

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.DS_Store
22
/env/
3+
/.env/
34
/__pycache__/
45
*/__pycache__/
56
mount/

.scripts/get_macfuse.bash

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
cd "$(dirname "$0")/../" || exit 1
6+
7+
tmp="$(mktemp -d)"
8+
9+
function rm_tmp() {
10+
if [[ -n "$tmp" ]]; then
11+
rm -r "$tmp"
12+
fi
13+
}
14+
15+
trap "rm_tmp" 0 1 2 3 13 15 # EXIT HUP INT QUIT PIPE TERM
16+
17+
wget https://github.com/osxfuse/osxfuse/releases/download/macfuse-4.0.5/macfuse-4.0.5.dmg \
18+
-O "$tmp/fuse.dmg"
19+
hdiutil attach -mountpoint "$tmp/mnt" "$tmp/fuse.dmg"
20+
cp "$tmp"/mnt/*.pkg build/pkg-scripts/osxfuse.pkg
21+
hdiutil detach "$tmp/mnt"

.scripts/get_os.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env python
2+
import sys
3+
import platform
4+
5+
6+
def main():
7+
system = platform.system()
8+
if system == 'Windows':
9+
print('win')
10+
elif system in ('Darwin', 'Linux'):
11+
print(system.lower())
12+
else:
13+
print('The system {} is not supported'.format(system), file=sys.stderr)
14+
sys.exit(1)
15+
16+
17+
if __name__ == '__main__':
18+
main()

.scripts/install_linux.bash renamed to .scripts/make_install_linux_script.py

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
#!/usr/bin/env python
2+
import os
3+
import json
4+
5+
BASE = os.path.join(os.path.dirname(__file__), '..')
6+
7+
TEMPLATE = """
18
#!/bin/bash
2-
# SPDX-License-Identifier: AGPL-3.0-only
3-
VERSION="1.1.2"
9+
BASE_URL="https://fs.codegrade.com/v{{VERSION}}/linux"
410
511
err_echo() {
612
(>&2 echo "$@")
@@ -20,13 +26,13 @@
2026
}
2127
2228
install_deps() {
23-
sudo apt-get install -qy wget python3 fuse python3-requests libnotify4 gconf2 gconf-service libappindicator1 libxtst6 libnss3
29+
sudo apt-get install -qy wget python3 fuse python3-requests libnotify4 gconf2 gconf-service libappindicator1 libxtst6 libnss3 python3-packaging
2430
}
2531
2632
download_file() {
2733
local url="$1" dst="$2"
2834
if ! wget --quiet "$url" -O "$dst"; then
29-
err_echo "Failed to download file: $url"
35+
err_echo "Failed to download file: ${url}, please check if a new version is available on https://codegrade.com/download-codegrade-filesystem"
3036
exit 10
3137
fi
3238
}
@@ -63,38 +69,49 @@
6369
echo "Updating package list"
6470
sudo apt update -q
6571
66-
printf "\\nInstalling dependencies\\n"
72+
printf "\\\\nInstalling dependencies\\\\n"
6773
if ! install_deps; then
6874
err_echo "Failed to install dependencies"
6975
exit 4
7076
fi
7177
tmpdir="$(mktemp -d)"
7278
trap '[[ -n $tmpdir ]] && rm -rf "$tmpdir"' 0 1 2 3 15
7379
74-
printf "\\nDownloading all needed files\\n"
75-
download_file "https://codegra.de/static/fs/linux/python3-fusepy_NEWEST-1_all.deb" "$tmpdir/fusepy.deb"
76-
if is_distro "Debian"; then
77-
download_file "https://codegra.de/static/fs/debian/python3-codegrade-fs_${VERSION}-1_all.deb" "$tmpdir/backend.deb"
78-
else
79-
download_file "https://codegra.de/static/fs/ubuntu/python3-codegrade-fs_${VERSION}-1_all.deb" "$tmpdir/backend.deb"
80-
fi
81-
download_file "https://codegra.de/static/fs/linux/codegrade-fs_${VERSION}_$(get_arch).deb" "$tmpdir/frontend.deb"
80+
printf "\\\\nDownloading all needed files\\\\n"
81+
download_file "${BASE_URL}/python3-fusepy.deb" "$tmpdir/fusepy.deb"
82+
download_file "${BASE_URL}/python3-codegrade-fs_all.deb" "$tmpdir/backend.deb"
83+
download_file "${BASE_URL}/codegrade-fs_$(get_arch).deb" "$tmpdir/frontend.deb"
8284
8385
if _pip list | grep -- 'CodeGra.fs'; then
84-
printf "\\nRemoving old versions\\n"
86+
printf "\\\\nRemoving old versions\\\\n"
8587
_pip uninstall -y CodeGra.fs
8688
fi
8789
88-
printf "\\nInstalling our version of fusepy\\n"
90+
printf "\\\\nInstalling our version of fusepy\\\\n"
8991
sudo dpkg -i "$tmpdir/fusepy.deb"
90-
printf "\\nInstalling the backend of the CodeGrade Filesystem\\n"
92+
printf "\\\\nInstalling the backend of the CodeGrade Filesystem\\\\n"
9193
sudo dpkg -i "$tmpdir/backend.deb"
92-
printf "\\nInstalling the frontend of the CodeGrade Filesystem\\n"
94+
printf "\\\\nInstalling the frontend of the CodeGrade Filesystem\\\\n"
9395
sudo dpkg -i "$tmpdir/frontend.deb"
9496
rm -rf "$tmpdir"
9597
tmpdir=""
9698
97-
printf "\\nDone installing the file system\\n"
99+
printf "\\\\nDone installing the file system\\\\n"
98100
}
99101
100102
main
103+
""".lstrip()
104+
105+
106+
def main():
107+
with open(os.path.join(BASE, 'package.json'), 'r') as f:
108+
version = json.load(f)['version']
109+
110+
dist_dir = os.path.join(BASE, 'dist')
111+
os.makedirs(dist_dir, exist_ok=True)
112+
with open(os.path.join(dist_dir, 'install_linux.bash'), 'w') as f:
113+
f.write(TEMPLATE.replace('{{VERSION}}', version))
114+
115+
116+
if __name__ == '__main__':
117+
main()

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
include debian/patches/fix-cgfs_types
22
include debian/patches/fix-fusepy
33
include debian/patches/series
4+
include package.json

0 commit comments

Comments
 (0)