-
-
Notifications
You must be signed in to change notification settings - Fork 1
250 lines (238 loc) · 8.23 KB
/
release.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
name: release
on:
push:
branches:
- master
- release/*
paths:
- '**.rs'
- '**/Cargo.*'
- '.github/workflows/release.yml'
- '**.pi'
- '**/Kagari.*'
- 'codecov.yml'
- 'plc.scoop'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
artifacts:
name: Artifacts
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- os: "macos-14"
dir: osx64
arch: darwin-arm64
artifacts: "plc"
RUSTFLAGS: ""
libvm: "libvm.a"
libvm_dylib: "libvm.dylib"
- os: "ubuntu-latest"
dir: linux64
debdir: pivot-lang_0.1.0-1_amd64
artifacts: "plc"
arch: linux-amd64
RUSTFLAGS: ""
libvm: "libvm.a"
libvm_dylib: "libvm.so"
- os: "windows-latest"
dir: win64
artifacts: "plc.exe"
RUSTFLAGS: "-Dwarnings -Ctarget-feature=+crt-static"
libvm: "vm.lib"
libvm_dylib: "vm.dll"
arch: windows-amd64
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Rust (stable)
uses: dsherret/rust-toolchain-file@v1
- uses: actions/cache@v3
name: Cache Cargo
if: ${{ matrix.config.os != 'self-hosted' && matrix.config.os != 'windows-latest' }}
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install LLVM
uses: Pivot-Studio/setup-llvm@main
- uses: ilammy/msvc-dev-cmd@v1
if: ${{ matrix.config.os == 'windows-latest' }}
- name: Cargo build vm
env:
RUSTFLAGS: ${{ matrix.config.RUSTFLAGS }}
run: cd vm && cargo build --release
- name: Cargo build
env:
RUSTFLAGS: ${{ matrix.config.RUSTFLAGS }}
run: cargo build --release
- run: mkdir -p ${{ matrix.config.dir }}
- name: Move artifacts
env:
ARTIFACTS: ${{ matrix.config.artifacts }}
OUT_DIR: ${{ matrix.config.dir }}
OS: ${{ matrix.config.os }}
run: |
import os
import shutil
artifacts = os.environ['ARTIFACTS'].split()
for artifact in artifacts:
src = "target/release/%s" % artifact
dst = os.environ['OUT_DIR'] + "/" + artifact
shutil.copy(src, dst)
shell: python
- name: Move libvm
env:
ARTIFACTS: ${{ matrix.config.libvm }}
OUT_DIR: ${{ matrix.config.dir }}
OS: ${{ matrix.config.os }}
run: |
import os
import shutil
artifacts = os.environ['ARTIFACTS'].split()
for artifact in artifacts:
src = "target/release/%s" % artifact
dst = os.environ['OUT_DIR'] + "/" + artifact
shutil.copy(src, dst)
shell: python
- name: Move libvm dylib
env:
ARTIFACTS: ${{ matrix.config.libvm_dylib }}
OUT_DIR: ${{ matrix.config.dir }}
OS: ${{ matrix.config.os }}
run: |
import os
import shutil
artifacts = os.environ['ARTIFACTS'].split()
for artifact in artifacts:
src = "target/release/%s" % artifact
dst = os.environ['OUT_DIR'] + "/" + artifact
shutil.copy(src, dst)
shell: python
- name: Move pllib
env:
ARTIFACTS: planglib
OUT_DIR: ${{ matrix.config.dir }}
OS: ${{ matrix.config.os }}
run: |
import os
import shutil
artifacts = os.environ['ARTIFACTS'].split()
for artifact in artifacts:
src = "%s" % artifact
dst = os.environ['OUT_DIR'] + "/" + artifact
shutil.copytree(src, dst)
shell: python
- if: ${{ matrix.config.os == 'ubuntu-latest' }}
name: Set up QEMU
uses: docker/setup-qemu-action@v3
- if: ${{ matrix.config.os == 'ubuntu-latest' }}
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- if: ${{ matrix.config.os == 'ubuntu-latest' }}
name: Login to ali registry
uses: docker/login-action@v3
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- if: ${{ matrix.config.os == 'ubuntu-latest' }}
name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
file: ./Dockerfile
tags: registry.cn-hangzhou.aliyuncs.com/pivot_studio/pivot_lang:latest
- name: prepare deb
if: ${{ matrix.config.os == 'ubuntu-latest' }}
run: |
mkdir -p ${{ matrix.config.debdir }}
cp -r deb/* ${{ matrix.config.debdir }}/
rm ${{ matrix.config.debdir }}/apt.yaml
ls ${{ matrix.config.debdir }}/
chmod +x ${{ matrix.config.debdir }}/DEBIAN/postinst
mkdir -p ${{ matrix.config.debdir }}/usr/bin
cp ${{ matrix.config.dir }}/plc ${{ matrix.config.debdir }}/usr/bin
mkdir -p ${{ matrix.config.debdir }}/pl
cp -r ${{ matrix.config.dir }}/* ${{ matrix.config.debdir }}/pl
rm ${{ matrix.config.debdir }}/pl/plc
- uses: Pivot-Studio/build-deb-action@master
if: ${{ matrix.config.os == 'ubuntu-latest' }}
id: build-deb
with:
package: pivot-lang
package_root: ${{ matrix.config.debdir }}
maintainer: Chronos <[email protected]>
version: 0.1.${{ github.run_number }} # refs/tags/v*.*.*
arch: 'amd64'
desc: 'pivot-lang compiler'
depends: build-essential, git, libunwind-dev, libxml2
- name: move deb
if: ${{ matrix.config.os == 'ubuntu-latest' }}
run: |
cp ${{ steps.build-deb.outputs.file_name }} ${{ matrix.config.dir }}/
- name: Update apt repo
if: ${{ matrix.config.os == 'ubuntu-latest' }}
uses: Pivot-Studio/apt-repo-action@master
with:
github_token: ${{ secrets.PAT }}
repo_supported_arch: |
amd64
repo_supported_version: |
jammy
focal
file: ${{ steps.build-deb.outputs.file_name }}
file_target_version: jammy
public_key: ${{ secrets.PUBLIC }}
private_key: ${{ secrets.PRIVATE }}
key_passphrase: ${{ secrets.SECRET }}
page_branch: master
github_repository: Pivot-Studio/apt-repo
- name: tar artifacts
env:
OUT_DIR: ${{ matrix.config.dir }}
OS: ${{ matrix.config.os }}
run: |
import os
src = os.environ['OUT_DIR']
dst = "pivot-lang-0.1.${{ github.run_number }}-${{ matrix.config.arch }}.tar.gz"
os.system("tar -czvf %s %s" % (dst, src))
shell: python
- name: Set outputs
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- uses: ncipollo/release-action@v1
name: upload
with:
artifacts: "pivot-lang-0.1.${{ github.run_number }}-${{ matrix.config.arch }}.tar.gz"
allowUpdates: true
replacesArtifacts: false
commit: master
tag: v0.1.${{ github.run_number }}
- name: generate scoop manifest
if: ${{ matrix.config.os == 'windows-latest' }}
run: |
mkdir scoop
$template=(cat .\plc.scoop)
$version="v0.1.${{ github.run_number }}"
$file="pivot-lang-0.1.${{ github.run_number }}-${{ matrix.config.arch }}.tar.gz"
$sha256=($(certutil -hashfile $file SHA256)[1])
cd scoop
$template -f $version,$file,$sha256>plc.json
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: ${{ matrix.config.os == 'windows-latest' }}
with:
personal_token: ${{ secrets.PAT }}
publish_dir: ./scoop
publish_branch: scoop
external_repository: Pivot-Studio/scoop