-
Notifications
You must be signed in to change notification settings - Fork 11
182 lines (173 loc) · 5.83 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
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
name: JRuby Dev Builds
on:
workflow_dispatch:
push:
tags:
- '*'
schedule:
- cron: '0 19 * * *'
jobs:
prepare:
name: Check if the latest jruby commit is already built
runs-on: ubuntu-latest
outputs:
should_build: ${{ steps.check_commit.outputs.result }}
commit: ${{ steps.latest_commit.outputs.commit }}
steps:
- name: Clone jruby
uses: actions/checkout@v4
with:
repository: jruby/jruby
path: jruby
- name: Set latest_commit
id: latest_commit
working-directory: jruby
run: echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Check if latest commit already built
uses: actions/github-script@v7
id: check_commit
with:
script: |
const latestDevCommit = "${{ steps.latest_commit.outputs.commit }}"
const { owner, repo } = context.repo
let { data: release } = await github.rest.repos.getLatestRelease({ owner, repo })
const latestReleaseCommit = release.body.split('@')[1]
console.log(`Latest release commit: ${latestReleaseCommit}`)
console.log(`Latest jruby commit: ${latestDevCommit}`)
if (latestReleaseCommit === latestDevCommit) {
return 'false'
} else {
return 'true'
}
result-encoding: string
release:
name: Create GitHub Release
needs: [prepare]
# We don't build JRuby from the repo commit but from latest maven snapshort, so always run
# if: needs.prepare.outputs.should_build == 'true'
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
if: github.event_name != 'push'
- name: Set tag name
id: tag
run: |
if [[ "${{ github.event_name }}" != "push" ]]; then
tag=v$(date +%Y%m%d.%H%M%S)
else
tag=$(basename "${{ github.ref }}")
fi
echo "tag=$tag" >> $GITHUB_OUTPUT
- name: Create Release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
tag="${{ steps.tag.outputs.tag }}"
body="jruby/jruby@${{ needs.prepare.outputs.commit }}"
gh release create --draft "$tag" --title "$tag" --notes "$body"
build:
needs: [prepare, release]
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, macos-12, macos-14, windows-2019 ]
runs-on: ${{ matrix.os }}
steps:
- name: Set platform
id: platform
shell: bash
run: |
platform=${{ matrix.os }}
platform=${platform/macos-12/macos-latest}
platform=${platform/macos-14/macos-13-arm64}
platform=${platform/windows-*/windows-latest}
echo "platform=$platform" >> $GITHUB_OUTPUT
# Build
- name: Clone this repo to get find-jruby-head-url.rb
uses: actions/checkout@v4
- uses: ruby/setup-ruby@master
with:
ruby-version: 2.6
- name: Download latest jruby nightly archive
shell: bash
run: |
url=$(ruby find-jruby-head-url.rb)
echo "$url"
curl --fail -L -o jruby-head.tar.gz "$url"
- uses: eregon/clean-path@v1
with:
regexp: '\bruby\b'
- run: tar xf jruby-head.tar.gz
if: "!startsWith(matrix.os, 'windows')"
# Extracting must be done in the native shell: https://github.com/MSP-Greg/ruby-setup-ruby/issues/1
# We need to use to use the system tar, the Git tar seems basically broken
- run: C:\windows\system32\tar.exe xf jruby-head.tar.gz
if: startsWith(matrix.os, 'windows')
- name: Rename to jruby-head
shell: bash
run: |
ls -l jruby-*-SNAPSHOT/bin
mv jruby-*-SNAPSHOT jruby-head
ls -l jruby-head/bin
- name: Add ruby alias
if: "!startsWith(matrix.os, 'windows')"
run: |
cd jruby-head/bin
ln -s jruby ruby
- name: Add ruby alias (Windows)
if: startsWith(matrix.os, 'windows')
shell: bash
run: |
cd jruby-head/bin
# Copy bash launcher, so 'ruby' works in bash
cp jruby ruby
# Create ruby.bat, so 'ruby' works in pwsh
echo -en "@ECHO OFF\r\n@\"%~dp0jruby.exe\" %*\r\n" > ruby.bat
ls -l
- name: Create archive
run: tar czf jruby-head-${{ steps.platform.outputs.platform }}.tar.gz jruby-head
# Test
- run: echo "$PWD/jruby-head/bin" >> $GITHUB_PATH
if: "!startsWith(matrix.os, 'windows')"
- run: echo "$($pwd.Path)\jruby-head\bin" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append
if: startsWith(matrix.os, 'windows')
- run: which ruby
if: "!startsWith(matrix.os, 'windows')"
- run: where.exe ruby
if: startsWith(matrix.os, 'windows')
- run: echo $Env:Path
- run: ruby --version
- run: ruby -e 'raise unless RUBY_ENGINE == %{jruby}'
- run: gem --version
- run: rake --version
- run: ruby -ropen-uri -e 'puts URI.send(:open, %{https://rubygems.org/}) { |f| f.read(1024) }'
- run: gem install json:2.2.0 --no-document
- run: bundle --version
- run: bundle install
- run: bundle exec rake --version
- name: Upload Built Ruby
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: gh release upload "${{ needs.release.outputs.tag }}" "jruby-head-${{ steps.platform.outputs.platform }}.tar.gz"
publish:
name: Publish Release
needs: [release, build]
runs-on: ubuntu-latest
steps:
- name: Publish Release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: gh release edit "${{ needs.release.outputs.tag }}" --draft=false
- uses: eregon/keep-last-n-releases@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
n: 3
remove_tags_without_release: true