Skip to content

Commit 67cfcaf

Browse files
authored
Automatically create draft release (#53)
* Draft release * Add release download links * Address comments
1 parent 0fc18aa commit 67cfcaf

File tree

8 files changed

+303
-29
lines changed

8 files changed

+303
-29
lines changed

.github/workflows/backend.yml

Lines changed: 59 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,18 @@ jobs:
2929
- run: python -m PyInstaller --onefile app.py
3030
- uses: actions/upload-artifact@v2
3131
with:
32-
name: "server_${{ matrix.os }}"
32+
name: "server_${{ runner.os }}"
3333
path: backend/dist
3434

35-
release:
35+
docker-release:
3636
if: github.ref == 'refs/heads/master'
37-
38-
strategy:
39-
matrix:
40-
os: [ubuntu-latest]
41-
42-
runs-on: ${{ matrix.os }}
43-
37+
runs-on: ubuntu-latest
4438
needs: build
45-
4639
steps:
4740
- uses: actions/checkout@v2
4841
- uses: actions/download-artifact@v2
4942
with:
50-
name: "server_${{ matrix.os }}"
43+
name: server_Linux
5144
path: backend/dist
5245
- uses: docker/build-push-action@v1
5346
with:
@@ -57,3 +50,58 @@ jobs:
5750
registry: docker.pkg.github.com/polycortex/polydodo
5851
repository: backend
5952
tags: latest
53+
54+
release:
55+
if: github.ref == 'refs/heads/master'
56+
runs-on: ubuntu-latest
57+
needs: build
58+
steps:
59+
- uses: actions/checkout@v2
60+
61+
- uses: release-drafter/release-drafter@v5
62+
id: create_release
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
66+
- uses: actions/download-artifact@v2
67+
with:
68+
name: server_Linux
69+
path: backend/dist/linux
70+
- run: chmod +x backend/dist/linux/app
71+
- run: tar -pczvf linux.tar.gz -C backend/dist/linux app
72+
- uses: actions/upload-release-asset@v1
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
with:
76+
upload_url: ${{ steps.create_release.outputs.upload_url }}
77+
asset_path: ./linux.tar.gz
78+
asset_name: polydodo_server_standalone_linux-x64.tar.gz
79+
asset_content_type: application/octet-stream
80+
81+
- uses: actions/download-artifact@v2
82+
with:
83+
name: server_macOS
84+
path: backend/dist/macos
85+
- run: chmod +x backend/dist/macos/app
86+
- run: tar -pczvf macos.tar.gz -C backend/dist/macos app
87+
- uses: actions/upload-release-asset@v1
88+
env:
89+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
with:
91+
upload_url: ${{ steps.create_release.outputs.upload_url }}
92+
asset_path: ./macos.tar.gz
93+
asset_name: polydodo_server_standalone_macos-x64.tar.gz
94+
asset_content_type: application/octet-stream
95+
96+
- uses: actions/download-artifact@v2
97+
with:
98+
name: server_Windows
99+
path: backend/dist/windows
100+
- uses: actions/upload-release-asset@v1
101+
env:
102+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103+
with:
104+
upload_url: ${{ steps.create_release.outputs.upload_url }}
105+
asset_path: ./backend/dist/windows/app.exe
106+
asset_name: polydodo_server_standalone_windows-x64.exe
107+
asset_content_type: application/octet-stream
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This file exists because of https://github.com/actions/upload-release-asset/pull/22
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
name: Delete Draft Releases
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Delete drafts
16+
uses: hugo19941994/delete-draft-releases@v0.1.0
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/mobile.yml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,32 @@ jobs:
3131
- run: flutter build apk
3232
- uses: actions/upload-artifact@v2
3333
with:
34-
name: Android app
35-
path: mobile/build/app/outputs/flutter-apk/app-release.apk
34+
name: Android
35+
path: mobile/build/app/outputs/flutter-apk
3636

37-
- run: flutter build ios --release --no-codesign
38-
- uses: actions/upload-artifact@v2
37+
- run: flutter build ios --no-codesign
38+
39+
release:
40+
if: github.ref == 'refs/heads/master'
41+
runs-on: ubuntu-latest
42+
needs: build
43+
steps:
44+
- uses: actions/checkout@v2
45+
46+
- uses: release-drafter/release-drafter@v5
47+
id: create_release
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
51+
- uses: actions/download-artifact@v2
52+
with:
53+
name: Android
54+
path: mobile/out
55+
- uses: actions/upload-release-asset@v1
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3958
with:
40-
name: iOS app
41-
path: mobile/build/ios/iphoneos/Runner.app
59+
upload_url: ${{ steps.create_release.outputs.upload_url }}
60+
asset_path: ./mobile/out/app-release.apk
61+
asset_name: polydodo_app_android.apk
62+
asset_content_type: application/octet-stream

.github/workflows/web.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ jobs:
2323
path: web/build
2424

2525
release:
26+
if: github.ref == 'refs/heads/master'
2627
runs-on: ubuntu-latest
2728
needs: build
28-
if: github.ref == 'refs/heads/master'
2929
steps:
3030
- uses: actions/checkout@v2
3131
- uses: actions/download-artifact@v2

web/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@
2323
"not op_mini all"
2424
],
2525
"dependencies": {
26+
"@octokit/rest": "^18.0.6",
2627
"argon-design-system-react": "^1.1.0",
2728
"axios": "^0.20.0",
2829
"axios-observable": "^1.1.3",
2930
"bootstrap": "^4.5.0",
3031
"classnames": "2.2.6",
3132
"d3": "^5.16.0",
3233
"d3-tip": "^0.9.1",
34+
"detect-browser": "^5.2.0",
3335
"headroom.js": "^0.11.0",
3436
"luxon": "^1.25.0",
3537
"node-sass": "4.14.1",

web/src/requests/latest_release.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { Octokit } from '@octokit/rest';
2+
import { detect } from 'detect-browser';
3+
4+
const octokit = new Octokit();
5+
6+
const CURRENT_OS_NAME = detect().os;
7+
8+
const ASSET_DISPLAYNAME_MAP = {
9+
'polydodo_server_standalone_linux-x64.tar.gz': 'Linux',
10+
'polydodo_server_standalone_macos-x64.tar.gz': 'Mac OS',
11+
'polydodo_server_standalone_windows-x64.exe': 'Windows',
12+
};
13+
14+
const getPublishedReleases = async () => {
15+
const releases = await octokit.repos.listReleases({ owner: 'polycortex', repo: 'polydodo' });
16+
const publishedReleases = releases.data.filter((release) => !release.draft);
17+
return publishedReleases;
18+
};
19+
20+
export const getLatestServerReleaseAssets = async () => {
21+
const latestRelease = (await getPublishedReleases())[0];
22+
return latestRelease.assets
23+
.filter((asset) => asset.name.startsWith('polydodo_server'))
24+
.map((asset) => ({
25+
name: ASSET_DISPLAYNAME_MAP[asset.name],
26+
currentOs: CURRENT_OS_NAME.includes(ASSET_DISPLAYNAME_MAP[asset.name]),
27+
url: asset.browser_download_url,
28+
}));
29+
};
Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,39 @@
1-
import React from 'react';
1+
import React, { useEffect, useState } from 'react';
22
import { Container, Row, Col, Spinner } from 'reactstrap';
3+
import { getLatestServerReleaseAssets } from 'requests/latest_release';
4+
import { ListGroup, ListGroupItem } from 'reactstrap';
35

4-
const WaitingForServer = () => (
5-
<Container>
6-
<h3 className="mb-4">Waiting for local server to be running...</h3>
7-
<Row>
8-
<Col className="text-center mb-4">
9-
<Spinner style={{ width: '3rem', height: '3rem' }} />
10-
</Col>
11-
</Row>
12-
</Container>
13-
);
6+
const WaitingForServer = () => {
7+
const [assets, setAssets] = useState([]);
8+
9+
useEffect(() => {
10+
getLatestServerReleaseAssets().then((assets) => setAssets(assets));
11+
}, [setAssets]);
12+
13+
return (
14+
<Container>
15+
<h3 className="mb-4">Waiting for local server to be running...</h3>
16+
17+
<h3>Download latest server release</h3>
18+
<Row>
19+
<Col className="text-center mb-4">
20+
<ListGroup>
21+
{assets.map((asset) => (
22+
<ListGroupItem key={asset.name} active={asset.currentOs} tag="a" href={asset.url}>
23+
{asset.name}
24+
</ListGroupItem>
25+
))}
26+
</ListGroup>
27+
</Col>
28+
</Row>
29+
30+
<Row>
31+
<Col className="text-center mb-4">
32+
<Spinner style={{ width: '3rem', height: '3rem' }} />
33+
</Col>
34+
</Row>
35+
</Container>
36+
);
37+
};
1438

1539
export default WaitingForServer;

0 commit comments

Comments
 (0)