Skip to content

Commit 5e0294d

Browse files
authored
Merge pull request #40 from huanshankeji/github-actions-and-github-pages
Enable GitHub Actions and host the demo with GitHub Pages
2 parents 755a259 + 263c476 commit 5e0294d

File tree

6 files changed

+180
-2
lines changed

6 files changed

+180
-2
lines changed

.github/workflows/ci.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ "*" ]
6+
# pull_request:
7+
# branches: [ "*" ]
8+
9+
jobs:
10+
check:
11+
12+
strategy:
13+
matrix:
14+
os: [ ubuntu-latest, macos-latest, windows-latest ]
15+
runs-on: ${{ matrix.os }}
16+
permissions:
17+
contents: read
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Set up JDK 8
22+
uses: actions/setup-java@v4
23+
with:
24+
java-version: '8'
25+
distribution: 'zulu'
26+
- name: Set up JDK 17
27+
uses: actions/setup-java@v4
28+
with:
29+
java-version: '17'
30+
distribution: 'temurin'
31+
32+
- name: Setup Gradle
33+
uses: gradle/actions/setup-gradle@v4
34+
35+
- name: Check with Gradle Wrapper
36+
run: ./gradlew check
37+
38+
dependency-submission:
39+
40+
strategy:
41+
matrix:
42+
os: [ ubuntu-latest, macos-latest, windows-latest ]
43+
runs-on: ${{ matrix.os }}
44+
permissions:
45+
contents: write
46+
47+
steps:
48+
- uses: actions/checkout@v4
49+
- name: Set up JDK 17
50+
uses: actions/setup-java@v4
51+
with:
52+
java-version: '17'
53+
distribution: 'temurin'
54+
55+
- name: Generate and submit dependency graph
56+
uses: gradle/actions/dependency-submission@v4
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Deploy the demo to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [ "release" ]
6+
pull_request:
7+
branches: [ "release" ]
8+
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20+
concurrency:
21+
group: "pages"
22+
cancel-in-progress: false
23+
24+
jobs:
25+
# Build job
26+
build:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
- name: Setup Pages
32+
uses: actions/configure-pages@v5
33+
34+
- name: Set up JDK 17
35+
uses: actions/setup-java@v4
36+
with:
37+
java-version: "17"
38+
distribution: "temurin"
39+
40+
- name: Setup Gradle
41+
uses: gradle/actions/setup-gradle@v4
42+
43+
- name: Build the distribution with Gradle Wrapper
44+
run: ./gradlew :demo:sideBySideBrowserDistribution
45+
46+
- name: Upload artifact
47+
uses: actions/upload-pages-artifact@v3
48+
with:
49+
path: demo/build/dist/sideBySide/productionExecutable/
50+
51+
# Deployment job
52+
deploy:
53+
environment:
54+
name: github-pages
55+
url: ${{ steps.deployment.outputs.page_url }}
56+
runs-on: ubuntu-latest
57+
needs: build
58+
steps:
59+
- name: Deploy to GitHub Pages
60+
id: deployment
61+
uses: actions/deploy-pages@v4

demo/build.gradle.kts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,19 @@ android {
119119
debugImplementation(compose.uiTooling)
120120
}
121121
}
122+
123+
val jsBrowserDistribution by tasks.getting(Copy::class)
124+
val wasmJsBrowserDistribution by tasks.getting(Copy::class)
125+
126+
tasks.register<Sync>("sideBySideBrowserDistribution") {
127+
group = "kotlin browser"
128+
129+
into(layout.buildDirectory.dir("dist/sideBySide/productionExecutable"))
130+
from(jsBrowserDistribution) {
131+
into("js-dom")
132+
}
133+
from(wasmJsBrowserDistribution) {
134+
into("wasm-js-canvas")
135+
}
136+
from(projectDir.resolve("side-by-side-site"))
137+
}

demo/side-by-side-site/index.html

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
6+
<meta charset="UTF-8">
7+
<title>Side by side - Compose Multiplatform Material demo</title>
8+
<meta content="width=device-width, initial-scale=1" name="viewport">
9+
<style>
10+
body {
11+
margin: 0;
12+
height: 100vh;
13+
}
14+
15+
.row {
16+
display: flex;
17+
flex-direction: row;
18+
height: 100%;
19+
}
20+
21+
.column {
22+
display: flex;
23+
flex-direction: column;
24+
}
25+
26+
.flex-grow-1 {
27+
flex-grow: 1;
28+
}
29+
</style>
30+
</head>
31+
32+
<body>
33+
<div class="row">
34+
<div class="flex-grow-1 column">
35+
<h2>JS DOM / Compose HTML</h2>
36+
<embed class="flex-grow-1" src="js-dom/index.html">
37+
</div>
38+
<div class="flex-grow-1 column">
39+
<h2>Wasm JS canvas / <code>androidx.compose</code></h2>
40+
<embed class="flex-grow-1" src="wasm-js-canvas/index.html">
41+
</div>
42+
</div>
43+
</body>
44+
45+
</html>

demo/src/jsMain/resources/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<head>
55
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
66
<meta charset="UTF-8">
7-
<title>Compose Multiplatform Material demo</title>
7+
<title>JS DOM - Compose Multiplatform Material demo</title>
88
<meta content="width=device-width, initial-scale=1" name="viewport">
99
<style>
1010
body {

demo/src/wasmJsMain/resources/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<head>
55
<meta charset="UTF-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7-
<title>Compose Multiplatform Material demo</title>
7+
<title>Wasm JS canvas - Compose Multiplatform Material demo</title>
88
<link type="text/css" rel="stylesheet" href="styles.css">
99
<script src="app.js" type="application/javascript"></script>
1010
</head>

0 commit comments

Comments
 (0)