-
Notifications
You must be signed in to change notification settings - Fork 1
142 lines (135 loc) · 4.74 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
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
steps:
- 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
uses: actions/upload-pages-artifact@v2
with:
path: '${{ github.workspace }}/src/asteroids-website/build'
deploy:
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
release:
runs-on: ubuntu-latest
needs: deploy
permissions:
contents: write
steps:
- name: Download artifact
uses: actions/[email protected]
with:
name: github-pages
path: asteroids
- name: Set current datetime
id: set_datetime
run: echo "datetime=$(date +"%Y%m%d%H%M%S")" >> "$GITHUB_OUTPUT"
- name: Create ZIP
run: |
cd ./asteroids
mkdir ./asteroids
tar -xvf ./artifact.tar -C ./asteroids
zip -r ../asteroids-v${{ steps.set_datetime.outputs.datetime }}.zip ./asteroids/
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
with:
artifacts: "./asteroids-v${{ steps.set_datetime.outputs.datetime }}.zip"
artifactContentType: application/zip
body: Asteroids Game - Prerelease v${{ steps.set_datetime.outputs.datetime }}
prerelease: true
draft: false
commit: ${{ github.head_ref }}
tag: v${{ steps.set_datetime.outputs.datetime }}
token: ${{ secrets.GITHUB_TOKEN }}
- uses: manleydev/butler-publish-itchio-action@master
env:
BUTLER_CREDENTIALS: ${{ secrets.ITCHIO_API_KEY }}
CHANNEL: html
ITCH_GAME: asteroids
ITCH_USER: dylanlangston
PACKAGE: ./asteroids-v${{ steps.set_datetime.outputs.datetime }}.zip