Skip to content

Commit 3de5f70

Browse files
authored
Merge pull request #33 from ereslibre/add-ruby-gh-actions
Add Ruby GH workflows
2 parents dcba91a + 188d149 commit 3de5f70

File tree

9 files changed

+146
-61
lines changed

9 files changed

+146
-61
lines changed

.github/workflows/build-php.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ jobs:
4747
- name: Rename artifacts
4848
shell: bash
4949
run: |
50-
sudo mv php/build-output/php/php-${{ matrix.version }}/bin/php-cgi{${{ matrix.suffix }},-${{ matrix.version }}${{ matrix.suffix }}.wasm}
50+
sudo mv php/build-output/php/php-${{ matrix.version }}/bin/php-cgi{${{ matrix.suffix }},-${{ matrix.version }}${{ matrix.suffix }}}.wasm
5151
- name: Rename artifacts
5252
shell: bash
5353
if: ${{ matrix.build-php-cli }}
5454
run: |
55-
sudo mv php/build-output/php/php-${{ matrix.version }}/bin/php{${{ matrix.suffix }},-${{ matrix.version }}${{ matrix.suffix }}.wasm}
55+
sudo mv php/build-output/php/php-${{ matrix.version }}/bin/php{${{ matrix.suffix }},-${{ matrix.version }}${{ matrix.suffix }}}.wasm
5656
- name: Upload php-${{ matrix.version }}${{ matrix.suffix }}.wasm artifact
5757
uses: actions/upload-artifact@v3
5858
if: ${{ matrix.build-php-cli }}

.github/workflows/build-ruby.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Build Ruby
2+
on:
3+
push:
4+
# By specifying branches explicitly, we avoid this workflow from
5+
# running on tag push. We have a dedicated workflow to be ran when
6+
# a tag is pushed.
7+
branches:
8+
- "*"
9+
pull_request:
10+
jobs:
11+
build-ruby:
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
include:
16+
- version: 3.2.0
17+
target_version: 3_2_0
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v3
22+
- name: Build Ruby
23+
run: make ruby/v${{ matrix.target_version }}
24+
- name: Rename artifacts
25+
shell: bash
26+
run: |
27+
sudo mv ruby/build-output/ruby/v${{ matrix.target_version }}/bin/ruby{,-${{ matrix.version }}}.wasm
28+
- name: Upload ruby-${{ matrix.version }}.wasm artifact
29+
uses: actions/upload-artifact@v3
30+
with:
31+
name: ruby-${{ matrix.version }}.wasm
32+
path: ruby/build-output/ruby/v${{ matrix.target_version }}/bin/ruby-${{ matrix.version }}.wasm

