-
Notifications
You must be signed in to change notification settings - Fork 0
183 lines (151 loc) · 4.8 KB
/
ci.yml
File metadata and controls
183 lines (151 loc) · 4.8 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
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
name: CI/CD
on:
pull_request:
branches: [ main ]
push:
tags: [ 'v*' ]
jobs:
build-native:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
rid: linux-x64
- os: macos-latest
rid: osx-arm64
- os: windows-latest
rid: win-x64
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Build Native Libraries
run: |
cd tree-sitter
make clean && make
shell: bash
- name: Copy Native Files
run: |
mkdir -p TypeScriptParser/runtimes/${{ matrix.rid }}/native
cp -r tree-sitter/dist/* TypeScriptParser/runtimes/${{ matrix.rid }}/native/
echo "Files copied for ${{ matrix.rid }}:"
shell: bash
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build -c Release --no-restore
- name: Debug Runtime Files Before Test
run: |
echo "=== Runtime files structure ==="
find ./TypeScriptParser/runtimes/ -type f
echo "=== Test output directory before testing ==="
ls -la TypeScriptParser.Tests/bin/Release/net9.0/ || echo "Test output directory not found"
shell: bash
- name: Test
run: dotnet test -c Release --no-build
- name: Upload Native Artifacts
uses: actions/upload-artifact@v4
with:
name: native-${{ matrix.rid }}
path: TypeScriptParser/runtimes/
retention-days: 1
pack-and-publish:
needs: build-native
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Download Native Artifacts
uses: actions/download-artifact@v4
with:
pattern: native-*
path: TypeScriptParser/runtimes/
merge-multiple: true
- name: Set Version
run: |
if [[ $GITHUB_REF == refs/tags/v* ]]; then
TAG=${GITHUB_REF#refs/tags/v}
VERSION="${TAG}.${{ github.run_number }}"
else
VERSION="1.0.0-pr${{ github.event.number }}.${{ github.run_number }}"
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build -c Release -p:Version=$VERSION --no-restore
- name: Pack
run: dotnet pack -c Release -p:Version=$VERSION --no-build -o ./artifacts
- name: Upload Packages
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: artifacts/*.nupkg
package-test:
needs: pack-and-publish
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
rid: linux-x64
- os: macos-latest
rid: osx-arm64
- os: windows-latest
rid: win-x64
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Download NuGet Packages
uses: actions/download-artifact@v4
with:
name: nuget-packages
path: ./artifacts
- name: Set Version
run: |
if [[ $GITHUB_REF == refs/tags/v* ]]; then
TAG=${GITHUB_REF#refs/tags/v}
VERSION="${TAG}.${{ github.run_number }}"
else
VERSION="1.0.0-pr${{ github.event.number }}.${{ github.run_number }}"
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
shell: bash
- name: Restore Dependencies
run: dotnet restore TypeScriptParser.TestPackage/
shell: bash
- name: Update Package Reference
run: |
dotnet remove TypeScriptParser.TestPackage/TypeScriptParser.TestPackage.csproj package TypeScriptParser
dotnet add TypeScriptParser.TestPackage/TypeScriptParser.TestPackage.csproj package TypeScriptParser --version $VERSION --source ./artifacts
shell: bash
- name: Test Package
run: dotnet test TypeScriptParser.TestPackage/ -c Release
shell: bash
publish:
needs: package-test
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-dev')
steps:
- name: Download NuGet Packages
uses: actions/download-artifact@v4
with:
name: nuget-packages
path: ./artifacts
- name: Publish to NuGet
run: |
dotnet nuget push artifacts/*.nupkg \
--api-key ${{ secrets.NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate