Repository navigation
153 lines (130 loc) · 5.57 KB
/
Copy pathrelease.yml
File metadata and controls
153 lines (130 loc) · 5.57 KB
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
name: release
# タグを打つとビルドしてGitHub Releasesへ成果物を添付する。
#
# パッケージレジストリ(NuGet / Maven Central / npm / PyPI / crates.io)へは公開せず、
# ここに置いたファイルを利用者が自分のプロジェクトへ組み込む形をとる。
on:
push:
tags: ["v*"]
# タグを打つ前に組み立てだけ試せるようにしておく
workflow_dispatch:
# gh release createで成果物を上げるために要る
permissions:
contents: write
jobs:
release:
name: 成果物を組み立てて公開する
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "21"
cache: maven
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: npm
cache-dependency-path: typescript/package-lock.json
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: dtolnay/rust-toolchain@stable
# 版はタグだけで決める。手動実行のときはCHANGELOGのいちばん新しい版を使う
- name: 版を決める
id: version
run: |
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
version="${GITHUB_REF_NAME#v}"
else
version=$(python3 spec/tools/set_version.py --changelog-latest)
fi
echo "value=${version}" >> "$GITHUB_OUTPUT"
echo "組み立てる版: ${version}"
# リポジトリのパッケージ設定は0.0.0のままなので、組み立てる前に版を書き込む
- name: パッケージ設定へ版を書き込む
run: python3 spec/tools/set_version.py "${{ steps.version.outputs.value }}"
# CHANGELOGにその版の節が無ければここで落ちる
# 変更点を書き忘れたまま、テストや組み立てに時間を使わないよう先に確かめる
- name: リリース本文を組み立てる
run: |
python3 spec/tools/release_notes.py \
"${{ steps.version.outputs.value }}" --output release-body.md
echo "----- ここから本文 -----"
cat release-body.md
# 正しく動かないものを配らないよう、公開前に必ず全部通す
- name: 全言語のテスト
run: |
(cd csharp && dotnet test --configuration Release)
(cd java && mvn --batch-mode test)
(cd typescript && npm ci && npm test)
(cd python && pip install pytest && python -m pytest tests)
(cd rust && cargo test --all-features)
- name: 全言語の挙動が一致することの検証
run: ./spec/run-conformance.sh
# dllを直接参照したい人向け。xmlを隣に置かないと補完に説明が出ないので、
# LICENSEと合わせてひとまとめにする
- name: C# (zip)
run: |
dotnet build csharp/src/SpringNBTLibrary/SpringNBTLibrary.csproj \
--configuration Release
mkdir -p artifacts/csharp
cp csharp/src/SpringNBTLibrary/bin/Release/net8.0/SpringNBTLibrary.dll artifacts/csharp/
cp csharp/src/SpringNBTLibrary/bin/Release/net8.0/SpringNBTLibrary.xml artifacts/csharp/
cp LICENSE artifacts/csharp/
cp csharp/README.md artifacts/csharp/
(cd artifacts/csharp && zip -q -r \
"../SpringNBTLibrary-${{ steps.version.outputs.value }}-dotnet8.zip" .)
# NuGetへは公開しないが、落としたファイルをローカルのソースにできる
- name: C# (nupkg)
run: |
dotnet pack csharp/src/SpringNBTLibrary/SpringNBTLibrary.csproj \
--configuration Release --output artifacts
- name: Java (jar)
run: |
(cd java && mvn --batch-mode -DskipTests package)
mkdir -p artifacts
cp java/target/spring-nbt-library-*.jar artifacts/
- name: TypeScript (tgz)
run: |
(cd typescript && npm run build && npm pack)
mkdir -p artifacts
cp typescript/spring-nbt-library-*.tgz artifacts/
- name: Python (wheel / sdist)
run: |
pip install build
(cd python && python -m build)
mkdir -p artifacts
cp python/dist/*.whl python/dist/*.tar.gz artifacts/
# 版を書き込んだCargo.tomlは未コミットの変更になるので、--allow-dirtyで許す
- name: Rust (crate)
run: |
(cd rust && cargo package --no-verify --allow-dirty)
mkdir -p artifacts
cp rust/target/package/spring-nbt-library-*.crate artifacts/
# 落としたファイルが元のままか、利用者が確かめられるようにする
- name: チェックサムを作る
run: |
rm -rf artifacts/csharp
(cd artifacts && sha256sum * > SHA256SUMS.txt)
ls -la artifacts
- name: Releases へ上げる
if: github.ref_type == 'tag'
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${GITHUB_REF_NAME}" artifacts/* \
--title "${GITHUB_REF_NAME}" \
--notes-file release-body.md \
--verify-tag
# 手動実行では中身を確認できるように残すだけにする
- name: 成果物を保存する
if: github.ref_type != 'tag'
uses: actions/upload-artifact@v4
with:
name: artifacts
path: artifacts/