11# https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax
2- name : ' On Tag '
2+ name : ' New Release '
33description : |
4- This workflow runs when a tag gets created.
4+ This workflow runs when a new tag is created.
55
66on :
77 push :
88 branches : [ 'main' ]
99 tags : [ '*' ]
1010
1111jobs :
12- run :
13- name : ' Run'
12+ tag-is-valid-package-version :
13+ name : ' Tag is Valid Package Version'
14+ runs-on : ubuntu-latest
15+ steps :
16+ - name : ' Check tag'
17+ id : check-tag
18+ env :
19+ TAG : ${{ github.ref_name }}
20+
21+ run : |
22+ if [[ "$TAG" =~ ^(0|[1-9][[:digit:]]*)\.(0|[1-9][[:digit:]]*)\.(0|[1-9][[:digit:]]*)(-(alpha|rc|beta|experimental)\.[1-9][[:digit:]]*)?$ ]]; then
23+ echo "Version \"$TAG\" is a valid package version."
24+ echo "IS_VALID_PACKAGE_VERSION=true" >> $GITHUB_OUTPUT
25+ else
26+ echo "Version \"$PACKAGE_VERSION\" is not a valid package version."
27+ echo "IS_VALID_PACKAGE_VERSION=false" >> $GITHUB_OUTPUT
28+ fi
29+
30+ outputs :
31+ is-valid-package-version : ${{ steps.check-tag.outputs.IS_VALID_PACKAGE_VERSION }}
32+
33+ build-binary :
34+ name : ' Build Binary'
1435 runs-on : windows-latest
36+ needs : [ 'tag-is-valid-package-version' ]
37+ if : ${{ needs.tag-is-valid-package-version.outputs.is-valid-package-version == 'true' }}
38+ permissions :
39+ contents : write
40+
1541 steps :
1642 - name : ' Checkout repository'
1743 uses : actions/checkout@v6
@@ -22,3 +48,161 @@ jobs:
2248 uses : ' ./.github/actions/setup_and_configure_cmake'
2349 with :
2450 preset : ' windows-vs-release'
51+
52+ - name : ' Build'
53+ id : build
54+ uses : ' ./.github/actions/build_binary_and_export_env'
55+ with :
56+ preset : ' windows-vs-release'
57+ config : ' Release'
58+ target : ' cpp_bindings_windows'
59+
60+ - name : ' Upload artifacts'
61+ uses : actions/upload-artifact@v4
62+ with :
63+ if-no-files-found : error
64+ name : cpp_bindings_windows
65+ path : build/cpp_bindings_windows.dll
66+
67+ test-unit-cpp :
68+ name : ' Test Unit C++'
69+ runs-on : windows-latest
70+ needs : [ 'build-binary' ]
71+ env :
72+ TEST_REPORT_NAME : ' test_report.xml'
73+
74+ steps :
75+ - name : ' Checkout repository'
76+ uses : actions/checkout@v6
77+
78+ - name : ' Download artifact'
79+ uses : actions/download-artifact@v4
80+ with :
81+ name : ' cpp_bindings_windows'
82+ path : artifacts
83+
84+ - name : ' Setup and configure CMake'
85+ uses : ' ./.github/actions/setup_and_configure_cmake'
86+ with :
87+ preset : ' windows-vs-release'
88+
89+ - name : ' Build'
90+ id : build
91+ uses : ' ./.github/actions/build_binary_and_export_env'
92+ with :
93+ preset : ' windows-vs-release'
94+ config : ' Release'
95+ target : ' cpp_bindings_windows'
96+
97+ - name : ' Copy library artifact next to test exe'
98+ shell : pwsh
99+ run : |
100+ $testExe = Get-ChildItem `
101+ -Recurse `
102+ -Path build `
103+ -Filter cpp_bindings_windows_tests.exe `
104+ -File | Select-Object -First 1
105+
106+ if ($testExe) {
107+ Copy-Item -Force artifacts/cpp_bindings_windows.dll $testExe.DirectoryName
108+ }
109+
110+ - name : ' Run tests'
111+ shell : pwsh
112+ run : |
113+ $testExe = Get-ChildItem `
114+ -Recurse `
115+ -Path build `
116+ -Filter cpp_bindings_windows_tests.exe `
117+ -File | Select-Object -First 1
118+
119+ if (-not $testExe) {
120+ throw "cpp_bindings_windows_tests.exe not found"
121+ }
122+
123+ Push-Location $testExe.DirectoryName
124+ & $testExe.FullName --gtest_color=yes --gtest_output=xml:$env:TEST_REPORT_NAME
125+ Pop-Location
126+
127+ Copy-Item (Join-Path $testExe.DirectoryName $env:TEST_REPORT_NAME) build/
128+
129+ - name : ' Upload test report'
130+ if : always()
131+ uses : actions/upload-artifact@v4
132+ with :
133+ name : test_reports
134+ path : build/${{ env.TEST_REPORT_NAME }}
135+
136+ - name : ' Publish test report'
137+ if : always()
138+ uses : mikepenz/action-junit-report@v5
139+ with :
140+ report_paths : ' build/${{ env.TEST_REPORT_NAME }}'
141+ detailed_summary : true
142+ group_suite : true
143+ include_passed : true
144+ annotate_notice : true
145+ check_title_template : ' {{FILE_NAME}} | {{TEST_NAME}}'
146+
147+ create-release :
148+ name : ' Create Release'
149+ runs-on : ubuntu-latest
150+ needs : [ 'test-unit-cpp' ]
151+ steps :
152+ - name : ' Download artifact'
153+ uses : actions/download-artifact@v4
154+ with :
155+ name : ' cpp_bindings_windows'
156+ path : ' artifacts'
157+
158+ - name : ' Create GitHub Release'
159+ uses : softprops/action-gh-release@v2
160+ with :
161+ name : ' v${{ github.ref_name }}'
162+ tag_name : ${{ github.ref_name }}
163+ generate_release_notes : true
164+ files : artifacts/cpp_bindings_windows.dll
165+
166+ publish-jsr :
167+ name : ' Publish JSR'
168+ runs-on : windows-latest
169+ needs : [ 'test-unit-cpp' ]
170+ permissions :
171+ contents : read
172+ id-token : write
173+
174+ steps :
175+ - name : ' Checkout repository'
176+ uses : actions/checkout@v6
177+ with :
178+ fetch-depth : 0
179+
180+ - name : ' Setup Deno'
181+ uses : denoland/setup-deno@v2
182+ with :
183+ deno-version : ' 2.x'
184+
185+ - name : ' Download artifact'
186+ uses : actions/download-artifact@v4
187+ with :
188+ name : ' cpp_bindings_windows'
189+ path : ' artifacts'
190+
191+ - name : ' Prepare files for JSR'
192+ shell : pwsh
193+ run : |
194+ New-Item -ItemType Directory -Force -Path ./jsr/bin | Out-Null
195+ Copy-Item -Force ./artifacts/cpp_bindings_windows.dll ./jsr/bin/x86_64.dll
196+
197+ ./jsr/scripts/binary_to_json.ps1 `
198+ artifacts/cpp_bindings_windows.dll `
199+ jsr/bin/x86_64.json windows-x86_64
200+
201+ ./jsr/scripts/set_version.ps1 `
202+ jsr/jsr.json `
203+ "${{ github.ref_name }}"
204+
205+ - name : ' Publish package to JSR (normal)'
206+ working-directory : jsr
207+ run : |
208+ deno publish --allow-dirty
0 commit comments