-
Notifications
You must be signed in to change notification settings - Fork 2
148 lines (140 loc) · 3.79 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
137
138
139
140
141
142
143
144
145
146
147
148
name: Create tagged release
on:
push:
tags:
- 'v*'
jobs:
create_release:
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
-
name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
build-cli:
runs-on: ubuntu-latest
needs:
- create_release
steps:
-
name: Action Checkout
uses: actions/checkout@v3
-
name: Setup Golang
uses: actions/setup-go@v4
with:
go-version: '1.21'
-
name: Test
run: go test -v .
-
name: Build
run: /usr/bin/env bash ./cmds/mcla/build.sh -ldflags="-X 'main.version=${GITHUB_REF#refs/*/}'"
-
name: Upload Release Assets
uses: zyxkad/upload-release-asset-dir@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_dir: ./output
build-wasm:
runs-on: ubuntu-latest
steps:
-
name: Action Checkout
uses: actions/checkout@v3
-
name: Setup Tinygo
uses: acifani/setup-tinygo@v1
with:
tinygo-version: '0.30.0'
-
name: Build wasm
run: |
mkdir output
/usr/bin/env bash ./cmds/mcla_wasm/build.sh -o ./output/mcla.wasm -opt=z -no-debug -ldflags="-X 'main.version=${GITHUB_REF#refs/*/}'"
cp ./cmds/mcla_wasm/wasm_exec.js ./output/wasm_exec.js
-
name: Upload wasm output to artifact
uses: actions/upload-artifact@v2
with:
name: build-wasm-output
path: output/mcla.wasm
-
name: Upload tinygo wasm_exec to artifact
uses: actions/upload-artifact@v2
with:
name: build-wasm-exec-js
path: output/wasm_exec.js
publish-wasm:
runs-on: ubuntu-latest
needs:
- create_release
- build-wasm
steps:
-
name: Download build-wasm output from artifact
uses: actions/download-artifact@v2
with:
name: build-wasm-output
path: output
-
name: Download tinygo wasm_exec from artifact
uses: actions/download-artifact@v2
with:
name: build-wasm-exec-js
path: output
-
name: Upload Release Assets
uses: zyxkad/upload-release-asset-dir@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_dir: ./output
publish-pages:
runs-on: ubuntu-latest
needs:
- build-wasm
steps:
-
name: Action Checkout
uses: actions/checkout@v3
with:
ref: 'pages'
-
name: Download build-wasm output from artifact
uses: actions/download-artifact@v2
with:
name: build-wasm-output
path: .
-
name: Download tinygo wasm_exec from artifact
uses: actions/download-artifact@v2
with:
name: build-wasm-exec-js
path: .
-
name: Good for version control
run: |
export RELEASE_VERSION="${GITHUB_REF#refs/*/}"
mkdir -p "${RELEASE_VERSION}"
cp wasm_exec.js mcla.wasm "${RELEASE_VERSION}"
-
name: Commit and push
run: |
git config user.name github-actions
git config user.email github-actions[bot]@users.noreply.github.com
git add .
git commit -m "published"
git push