-
Notifications
You must be signed in to change notification settings - Fork 1
182 lines (173 loc) · 6.03 KB
/
DeployPages.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: Deploy Pages
on:
push:
branches: ["main"]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
outputs:
datetime: ${{ steps.set_datetime.outputs.datetime }}
steps:
- name: Set current datetime output variable
id: set_datetime
run: echo "datetime=$(date +"%Y%m%d%H%M%S")" >> "$GITHUB_OUTPUT"
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Checkout
id: checkout
uses: actions/checkout@v3
- name: Checkout submodules
run: git submodule update --init --recursive
- name: Setup Zig
uses: goto-bus-stop/[email protected]
with:
version: 0.11.0
- name: Setup Node
id: setup-node
uses: actions/setup-node@v3
with:
node-version: "20.10.0"
cache: 'npm'
cache-dependency-path: "${{ github.workspace }}/src/asteroids-website"
- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- name: Node Cache
uses: actions/cache@v3
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: |
${{ steps.npm-cache-dir.outputs.dir }}
${{ github.workspace }}/src/asteroids-website/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('${{ github.workspace }}/src/asteroids-website/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Node Modules
run: |
cd ${{ github.workspace }}/src/asteroids-website
npm install
- name: Install Wizer
uses: baptiste0928/[email protected]
with:
crate: wizer
# Enable all features - https://docs.rs/crate/wizer/latest/features
features: structopt,env_logger,wasmprinter
- name: Zig Cache
uses: Hanaasagi/[email protected]
with:
cache-directories: "${{ github.workspace }}/src/emscripten/upstream/"
- name: Build Zig
run: |
cd ${{ github.workspace }}
zig build -Dtarget=wasm32-emscripten -Doptimize=ReleaseFast
- name: Wizer Pre-Init
run: |
cd ${{ github.workspace }}/src/asteroids-website
wizer ./src/import/asteroids.wasm --init-func wizer_initialize -o ./src/import/asteroids-initialized.wasm
- name: Binaryen Optimize
run: |
cd ${{ github.workspace }}/src/asteroids-website
npm exec --package=binaryen -c 'wasm-opt ./src/import/asteroids-initialized.wasm -all --post-emscripten --low-memory-unused -tnh --converge -Oz --flatten --rereloop -Oz -Oz -o ./src/import/asteroids.wasm'
rm ./src/import/asteroids-initialized.wasm
- name: Build Svelte
run: |
cd ${{ github.workspace }}/src/asteroids-website
npm run build
- name: Upload artifact
id: upload
uses: actions/upload-artifact@v4
with:
name: release-artifact
path: '${{ github.workspace }}/src/asteroids-website/build'
- name: Build Svelte compressed
run: |
cd ${{ github.workspace }}/src/asteroids-website
npm run build-compressed
- name: Upload github pages artifact
id: upload-compressed
uses: actions/upload-pages-artifact@v2
with:
path: '${{ github.workspace }}/src/asteroids-website/build'
- name: Upload itch.io artifact
id: upload-itchio
uses: actions/upload-artifact@v4
with:
name: itch-io
path: '${{ github.workspace }}/src/asteroids-website/build'
deploy-github-pages:
runs-on: ubuntu-latest
needs: [build]
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
deploy-itchio:
runs-on: ubuntu-latest
needs: [build, deploy-github-pages]
permissions:
contents: write
steps:
- name: Download artifact compressed
id: download
uses: actions/download-artifact@v4
with:
name: itch-io
- name: Push to itch.io
uses: manleydev/butler-publish-itchio-action@master
env:
BUTLER_CREDENTIALS: ${{ secrets.ITCHIO_API_KEY }}
CHANNEL: html
VERSION: v${{ needs.build.outputs.datetime }}
ITCH_GAME: asteroids
ITCH_USER: dylanlangston
PACKAGE: ${{ steps.download.outputs.download-path }}
- name: Sleep 30s
run: sleep 30s
- name: First load of itch.io
uses: karol-brejna-i/webpage-screenshot-action@v1
with:
url: https://dylanlangston.itch.io/asteroids
release:
runs-on: ubuntu-latest
needs: [build, deploy-github-pages]
permissions:
contents: write
steps:
- name: Download artifact
id: download
uses: actions/download-artifact@v4
with:
name: release-artifact
- name: Create ZIP
run: |
cd ${{ steps.download.outputs.download-path }}/../
zip -r ./asteroids-v${{ needs.build.outputs.datetime}}.zip ./asteroids/
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
with:
artifacts: "${{ steps.download.outputs.download-path }}/../asteroids-v${{ needs.build.outputs.datetime}}.zip"
artifactContentType: application/zip
body: |
**Asteroids Game - _Prerelease v${{ needs.build.outputs.datetime }}_**
${{ github.event.head_commit.message }}
prerelease: true
draft: false
commit: ${{ github.head_ref }}
tag: v${{ needs.build.outputs.datetime }}
token: ${{ secrets.GITHUB_TOKEN }}