forked from ruby/ruby-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (122 loc) · 4.33 KB
/
build.yml
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
name: Build Ruby for GitHub Actions
on:
workflow_dispatch:
# push:
# paths-ignore:
# - README.md
jobs:
# Build stable releases
build:
if: true
strategy:
fail-fast: false
matrix:
include:
# - os: ubuntu-22.04
# ruby: 3.2.3
# runs-on: ruby-builder-amd64
- os: ubuntu-22.04
ruby: 3.2.3
runs-on: ruby-builder-arm64
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
- name: Set tag name
id: info
run: |
tag=toolcache
echo "tag=$tag" >> $GITHUB_OUTPUT
- name: Set ruby
id: ruby
run: |
ruby=${{ matrix.ruby }}
if [[ "$ruby" == [0-9]* ]]; then
ruby="ruby-$ruby"
fi
echo "ruby=$ruby" >> $GITHUB_OUTPUT
- name: Check if already built
run: '! curl -s -L --head --fail https://github.com/quipper/ruby-builder/releases/download/${{ steps.info.outputs.tag }}/${{ steps.ruby.outputs.ruby }}-${{ matrix.os }}.tar.gz'
- name: Set NO_DOCUMENT
run: |
if [[ "${{ steps.ruby.outputs.ruby }}" == ruby-1.9* ]]; then
echo "NO_DOCUMENT=--no-ri --no-rdoc" >> $GITHUB_ENV
else
echo "NO_DOCUMENT=--no-document" >> $GITHUB_ENV
fi
- name: Clone ruby-build
run: git clone https://github.com/rbenv/ruby-build.git
- name: Install ruby-build
run: sudo ./ruby-build/install.sh
- name: List versions
run: ruby-build --definitions
# Install packages
- run: sudo apt-get install -y --no-install-recommends libyaml-dev libgdbm-dev libreadline-dev libncurses5-dev
if: startsWith(matrix.os, 'ubuntu') && startsWith(steps.ruby.outputs.ruby, 'ruby-')
- name: Set RUBY_BUILD_RUBY_NAME
run: |
ruby="${{ steps.ruby.outputs.ruby }}"
if [[ $ruby == ruby-* ]]; then
echo "RUBY_BUILD_RUBY_NAME=${ruby#ruby-}" >> $GITHUB_ENV
else
echo "RUBY_BUILD_RUBY_NAME=$ruby" >> $GITHUB_ENV
fi
- name: Set PREFIX
run: |
ruby="${{ steps.ruby.outputs.ruby }}"
if [[ $ruby == ruby-* ]]; then
# See https://github.com/ruby/setup-ruby/issues/98
arch=$(node -e 'console.log(os.arch())')
echo "PREFIX=$RUNNER_TOOL_CACHE/Ruby/${ruby#ruby-}/$arch" >> $GITHUB_ENV
else
echo "PREFIX=$HOME/.rubies/$ruby" >> $GITHUB_ENV
fi
- run: rm -rf $PREFIX
- name: Build Ruby
run: ruby-build --verbose $RUBY_BUILD_RUBY_NAME $PREFIX
env:
CPPFLAGS: "-DENABLE_PATH_CHECK=0" # https://github.com/actions/virtual-environments/issues/267
- name: Create archive
run: tar czf ${{ steps.ruby.outputs.ruby }}-${{ steps.platform.outputs.platform }}.tar.gz -C $(dirname $PREFIX) $(basename $PREFIX)
- name: Install Bundler if needed
run: |
if [ ! -e $PREFIX/bin/bundle ]; then
export PATH="$PREFIX/bin:$PATH"
gem install bundler -v '~> 1' $NO_DOCUMENT
fi
- run: echo "$PREFIX/bin" >> $GITHUB_PATH
- run: ruby --version
- run: ruby -ropen-uri -e 'puts URI.send(:open, %{https://rubygems.org/}) { |f| f.read(1024) }'
- name: Install JSON gem
run: gem install json -v '2.2.0' $NO_DOCUMENT
- run: bundle --version
- run: bundle install
- run: bundle exec rake --version
- run: ruby test_subprocess.rb
- name: Upload Built Ruby
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: gh release upload "toolcache" "${{ steps.ruby.outputs.ruby }}-${{ steps.platform.outputs.platform }}.tar.gz"
createPullRequest:
name: Create PR to setup-ruby
needs: [build]
if: startsWith(github.event.head_commit.message, 'Build ')
runs-on: ubuntu-latest
steps:
- name: Set versions
id: versions
env:
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: |
commit_message="$COMMIT_MESSAGE"
if [[ "$commit_message" =~ ^Build\ * ]]; then
versions=${commit_message#* }
echo "versions=$versions" >> $GITHUB_OUTPUT
else
exit 2
fi
- uses: ruby/ruby-builder/.github/actions/create-pr-to-setup-ruby@master
with:
versions: ${{ steps.versions.outputs.versions }}
title: Add ${{ steps.versions.outputs.versions }}
token: ${{ secrets.CHECK_NEW_RELEASES_TOKEN }}