Skip to content

Commit f8b1419

Browse files
committed
fix: enhance GitHub Actions workflow for deployment
1 parent 34be70b commit f8b1419

File tree

3 files changed

+37
-23
lines changed

3 files changed

+37
-23
lines changed

.github/workflows/release.yml

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,57 +40,68 @@ jobs:
4040

4141
- name: Run tests
4242
run: cargo test
43-
44-
pages:
45-
name: Deploy Demo App
43+
44+
build:
45+
name: Build Demo App
4646
needs: test
4747
if: github.event_name == 'push'
4848
runs-on: ubuntu-latest
49-
environment:
50-
name: github-pages
51-
url: ${{ steps.deployment.outputs.page_url }}
5249
steps:
5350
- uses: actions/checkout@v4
5451

55-
- name: Setup Rust
56-
uses: dtolnay/rust-toolchain@stable
52+
- name: Restore cache
53+
uses: actions/cache@v3
5754
with:
58-
targets: wasm32-unknown-unknown
59-
60-
- name: Update Rust toolchain
61-
run: rustup update stable
55+
path: |
56+
~/.cargo/bin
57+
~/.cargo/git
58+
~/.cargo/registry
59+
target
60+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
6261

6362
- name: Install Trunk
6463
uses: jetli/[email protected]
6564
with:
6665
version: 'latest'
6766

68-
- name: Install wasm-bindgen-cli
69-
run: cargo install wasm-bindgen-cli
67+
- name: Add WASM target
68+
run: rustup target add wasm32-unknown-unknown
7069

7170
- name: Build Demo App
7271
run: |
7372
cd demo
74-
trunk build --release
73+
RUSTFLAGS='--cfg getrandom_backend="wasm_js"' trunk build --public-url "/bigcolor" --release
7574
7675
- name: Setup Pages
7776
uses: actions/configure-pages@v5
7877

79-
- name: Create deployment directory
80-
run: |
81-
mkdir -p _site
82-
cp -r demo/dist/* _site/
83-
8478
- name: Upload artifact
8579
uses: actions/upload-pages-artifact@v3
86-
80+
with:
81+
path: "demo/dist"
82+
83+
deploy:
84+
name: Deploy to GitHub Pages
85+
needs: build
86+
if: github.event_name == 'push'
87+
runs-on: ubuntu-latest
88+
89+
permissions:
90+
pages: write
91+
id-token: write
92+
93+
environment:
94+
name: github-pages
95+
url: ${{ steps.deployment.outputs.page_url }}
96+
97+
steps:
8798
- name: Deploy to GitHub Pages
8899
id: deployment
89100
uses: actions/deploy-pages@v4
90101

91102
release:
92103
name: Semantic Release
93-
needs: [test, pages]
104+
needs: [test, deploy]
94105
if: github.event_name == 'push'
95106
runs-on: ubuntu-latest
96107
permissions:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<p align="center">
22
<br/>
3-
<a target="_blank"><img width="256px" src="public/logo.png" /></a>
3+
<a target="_blank"><img width="256px" src="https://github.com/ducflair/bigcolor/blob/main/public/logo.png?raw=true" /></a>
44
<p align="center">Rust Color Parser & Manipulation Library</p>
55
<p align="center" style="align: center;">
66
<a href="https://crates.io/crates/bigcolor/"><img src="https://shields.io/badge/Crates-FFC933?logo=Rust&logoColor=646464&style=round-square" alt="Crates" /></a>

demo/Trunk.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
# Build in release mode
33
release = false
44

5+
# The public URL path for assets when deployed
6+
public_url = "/bigcolor/"
7+
58
[watch]
69
# Watch for changes in these directories
710
watch = ["src", "index.html", "styles.css"]

0 commit comments

Comments
 (0)