Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit 45c81d8

Browse files
committed
updated release workflow
1 parent 80a177b commit 45c81d8

File tree

3 files changed

+137
-113
lines changed

3 files changed

+137
-113
lines changed

.github/workflows/release.yml

Lines changed: 135 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -5,168 +5,192 @@ on:
55
- 'v*'
66

77
jobs:
8-
create-release:
9-
name: create-release
10-
runs-on: ubuntu-latest
11-
steps:
12-
- name: get version number
13-
run: |
14-
echo "GITHUB_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
15-
16-
- name: print version number
17-
run: |
18-
echo "tag = ${{ env.GITHUB_TAG }}"
19-
20-
- name: create release on github
21-
id: create_release
22-
uses: actions/create-release@v1
23-
env:
24-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25-
with:
26-
tag_name: ${{ env.GITHUB_TAG }}
27-
release_name: ${{ env.GITHUB_TAG }}
28-
29-
- name: generate env artifact
30-
run: |
31-
echo "RELEASE_UPLOAD_URL=${{ steps.create_release.outputs.upload_url }}" > artifact-env
32-
echo "GITHUB_TAG=$GITHUB_TAG" >> artifact-env
33-
34-
- name: save env artifact
35-
uses: actions/upload-artifact@v1
36-
with:
37-
name: artifact-env
38-
path: artifact-env
39-
40-
upload-release:
41-
name: upload-release
42-
needs: ['create-release']
8+
build-lib:
9+
name: build lib file (target = ${{ matrix.build.target }})
4310
runs-on: ${{ matrix.build.os }}
4411
env:
45-
CARGO_BUILD_TARGET: ${{ matrix.build.target }}
46-
CC: ${{ matrix.build.cc }}
12+
BUILD_ENV: release
13+
TARGET: ${{ matrix.build.target }}
4714
CXX: ${{ matrix.build.cxx }}
4815
LD: ${{ matrix.build.ld }}
49-
CARGOFLAGS: ${{ matrix.build.cargoflags }}
50-
BUILD_ENV: release
16+
AR: ${{ matrix.build.ar }}
5117
strategy:
5218
fail-fast: false
5319
matrix:
5420
build:
5521
- os: ubuntu-latest
5622
target: x86_64-unknown-linux-gnu
57-
cc: clang-9
58-
cxx: clang++-9
59-
ld: ld.lld-9
60-
cargoflags: --features="onig"
61-
output: lib-ruby-parser.a
62-
upload_as: lib-ruby-parser-x86_64-unknown-linux-gnu.a
23+
cxx: clang++-12
24+
ld: ld.lld-12
25+
ar: llvm-ar-12
26+
lib_file: libruby_parser_cpp.a
27+
output_artifact_name: libruby_parser_cpp-x86_64-unknown-linux-gnu.a
6328

6429
- os: macos-latest
6530
target: x86_64-apple-darwin
66-
cc: clang
6731
cxx: clang++
6832
ld: ld
69-
cargoflags: --features="onig"
70-
output: lib-ruby-parser.a
71-
upload_as: lib-ruby-parser-x86_64-apple-darwin.a
33+
ar: ar
34+
lib_file: libruby_parser_cpp.a
35+
output_artifact_name: libruby_parser_cpp-x86_64-apple-darwin.a
7236

7337
- os: windows-latest
7438
target: x86_64-pc-windows-msvc
75-
cc: cl.exe
7639
cxx: cl.exe
7740
ld: link.exe
78-
cargoflags: ""
79-
output: lib-ruby-parser.lib
80-
upload_as: lib-ruby-parser-x86_64-pc-windows-msvc.lib
41+
lib_file: libruby_parser_cpp.lib
42+
output_artifact_name: libruby_parser_cpp-x86_64-pc-windows-msvc.lib
8143

8244
steps:
8345
- name: setup msvc on windows
8446
if: runner.os == 'Windows'
8547
uses: ilammy/msvc-dev-cmd@v1
8648