.github/workflows/release-php.yaml

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ jobs:
4040
build-php-cli: false
4141
version: 8.2.0
4242
runs-on: ubuntu-latest
43-
env:
44-
BINARYEN_VERSION: 111
4543
steps:
4644
- name: Checkout repository
4745
# Only run for the PHP version specified in the git tag.
@@ -65,7 +63,7 @@ jobs:
6563
if: startsWith(github.event.ref, format('refs/tags/php/{0}+', matrix.version))
6664
shell: bash
6765
run: |
68-
sudo mv php/build-output/php/php-${{ matrix.version }}/bin/php-cgi{${{ matrix.suffix }},-${{ matrix.version }}${{ matrix.suffix }}.wasm}
66+
sudo mv php/build-output/php/php-${{ matrix.version }}/bin/php-cgi{${{ matrix.suffix }},-${{ matrix.version }}${{ matrix.suffix }}}.wasm
6967
- name: Rename release artifacts
7068
# Only run for the PHP version specified in the git tag.
7169
#
@@ -74,38 +72,7 @@ jobs:
7472
if: ${{ startsWith(github.event.ref, format('refs/tags/php/{0}+', matrix.version)) && matrix.build-php-cli }}
7573
shell: bash
7674
run: |
77-
sudo mv php/build-output/php/php-${{ matrix.version }}/bin/php{${{ matrix.suffix }},-${{ matrix.version }}${{ matrix.suffix }}.wasm}
78-
- name: Setup binaryen
79-
# Only run for the PHP version specified in the git tag.
80-
#
81-
# This if could be moved to the parent `job` section when it's
82-
# supported by GitHub (https://github.com/community/community/discussions/37883)
83-
if: startsWith(github.event.ref, format('refs/tags/php/{0}+', matrix.version))
84-
shell: bash
85-
run: |
86-
wget https://github.com/WebAssembly/binaryen/releases/download/version_${{ env.BINARYEN_VERSION }}/binaryen-version_${{ env.BINARYEN_VERSION }}-x86_64-linux.tar.gz
87-
tar -xf binaryen-version_${{ env.BINARYEN_VERSION }}-x86_64-linux.tar.gz --strip-components=1 -C /opt
88-
rm binaryen-version_${{ env.BINARYEN_VERSION }}-x86_64-linux.tar.gz
89-
- name: Optimize php-cgi release artifacts
90-
# Only run for the PHP version specified in the git tag.
91-
#
92-
# This if could be moved to the parent `job` section when it's
93-
# supported by GitHub (https://github.com/community/community/discussions/37883)
94-
if: startsWith(github.event.ref, format('refs/tags/php/{0}+', matrix.version))
95-
shell: bash
96-
run: |
97-
sudo /opt/bin/wasm-opt -Os -o php/build-output/php/php-${{ matrix.version }}/bin/php-cgi-${{ matrix.version }}${{ matrix.suffix }}.size-optimized.wasm php/build-output/php/php-${{ matrix.version }}/bin/php-cgi-${{ matrix.version }}${{ matrix.suffix }}.wasm
98-
sudo /opt/bin/wasm-opt -O -o php/build-output/php/php-${{ matrix.version }}/bin/php-cgi-${{ matrix.version }}${{ matrix.suffix }}.speed-optimized.wasm php/build-output/php/php-${{ matrix.version }}/bin/php-cgi-${{ matrix.version }}${{ matrix.suffix }}.wasm
99-
- name: Optimize php release artifacts
100-
# Only run for the PHP version specified in the git tag.
101-
#
102-
# This if could be moved to the parent `job` section when it's
103-
# supported by GitHub (https://github.com/community/community/discussions/37883)
104-
if: ${{ startsWith(github.event.ref, format('refs/tags/php/{0}+', matrix.version)) && matrix.build-php-cli }}
105-
shell: bash
106-
run: |
107-
sudo /opt/bin/wasm-opt -Os -o php/build-output/php/php-${{ matrix.version }}/bin/php-${{ matrix.version }}${{ matrix.suffix }}.size-optimized.wasm php/build-output/php/php-${{ matrix.version }}/bin/php-${{ matrix.version }}${{ matrix.suffix }}.wasm
108-
sudo /opt/bin/wasm-opt -O -o php/build-output/php/php-${{ matrix.version }}/bin/php-${{ matrix.version }}${{ matrix.suffix }}.speed-optimized.wasm php/build-output/php/php-${{ matrix.version }}/bin/php-${{ matrix.version }}${{ matrix.suffix }}.wasm
75+
sudo mv php/build-output/php/php-${{ matrix.version }}/bin/php{${{ matrix.suffix }},-${{ matrix.version }}${{ matrix.suffix }}}.wasm
10976
- name: Create release
11077
# Only run for the PHP version specified in the git tag.
11178
#
@@ -116,7 +83,7 @@ jobs:
11683
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11784
run: |
11885
gh release create --generate-notes ${{ github.ref_name }} || true
119-
- name: Append php-cgi release assets
86+
- name: Append PHP release assets
12087
# Only run for the PHP version specified in the git tag.
12188
#
12289
# This if could be moved to the parent `job` section when it's
@@ -126,22 +93,7 @@ jobs:
12693
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12794
run: |
12895
gh release upload ${{ github.ref_name }} \
129-
php/build-output/php/php-${{ matrix.version }}/bin/php-cgi-${{ matrix.version }}${{ matrix.suffix }}.wasm \
130-
php/build-output/php/php-${{ matrix.version }}/bin/php-cgi-${{ matrix.version }}${{ matrix.suffix }}.size-optimized.wasm \
131-
php/build-output/php/php-${{ matrix.version }}/bin/php-cgi-${{ matrix.version }}${{ matrix.suffix }}.speed-optimized.wasm
132-
- name: Append php release assets
133-
# Only run for the PHP version specified in the git tag.
134-
#
135-
# This if could be moved to the parent `job` section when it's
136-
# supported by GitHub (https://github.com/community/community/discussions/37883)
137-
if: ${{ startsWith(github.event.ref, format('refs/tags/php/{0}+', matrix.version)) && matrix.build-php-cli }}
138-
env:
139-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140-
run: |
141-
gh release upload ${{ github.ref_name }} \
142-
php/build-output/php/php-${{ matrix.version }}/bin/php-${{ matrix.version }}${{ matrix.suffix }}.wasm \
143-
php/build-output/php/php-${{ matrix.version }}/bin/php-${{ matrix.version }}${{ matrix.suffix }}.size-optimized.wasm \
144-
php/build-output/php/php-${{ matrix.version }}/bin/php-${{ matrix.version }}${{ matrix.suffix }}.speed-optimized.wasm
96+
php/build-output/php/php-${{ matrix.version }}/bin/*.wasm
14597
- name: Generate release assets digests
14698
# Only run for the PHP version specified in the git tag.
14799
#
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Note that for this workflow to be triggered, the tag needs to be
2+
# created of the form `ruby/<version>+<buildinfo>`, where <buildinfo>
3+
# by convention is YYYYMMDD-<short-sha> (short SHA can be calculated
4+
# with `git rev-parse --short HEAD`). An example of a tag following
5+
# the convention that triggers automation would be
6+
# `ruby/3.2.0+20221123-8dfe8b9`.
7+
name: Release Ruby
8+
on:
9+
push:
10+
tags:
11+
- ruby/*
12+
jobs:
13+
release-ruby:
14+
strategy:
15+
matrix:
16+
include:
17+
- version: 3.2.0
18+
target_version: 3_2_0
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout repository
22+
# Only run for the Ruby version specified in the git tag.
23+
#
24+
# This if could be moved to the parent `job` section when it's
25+
# supported by GitHub (https://github.com/community/community/discussions/37883)
26+
if: startsWith(github.event.ref, format('refs/tags/ruby/{0}+', matrix.version))
27+
uses: actions/checkout@v3
28+
- name: Build Ruby
29+
# Only run for the Ruby version specified in the git tag.
30+
#
31+
# This if could be moved to the parent `job` section when it's
32+
# supported by GitHub (https://github.com/community/community/discussions/37883)
33+
if: startsWith(github.event.ref, format('refs/tags/ruby/{0}+', matrix.version))
34+
run: make ruby/v${{ matrix.target_version }}
35+
- name: Rename release artifacts
36+
# Only run for the Ruby version specified in the git tag.
37+
#
38+
# This if could be moved to the parent `job` section when it's
39+
# supported by GitHub (https://github.com/community/community/discussions/37883)
40+
if: startsWith(github.event.ref, format('refs/tags/ruby/{0}+', matrix.version))
41+
shell: bash
42+
run: |
43+
sudo mv ruby/build-output/ruby/v${{ matrix.target_version }}/bin/ruby{,-${{ matrix.version }}}.wasm
44+
- name: Create release
45+
# Only run for the Ruby version specified in the git tag.
46+
#
47+
# This if could be moved to the parent `job` section when it's
48+
# supported by GitHub (https://github.com/community/community/discussions/37883)
49+
if: startsWith(github.event.ref, format('refs/tags/ruby/{0}+', matrix.version))
50+
env:
51+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
run: |
53+
gh release create --generate-notes ${{ github.ref_name }} || true
54+
- name: Append Ruby release assets
55+
# Only run for the Ruby version specified in the git tag.
56+
#
57+
# This if could be moved to the parent `job` section when it's
58+
# supported by GitHub (https://github.com/community/community/discussions/37883)
59+
if: ${{ startsWith(github.event.ref, format('refs/tags/ruby/{0}+', matrix.version))}}
60+
env:
61+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
run: |
63+
gh release upload ${{ github.ref_name }} \
64+
ruby/build-output/ruby/v${{ matrix.target_version }}/bin/*.wasm
65+
- name: Generate release assets digests
66+
# Only run for the Ruby version specified in the git tag.
67+
#
68+
# This if could be moved to the parent `job` section when it's
69+
# supported by GitHub (https://github.com/community/community/discussions/37883)
70+
if: ${{ startsWith(github.event.ref, format('refs/tags/ruby/{0}+', matrix.version))}}
71+
env:
72+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
run: |
74+
for asset in ruby/build-output/ruby/v${{ matrix.target_version }}/bin/*.wasm; do
75+
sha256sum "$asset" | sudo tee "$asset.sha256sum" > /dev/null
76+
done
77+
- name: Append release assets digests
78+
# Only run for the Ruby version specified in the git tag.
79+
#
80+
# This if could be moved to the parent `job` section when it's
81+
# supported by GitHub (https://github.com/community/community/discussions/37883)
82+
if: ${{ startsWith(github.event.ref, format('refs/tags/ruby/{0}+', matrix.version))}}
83+
env:
84+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85+
run: |
86+
gh release upload ${{ github.ref_name }} \
87+
ruby/build-output/ruby/v${{ matrix.target_version }}/bin/*.sha256sum

php/php-7.3.33/wl-build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ make cgi || exit 1
3636
logStatus "Preparing artifacts... "
3737
mkdir -p ${WASMLABS_OUTPUT}/bin 2>/dev/null || exit 1
3838

39-
cp sapi/cgi/php-cgi ${WASMLABS_OUTPUT}/bin/ || exit 1
39+
logStatus "Running wasm-opt with the asyncify pass on php-cgi..."
40+
wasm-opt -O2 --asyncify --pass-arg=asyncify-ignore-imports -o ${WASMLABS_OUTPUT}/bin/php-cgi.wasm sapi/cgi/php-cgi || exit 1
4041

4142
logStatus "DONE. Artifacts in ${WASMLABS_OUTPUT}"

php/php-7.4.32/wl-build.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ make -j ${MAKE_TARGETS} || exit 1
4848
logStatus "Preparing artifacts... "
4949
mkdir -p ${WASMLABS_OUTPUT}/bin 2>/dev/null || exit 1
5050

51-
cp sapi/cgi/php-cgi ${WASMLABS_OUTPUT}/bin/php-cgi${WASMLABS_RUNTIME:+-$WASMLABS_RUNTIME} || exit 1
51+
logStatus "Running wasm-opt with the asyncify pass on php-cgi..."
52+
wasm-opt -O2 --asyncify --pass-arg=asyncify-ignore-imports -o ${WASMLABS_OUTPUT}/bin/php-cgi${WASMLABS_RUNTIME:+-$WASMLABS_RUNTIME}.wasm sapi/cgi/php-cgi || exit 1
5253

5354
if [[ "${WASMLABS_RUNTIME}" == "wasmedge" ]]
5455
then
55-
cp sapi/cli/php ${WASMLABS_OUTPUT}/bin/php${WASMLABS_RUNTIME:+-$WASMLABS_RUNTIME} || exit 1
56+
logStatus "Running wasm-opt with the asyncify pass on php.."
57+
wasm-opt -O2 --asyncify --pass-arg=asyncify-ignore-imports -o ${WASMLABS_OUTPUT}/bin/php${WASMLABS_RUNTIME:+-$WASMLABS_RUNTIME}.wasm sapi/cli/php || exit 1
5658
fi
5759

5860
logStatus "DONE. Artifacts in ${WASMLABS_OUTPUT}"

php/php-8.1.11/wl-build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ make cgi || exit 1
4040
logStatus "Preparing artifacts... "
4141
mkdir -p ${WASMLABS_OUTPUT}/bin 2>/dev/null || exit 1
4242

43-
cp sapi/cgi/php-cgi ${WASMLABS_OUTPUT}/bin/ || exit 1
43+
logStatus "Running wasm-opt with the asyncify pass on php-cgi.."
44+
wasm-opt -O2 --asyncify --pass-arg=asyncify-ignore-imports -o ${WASMLABS_OUTPUT}/bin/php-cgi.wasm sapi/cgi/php-cgi || exit 1
4445

4546
logStatus "DONE. Artifacts in ${WASMLABS_OUTPUT}"

php/php-8.2.0/wl-build.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,13 @@ make -j ${MAKE_TARGETS} || exit 1
5151
logStatus "Preparing artifacts... "
5252
mkdir -p ${WASMLABS_OUTPUT}/bin 2>/dev/null || exit 1
5353

54-
cp sapi/cgi/php-cgi ${WASMLABS_OUTPUT}/bin/php-cgi${WASMLABS_RUNTIME:+-$WASMLABS_RUNTIME} || exit 1
54+
logStatus "Running wasm-opt with the asyncify pass on php-cgi.."
55+
wasm-opt -O2 --asyncify --pass-arg=asyncify-ignore-imports -o ${WASMLABS_OUTPUT}/bin/php-cgi${WASMLABS_RUNTIME:+-$WASMLABS_RUNTIME}.wasm sapi/cgi/php-cgi || exit 1
5556

5657
if [[ "${WASMLABS_RUNTIME}" == "wasmedge" ]]
5758
then
58-
cp sapi/cli/php ${WASMLABS_OUTPUT}/bin/php${WASMLABS_RUNTIME:+-$WASMLABS_RUNTIME} || exit 1
59+
logStatus "Running wasm-opt with the asyncify pass on php.."
60+
wasm-opt -O2 --asyncify --pass-arg=asyncify-ignore-imports -o ${WASMLABS_OUTPUT}/bin/php${WASMLABS_RUNTIME:+-$WASMLABS_RUNTIME}.wasm sapi/cli/php || exit 1
5961
fi
6062

6163
logStatus "DONE. Artifacts in ${WASMLABS_OUTPUT}"

ruby/v3_2_0/wl-build.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@ cd "${WASMLABS_CHECKOUT_PATH}"
1010

1111
mkdir -p build
1212

13+
logStatus "Downloading autotools data... "
14+
1315
ruby tool/downloader.rb -d tool -e gnu config.guess config.sub
1416

17+
logStatus "Generating configure script... "
18+
1519
./autogen.sh
1620

21+
logStatus "Configuring ruby..."
22+
1723
./configure \
1824
--host wasm32-unknown-wasi \
1925
--with-ext=ripper,monitor \
@@ -26,8 +32,10 @@ ruby tool/downloader.rb -d tool -e gnu config.guess config.sub
2632
debugflags="" \
2733
wasmoptflags="-O2"
2834

35+
logStatus "Building ruby..."
2936
make ruby
3037

31-
cp ruby ${WASMLABS_OUTPUT}/bin/ || exit 1
38+
logStatus "Preparing artifacts... "
39+
mv ruby ${WASMLABS_OUTPUT}/bin/ruby.wasm || exit 1
3240

3341
logStatus "DONE. Artifacts in ${WASMLABS_OUTPUT}"

0 commit comments

Comments
 (0)