-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (138 loc) · 4.41 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
name: Build and release binary
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "Version to build"
required: true
default: "0.0.0"
defaults:
run:
shell: bash
jobs:
info:
runs-on: ubuntu-latest
outputs:
version: ${{ jobs.info.outputs.version }}
prerelease: ${{ jobs.info.outputs.prerelease }}
steps:
- name: Determine version
id: version
run: |
if [ -z "${{ inputs.version }}" ]; then
VERSION=$(echo $GITHUB_REF | sed 's/refs\/tags\/v//')
else
VERSION=${{ inputs.version }}
fi
if [[ $VERSION == *"-"* ]]; then
PRERELEASE=true
else
PRERELEASE=false
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "prerelease=${PRERELEASE}" >> $GITHUB_OUTPUT
build:
needs:
- info
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-13]
include:
- os: ubuntu-latest
suffix: -linux
- os: windows-latest
suffix: -windows
- os: macos-13 # Intel Macにする
suffix: -macos
runs-on: ${{ matrix.os }}
steps:
- name: Setup zip
if: matrix.os == 'windows-latest'
run: |
curl.exe https://www.willus.com/archive/zip64/infozip_binaries_win64.zip -o zip64.zip
7z x zip64.zip -oC:\tools
echo "C:/tools" >> $GITHUB_PATH
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Bazel
uses: bazel-contrib/[email protected]
- name: Setup Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt, clippy
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 8
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"
cache-dependency-path: "crates/assets/frontend/pnpm-lock.yaml"
- name: Cache rust dependencies
uses: Swatinem/rust-cache@v2
- name: Build frontend
run: |
cd crates/assets/frontend
pnpm install
pnpm build
- name: Build rust
run: |
echo "Building version ${{ jobs.info.outputs.version }}"
cargo install cargo-edit
cargo set-version ${{ jobs.info.outputs.version }} -p cantari
cargo test --all
cargo build --release -vv
- name: Archive
run: |
mkdir archive
cp -r target/release/{sample.vvm,*.html,dict} archive
cp target/release/{*.dylib,*.so,*.so.*,*.dll} archive || true
cp target/release/{cantari,cantari.exe} archive || true
cp crates/cantari/engine_manifest.json archive
cd archive
zip -r ../cantari-${{ jobs.info.outputs.version }}${{ matrix.suffix }}.zip .
cd ..
mv cantari-${{ jobs.info.outputs.version }}${{ matrix.suffix }}.zip cantari-${{ jobs.info.outputs.version }}${{ matrix.suffix }}.vvpp
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ jobs.info.outputs.version }}
prerelease: true
files: |
cantari-${{ jobs.info.outputs.version }}${{ matrix.suffix }}.vvpp
set-information:
needs:
- info
- build
runs-on: ubuntu-latest
steps:
- name: Set information
uses: actions/github-script@v7
with:
script: |
const version = "${{ needs.info.outputs.version }}"
const prerelease = "${{ needs.info.outputs.prerelease }}"
const body =
"使い方はここを参照してください:https://github.com/sevenc-nanashi/Cantari?tab=readme-ov-file#cantari--let-utaus-speak-on-voicevox" +
"Mac OS版は不安定です。`
const { data: release } = await github.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: `v${version}`,
})
await github.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.id,
tag_name: `v${version}`,
prerelease,
body,
})