87-
- name: fix linker on windows
88-
if: runner.os == 'Windows'
89-
run: |
90-
rm "C:\\Program Files\\Git\\usr\\bin\\link.exe"
91-
which -a link.exe
49+
- name: install rust
50+
uses: actions-rs/toolchain@v1
51+
with:
52+
profile: minimal
53+
toolchain: stable
54+
target: ${{ matrix.build.target }}
55+
override: true
56+
57+
- name: print rustc detailed version
58+
run: rustc --version --verbose
9259

9360
- name: checkout
9461
uses: actions/checkout@v2
9562

96-
- name: download env artifact
97-
uses: actions/download-artifact@v1
63+
- name: codegen
64+
env:
65+
RUSTFLAGS: ""
66+
run: |
67+
make do-codegen
68+
make token_ids.hpp
69+
70+
- name: make lib file
71+
run: |
72+
make ${{ matrix.build.lib_file }}
73+
cp ${{ matrix.build.lib_file }} ${{ matrix.build.output_artifact_name }}
74+
75+
- name: upload ${{ matrix.build.output_artifact_name }}
76+
uses: actions/upload-artifact@v2
9877
with:
99-
name: artifact-env
100-
path: artifact-env
78+
name: ${{ matrix.build.output_artifact_name }}
79+
path: ${{ matrix.build.output_artifact_name }}
80+
81+
- name: benchmark
82+
run: make benchmark/download && make benchmark/record
10183

102-
- name: load env artifact
103-
shell: bash
104-
run: cat artifact-env/artifact-env >> $GITHUB_ENV
84+
- name: upload ${{ matrix.build.target }}.benchmark-out
85+
uses: actions/upload-artifact@v2
86+
with:
87+
name: ${{ matrix.build.target }}.benchmark-out
88+
path: ${{ matrix.build.target }}.benchmark-out
10589

90+
build-header:
91+
name: build header file
92+
runs-on: ubuntu-latest
93+
env:
94+
TARGET: x86_64-unknown-linux-gnu
95+
steps:
10696
- name: install rust
10797
uses: actions-rs/toolchain@v1
10898
with:
109-
toolchain: stable
11099
profile: minimal
100+
toolchain: stable
111101
override: true
112102

113-
- name: build
114-
shell: bash
115-
run: make clean build-static
103+
- name: checkout
104+
uses: actions/checkout@v2
116105

117-
- name: show asset
118-
shell: bash
119-
run: ls -l target/release/${{ matrix.build.output }}
106+
- name: build lib-ruby-parser.hpp
107+
run: make lib-ruby-parser.hpp
120108

121-
- name: upload assets
122-
uses: actions/upload-release-asset@v1.0.1
123-
env:
124-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109+
- name: upload lib-ruby-parser.hpp
110+
uses: actions/upload-artifact@v2
125111
with:
126-
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
127-
asset_path: target/release/${{ matrix.build.output }}
128-
asset_name: ${{ matrix.build.upload_as }}
129-
asset_content_type: application/octet-stream
130-
131-
upload-headers:
132-
name: upload-headers
133-
needs: ['create-release']
112+
name: lib-ruby-parser.hpp
113+
path: lib-ruby-parser.hpp
114+
115+
build-release-notes:
116+
name: build release notes
117+
needs:
118+
- 'build-lib'
134119
runs-on: ubuntu-latest
135-
env:
136-
BUILD_ENV: release
137120
steps:
138121
- name: checkout
139122
uses: actions/checkout@v2
140123

141-
- name: download env artifact
142-
uses: actions/download-artifact@v1
143-
with:
144-
name: artifact-env
145-
path: artifact-env
124+
# download benchmark results
125+
- uses: actions/download-artifact@v2
126+
with: { name: x86_64-unknown-linux-gnu.benchmark-out }
146127

147-
- name: load env artifact
148-
run: cat artifact-env/artifact-env >> $GITHUB_ENV
128+
- uses: actions/download-artifact@v2
129+
with: { name: x86_64-apple-darwin.benchmark-out }
149130

