Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 59 additions & 11 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,18 @@ jobs:
- run: python -m PyInstaller --onefile app.py
- uses: actions/upload-artifact@v2
with:
name: "server_${{ matrix.os }}"
name: "server_${{ runner.os }}"
path: backend/dist

release:
docker-release:
if: github.ref == 'refs/heads/master'

strategy:
matrix:
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}

runs-on: ubuntu-latest
needs: build

steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: "server_${{ matrix.os }}"
name: server_Linux
path: backend/dist
- uses: docker/build-push-action@v1
with:
Expand All @@ -57,3 +50,58 @@ jobs:
registry: docker.pkg.github.com/polycortex/polydodo
repository: backend
tags: latest

release:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2

- uses: release-drafter/release-drafter@v5
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/download-artifact@v2
with:
name: server_Linux
path: backend/dist/linux
- run: chmod +x backend/dist/linux/app
- run: tar -pczvf linux.tar.gz -C backend/dist/linux app
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./linux.tar.gz
asset_name: polydodo_server_standalone_linux-x64.tar.gz
asset_content_type: application/octet-stream

- uses: actions/download-artifact@v2
with:
name: server_macOS
path: backend/dist/macos
- run: chmod +x backend/dist/macos/app
- run: tar -pczvf macos.tar.gz -C backend/dist/macos app
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./macos.tar.gz
asset_name: polydodo_server_standalone_macos-x64.tar.gz
asset_content_type: application/octet-stream

- uses: actions/download-artifact@v2
with:
name: server_Windows
path: backend/dist/windows
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./backend/dist/windows/app.exe
asset_name: polydodo_server_standalone_windows-x64.exe
asset_content_type: application/octet-stream
18 changes: 18 additions & 0 deletions .github/workflows/delete-draft-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This file exists because of https://github.com/actions/upload-release-asset/pull/22

on:
push:
branches:
- master

name: Delete Draft Releases

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Delete drafts
uses: hugo19941994/delete-draft-releases@v0.1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33 changes: 27 additions & 6 deletions .github/workflows/mobile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,32 @@ jobs:
- run: flutter build apk
- uses: actions/upload-artifact@v2
with:
name: Android app
path: mobile/build/app/outputs/flutter-apk/app-release.apk
name: Android
path: mobile/build/app/outputs/flutter-apk

- run: flutter build ios --release --no-codesign
- uses: actions/upload-artifact@v2
- run: flutter build ios --no-codesign

release:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2

- uses: release-drafter/release-drafter@v5
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/download-artifact@v2
with:
name: Android
path: mobile/out
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: iOS app
path: mobile/build/ios/iphoneos/Runner.app
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./mobile/out/app-release.apk
asset_name: polydodo_app_android.apk
asset_content_type: application/octet-stream
2 changes: 1 addition & 1 deletion .github/workflows/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ jobs:
path: web/build

release:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
Expand Down
2 changes: 2 additions & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
"not op_mini all"
],
"dependencies": {
"@octokit/rest": "^18.0.6",
"argon-design-system-react": "^1.1.0",
"axios": "^0.20.0",
"axios-observable": "^1.1.3",
"bootstrap": "^4.5.0",
"classnames": "2.2.6",
"d3": "^5.16.0",
"d3-tip": "^0.9.1",
"detect-browser": "^5.2.0",
"headroom.js": "^0.11.0",
"luxon": "^1.25.0",
"node-sass": "4.14.1",
Expand Down
29 changes: 29 additions & 0 deletions web/src/requests/latest_release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Octokit } from '@octokit/rest';
import { detect } from 'detect-browser';

const octokit = new Octokit();

const CURRENT_OS_NAME = detect().os;

const ASSET_DISPLAYNAME_MAP = {
'polydodo_server_standalone_linux-x64.tar.gz': 'Linux',
'polydodo_server_standalone_macos-x64.tar.gz': 'Mac OS',
'polydodo_server_standalone_windows-x64.exe': 'Windows',
};

const getPublishedReleases = async () => {
const releases = await octokit.repos.listReleases({ owner: 'polycortex', repo: 'polydodo' });
const publishedReleases = releases.data.filter((release) => !release.draft);
return publishedReleases;
};

export const getLatestServerReleaseAssets = async () => {
const latestRelease = (await getPublishedReleases())[0];
return latestRelease.assets
.filter((asset) => asset.name.startsWith('polydodo_server'))
.map((asset) => ({
name: ASSET_DISPLAYNAME_MAP[asset.name],
currentOs: CURRENT_OS_NAME.includes(ASSET_DISPLAYNAME_MAP[asset.name]),
url: asset.browser_download_url,
}));
};
46 changes: 35 additions & 11 deletions web/src/views/analyze_sleep/waiting_for_server/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,39 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import { Container, Row, Col, Spinner } from 'reactstrap';
import { getLatestServerReleaseAssets } from 'requests/latest_release';
import { ListGroup, ListGroupItem } from 'reactstrap';

const WaitingForServer = () => (
<Container>
<h3 className="mb-4">Waiting for local server to be running...</h3>
<Row>
<Col className="text-center mb-4">
<Spinner style={{ width: '3rem', height: '3rem' }} />
</Col>
</Row>
</Container>
);
const WaitingForServer = () => {
const [assets, setAssets] = useState([]);

useEffect(() => {
getLatestServerReleaseAssets().then((assets) => setAssets(assets));
}, [setAssets]);

return (
<Container>
<h3 className="mb-4">Waiting for local server to be running...</h3>

<h3>Download latest server release</h3>
<Row>
<Col className="text-center mb-4">
<ListGroup>
{assets.map((asset) => (
<ListGroupItem key={asset.name} active={asset.currentOs} tag="a" href={asset.url}>
{asset.name}
</ListGroupItem>
))}
</ListGroup>
</Col>
</Row>

<Row>
<Col className="text-center mb-4">
<Spinner style={{ width: '3rem', height: '3rem' }} />
</Col>
</Row>
</Container>
);
};

export default WaitingForServer;
Loading