-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (94 loc) · 3.36 KB
/
release.yml
File metadata and controls
109 lines (94 loc) · 3.36 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
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'WASM version (e.g., 0.0.46.1)'
required: true
t_ruby_version:
description: 't-ruby version (e.g., 0.0.46, defaults to latest)'
required: false
permissions:
contents: write
id-token: write
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Upgrade npm for OIDC trusted publishing
run: |
npm install -g npm@latest
npm --version
- name: Install dependencies
run: npm install
- name: Extract version
id: version
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
VERSION="${{ inputs.version }}"
T_RUBY_VERSION="${{ inputs.t_ruby_version }}"
else
VERSION=${GITHUB_REF#refs/tags/v}
T_RUBY_VERSION=""
fi
# t_ruby_version이 없으면 version에서 베이스 버전 추출
# 예: 0.0.46-patch1 -> 0.0.46
if [[ -z "$T_RUBY_VERSION" ]]; then
T_RUBY_VERSION=$(echo "$VERSION" | sed 's/-patch[0-9]*$//')
fi
# prerelease 버전인지 확인 (-patch가 포함되면 prerelease)
if [[ "$VERSION" == *"-patch"* ]]; then
NPM_TAG="patch"
else
NPM_TAG="latest"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "t_ruby_version=$T_RUBY_VERSION" >> $GITHUB_OUTPUT
echo "npm_tag=$NPM_TAG" >> $GITHUB_OUTPUT
echo "Publishing version: $VERSION (t-ruby: $T_RUBY_VERSION, npm tag: $NPM_TAG)"
- name: Clone t-ruby source
run: |
git clone --depth 1 --branch v${{ steps.version.outputs.t_ruby_version }} \
https://github.com/type-ruby/t-ruby.git /tmp/t-ruby
echo "Cloned t-ruby v${{ steps.version.outputs.t_ruby_version }}"
- name: Copy t-ruby lib to vendor
run: |
mkdir -p vendor/t-ruby
cp -r /tmp/t-ruby/lib vendor/t-ruby/
echo "Copied t-ruby lib files:"
ls -la vendor/t-ruby/lib/
- name: Bundle t-ruby source
run: node scripts/bundle-t-ruby.mjs
- name: Build
run: npm run build
- name: Verify build output
run: |
echo "Verifying build output..."
ls -la dist/
test -f dist/index.js || (echo "ERROR: dist/index.js not found" && exit 1)
test -f dist/index.cjs || (echo "ERROR: dist/index.cjs not found" && exit 1)
test -f dist/index.d.ts || (echo "ERROR: dist/index.d.ts not found" && exit 1)
echo "Build verification passed!"
- name: Update version
run: npm version ${{ steps.version.outputs.version }} --no-git-tag-version --allow-same-version
- name: Publish to npm
run: npm publish --access public --provenance --tag ${{ steps.version.outputs.npm_tag }}
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: "v${{ steps.version.outputs.version }}"
name: "v${{ steps.version.outputs.version }}"
generate_release_notes: true
files: |
dist/*
package.json