150-
- name: install rust
151-
uses: actions-rs/toolchain@v1
131+
- uses: actions/download-artifact@v2
132+
with: { name: x86_64-pc-windows-msvc.benchmark-out }
133+
134+
- name: build release notes
135+
run: |
136+
ls -l
137+
echo "### Results for x86_64-unknown-linux-gnu:" >> release_notes.md
138+
echo "" >> release_notes.md
139+
cat x86_64-unknown-linux-gnu.benchmark-out >> release_notes.md
140+
echo "" >> release_notes.md
141+
echo "### Results for x86_64-apple-darwin:" >> release_notes.md
142+
echo "" >> release_notes.md
143+
cat x86_64-apple-darwin.benchmark-out >> release_notes.md
144+
echo "" >> release_notes.md
145+
echo "### Results for x86_64-pc-windows-msvc:" >> release_notes.md
146+
echo "" >> release_notes.md
147+
cat x86_64-pc-windows-msvc.benchmark-out >> release_notes.md
148+
echo "" >> release_notes.md
149+
cat release_notes.md
150+
151+
- name: upload release_notes.md
152+
uses: actions/upload-artifact@v2
152153
with:
153-
toolchain: stable
154-
profile: minimal
155-
override: true
154+
name: release_notes.md
155+
path: release_notes.md
156+
157+
make-release:
158+
name: release
159+
needs:
160+
- 'build-lib'
161+
- 'build-header'
162+
- 'build-release-notes'
163+
runs-on: ubuntu-latest
164+
steps:
165+
- name: checkout
166+
uses: actions/checkout@v2
156167

157-
- name: generate lib-ruby-parser.h
158-
run: make clean target/lib-ruby-parser.h
168+
# lib files
169+
- uses: actions/download-artifact@v2
170+
with: { name: libruby_parser_cpp-x86_64-unknown-linux-gnu.a }
159171

160-
- name: show asset
161-
run: ls -l target/lib-ruby-parser.h
172+
- uses: actions/download-artifact@v2
173+
with: { name: libruby_parser_cpp-x86_64-apple-darwin.a }
162174

163-
- name: upload assets
164-
uses: actions/upload-release-asset@v1.0.1
165-
env:
166-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
167-
with:
168-
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
169-
asset_path: target/lib-ruby-parser.h
170-
asset_name: lib-ruby-parser.h
171-
asset_content_type: application/octet-stream
175+
- uses: actions/download-artifact@v2
176+
with: { name: libruby_parser_cpp-x86_64-pc-windows-msvc.lib }
177+
178+
# header file
179+
- uses: actions/download-artifact@v2
180+
with: { name: lib-ruby-parser.hpp }
172181

182+
# release notes
183+
- uses: actions/download-artifact@v2
184+
with: { name: release_notes.md }
185+
186+
- name: show artifacts
187+
run: ls -l
188+
189+
- name: release
190+
uses: ncipollo/release-action@v1
191+
with:
192+
allowUpdates: true
193+
artifactErrorsFailBuild: true
194+
artifacts: "libruby_parser_cpp-*,lib-ruby-parser.hpp"
195+
bodyFile: release_notes.md
196+
token: ${{ secrets.GITHUB_TOKEN }}

benchmark/benchmark.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ int main()
3636

3737
std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
3838

39-
std::cout << double(std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count()) / 1000000000 << "[s]" << std::endl;
39+
std::cout << double(std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count()) / 1000000000 << std::endl;
4040

4141
return 0;
4242
}

benchmark/build.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ benchmark/record: benchmark/cpp-parser
4747
$(call run_benchmark, ./rust-parser >> ../$(BENCHMARK_RECORDING))
4848
echo "Ruby:" >> $(BENCHMARK_RECORDING)
4949
$(call run_benchmark, ruby ruby-parser.rb >> ../$(BENCHMARK_RECORDING))
50-
echo "C:" >> $(BENCHMARK_RECORDING)
50+
echo "C++:" >> $(BENCHMARK_RECORDING)
5151
$(call run_benchmark, ./cpp-parser >> ../$(BENCHMARK_RECORDING))

0 commit comments

Comments
 (0)