-
Notifications
You must be signed in to change notification settings - Fork 71
136 lines (108 loc) · 4.02 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: Build
on:
push:
branches:
- development
pull_request:
branches:
- development
# Stops the running workflow of previous pushes
concurrency:
# cancel per workflow
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-core:
name: "stremio-core-*: Lint, test and build"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Rust setup (stable)
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Lint - rustfmt
run: cargo fmt --all -- --check
- name: Lint - clippy
run: cargo clippy --all --no-deps -- -D warnings
- name: Test
run: cargo test
- name: Build
run: cargo build
build-stremio-core-web:
name: "stremio-core-web: test (wasm) and build"
env:
NODE_VERSION: 12
WASM_PACK_VERSION: 0.12.1
# No need to check core-web if core itself is not passing
needs: build-core
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Rust setup
uses: dtolnay/[email protected]
with:
components: rustfmt, clippy, rust-std
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@v2
with:
tool: wasm-pack@${{ env.WASM_PACK_VERSION }}
- name: Setup chromedriver
uses: nanasess/setup-chromedriver@v2
- name: Run wasm tests (Chrome)
working-directory: stremio-core-web
run: wasm-pack test --chromedriver "$(which chromedriver)" --chrome --headless
- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
registry-url: https://registry.npmjs.org/
cache-dependency-path: stremio-core-web/package-lock.json
- name: Install NPM dependencies
working-directory: stremio-core-web
run: npm ci
- name: Build (release)
if: ${{ ! startsWith(github.ref, 'refs/pull/') }}
working-directory: stremio-core-web
run: npm run build
# if merge request, the ref_name will be e.g. `705/merge`
# so we need to recursively create these 2 folders
# create folder for release and dev builds to be published on GH pages
- run: mkdir -p ./build/${{ github.ref_name }}/dev
if: ${{ ! startsWith(github.ref, 'refs/pull/') }}
working-directory: stremio-core-web
- name: Package (release)
if: ${{ ! startsWith(github.ref, 'refs/pull/') }}
working-directory: stremio-core-web
run: npm pack
- name: Copy release package archive
if: ${{ ! startsWith(github.ref, 'refs/pull/') }}
working-directory: stremio-core-web
run: mv ./*.tgz ./build/${{ github.ref_name }}
- name: Build (dev)
working-directory: stremio-core-web
run: npm run build-dev
- name: Package (dev)
if: ${{ ! startsWith(github.ref, 'refs/pull/') }}
working-directory: stremio-core-web
run: npm pack
- name: Copy dev package archive
if: ${{ ! startsWith(github.ref, 'refs/pull/') }}
working-directory: stremio-core-web
run: mv ./*.tgz ./build/${{ github.ref_name }}/dev
- name: Deploy gh-pages
if: ${{ ! startsWith(github.ref, 'refs/pull/') && github.actor != 'dependabot[bot]' }}
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# the build directory already contains the `github.ref_name` as subfolder(s)
publish_dir: ./stremio-core-web/build
# in stremio, we use `feat/features-name` or `fix/this-bug`
# so we need a recursive creation of the destination dir!
destination_dir: ./stremio-core-web/
# otherwise it clears all existing files and folders in stremio-core-web subdir in gh-pages.
keep_files: true
allow_empty_commit: true