├── Gemfile ├── trigger.sh ├── test └── Gemfile ├── .github ├── dependabot.yml └── workflows │ └── build.yml ├── README.md ├── find-jruby-head-url-nokogiri.rb └── LICENSE /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'nokogiri' 4 | -------------------------------------------------------------------------------- /trigger.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | tag=v$(date +%Y%m%d.%H%M%S) 3 | git tag "$tag" 4 | git push origin "$tag" 5 | -------------------------------------------------------------------------------- /test/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'rake' 4 | gem 'path' 5 | gem 'json', '2.2.0' 6 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: 'github-actions' 4 | directory: '/' 5 | schedule: 6 | interval: 'weekly' 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JRuby Dev Builds for GitHub Actions 2 | 3 | These builds are only meant to be used inside GitHub Actions with 4 | [ruby/setup-ruby](https://github.com/ruby/setup-ruby). 5 | 6 | Please report issues to [ruby/setup-ruby](https://github.com/ruby/setup-ruby). 7 | 8 | They might not work in any other environment. 9 | -------------------------------------------------------------------------------- /find-jruby-head-url-nokogiri.rb: -------------------------------------------------------------------------------- 1 | require 'open-uri' 2 | require 'rubygems' 3 | require 'nokogiri' 4 | 5 | base_url = 'https://central.sonatype.com/repository/maven-snapshots/org/jruby/jruby-dist' 6 | index_url = "#{base_url}/maven-metadata.xml" 7 | 8 | STDERR.puts index_url 9 | xml = URI.open(index_url, &:read) 10 | STDERR.puts xml 11 | 12 | versions = Nokogiri::XML(xml).css('version').map(&:text) 13 | 14 | versions.delete('9000.dev-SNAPSHOT') 15 | most_recent = versions.max_by { |v| Gem::Version.new(v) } 16 | 17 | builds_url = "#{base_url}/#{most_recent}/maven-metadata.xml" 18 | STDERR.puts builds_url 19 | xml = URI.open(builds_url, &:read) 20 | STDERR.puts xml 21 | 22 | last_build = Nokogiri::XML(xml).css('snapshotVersion').select { |node| 23 | classifier = node.at('classifier') 24 | classifier and classifier.text == 'bin' and node.at('extension').text == 'tar.gz' 25 | }.map { |node| node.at('value').text }.last 26 | 27 | final_url = "#{base_url}/#{most_recent}/jruby-dist-#{last_build}-bin.tar.gz" 28 | puts final_url 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Benoit Daloze 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: JRuby Dev Builds 2 | on: 3 | workflow_dispatch: 4 | push: 5 | tags: 6 | - '*' 7 | schedule: 8 | - cron: '0 19 * * *' 9 | jobs: 10 | prepare: 11 | name: Check if the latest jruby snapshot is already built 12 | runs-on: ubuntu-latest 13 | outputs: 14 | should_build: ${{ steps.check_commit.outputs.result }} 15 | url: ${{ steps.url.outputs.url }} 16 | steps: 17 | - name: Clone to get find-jruby-head-url-nokogiri.rb 18 | uses: actions/checkout@v6 19 | - uses: ruby/setup-ruby@v1 20 | with: 21 | ruby-version: ruby 22 | bundler-cache: true 23 | - name: Get latest jruby nightly archive url 24 | id: url 25 | run: | 26 | echo "url=$(bundle exec ruby find-jruby-head-url-nokogiri.rb)" | tee -a "$GITHUB_OUTPUT" 27 | - name: Check if latest commit already built 28 | uses: actions/github-script@v8 29 | id: check_commit 30 | with: 31 | script: | 32 | const latestSnapshotUrl = "${{ steps.url.outputs.url }}" 33 | const { owner, repo } = context.repo 34 | let { data: release } = await github.rest.repos.getLatestRelease({ owner, repo }) 35 | const latestTaggedUrl = release.body.split(/\s+/)[1] 36 | console.log(`Latest snapshot url: ${latestSnapshotUrl}`) 37 | console.log(`Latest tagged url: ${latestTaggedUrl}`) 38 | if (latestSnapshotUrl === latestTaggedUrl) { 39 | return 'false' 40 | } else { 41 | return 'true' 42 | } 43 | result-encoding: string 44 | 45 | release: 46 | name: Create GitHub Release 47 | needs: [prepare] 48 | if: needs.prepare.outputs.should_build == 'true' 49 | runs-on: ubuntu-latest 50 | outputs: 51 | tag: ${{ steps.tag.outputs.tag }} 52 | steps: 53 | - uses: actions/checkout@v6 54 | with: 55 | fetch-depth: 0 56 | if: github.event_name != 'push' 57 | 58 | - name: Set tag name 59 | id: tag 60 | run: | 61 | if [[ "${{ github.event_name }}" != "push" ]]; then 62 | tag=v$(date +%Y%m%d.%H%M%S) 63 | else 64 | tag=$(basename "${{ github.ref }}") 65 | fi 66 | echo "tag=$tag" >> $GITHUB_OUTPUT 67 | - name: Create Release 68 | env: 69 | GH_TOKEN: ${{ github.token }} 70 | GH_REPO: ${{ github.repository }} 71 | run: | 72 | tag="${{ steps.tag.outputs.tag }}" 73 | gh release create --draft "$tag" --title "$tag" 74 | 75 | build: 76 | needs: [prepare, release] 77 | strategy: 78 | fail-fast: false 79 | matrix: 80 | os: [ ubuntu-22.04, ubuntu-24.04, ubuntu-22.04-arm, ubuntu-24.04-arm, macos-15-intel, macos-14, windows-2022, windows-11-arm ] 81 | runs-on: ${{ matrix.os }} 82 | outputs: 83 | commit: ${{ steps.latest_commit.outputs.commit }} 84 | steps: 85 | - name: Set platform 86 | id: platform 87 | shell: bash 88 | run: | 89 | platform=${{ matrix.os }} 90 | platform=${platform/macos-15-intel/darwin-x64} 91 | platform=${platform/macos-14/darwin-arm64} 92 | platform=${platform/%.04/.04-x64} 93 | platform=${platform/%.04-arm/.04-arm64} 94 | platform=${platform/windows-2022/windows-x64} 95 | platform=${platform/windows-11-arm/windows-arm64} 96 | echo "platform=$platform" >> $GITHUB_OUTPUT 97 | 98 | # Build 99 | - name: Clone to get test/Gemfile 100 | uses: actions/checkout@v6 101 | - name: Download latest jruby nightly archive 102 | shell: bash 103 | run: curl --fail -L -o jruby-head.tar.gz "${{ needs.prepare.outputs.url }}" 104 | - uses: eregon/clean-path@v1 105 | with: 106 | regexp: '\bruby\b' 107 | - run: tar xf jruby-head.tar.gz 108 | if: "!startsWith(matrix.os, 'windows')" 109 | # NOTE: Keep the logic from here in sync with ruby-builder's buildJRubyWindows job 110 | # Extracting must be done in the native shell: https://github.com/MSP-Greg/ruby-setup-ruby/issues/1 111 | # We need to use to use the system tar, the Git tar seems basically broken. 112 | # And `mv dir /c/...` also removes jruby.exe, so we need to avoid that. 113 | - run: C:\windows\system32\tar.exe xf jruby-head.tar.gz 114 | if: startsWith(matrix.os, 'windows') 115 | - name: Check bin/ and rename to jruby-head 116 | shell: bash 117 | run: | 118 | ls -l jruby-*-SNAPSHOT/bin 119 | mv jruby-*-SNAPSHOT jruby-head 120 | ls -l jruby-head/bin 121 | - name: Create archive 122 | run: tar czf jruby-head-${{ steps.platform.outputs.platform }}.tar.gz jruby-head 123 | 124 | # Test 125 | - run: echo "$PWD/jruby-head/bin" >> $GITHUB_PATH 126 | if: "!startsWith(matrix.os, 'windows')" 127 | - run: echo "$($pwd.Path)\jruby-head\bin" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append 128 | if: startsWith(matrix.os, 'windows') 129 | - run: which ruby 130 | if: "!startsWith(matrix.os, 'windows')" 131 | - run: where.exe ruby 132 | if: startsWith(matrix.os, 'windows') 133 | - run: echo $Env:Path 134 | 135 | # JAVA_HOME_21_AARCH64 - https://github.com/actions/partner-runner-images/blob/main/images/arm-windows-11-image.md#java 136 | # JAVA_HOME_21_arm64 - https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#java 137 | # JAVA_HOME_21_X64 - https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md#java 138 | - name: switch to Java 21 for verification 139 | run: echo "JAVA_HOME=${JAVA_HOME_21_AARCH64:-${JAVA_HOME_21_arm64:-${JAVA_HOME_21_X64:-}}}" >> "$GITHUB_ENV" 140 | shell: bash 141 | - run: ruby --version 142 | - run: ruby -e 'raise unless RUBY_ENGINE == %{jruby}' 143 | - run: gem --version 144 | - run: rake --version 145 | - run: ruby -ropen-uri -e 'puts URI.send(:open, %{https://rubygems.org/}) { |f| f.read(1024) }' 146 | - run: gem install json:2.2.0 --no-document 147 | - run: bundle --version 148 | working-directory: test 149 | - run: bundle install 150 | working-directory: test 151 | - run: bundle exec rake --version 152 | working-directory: test 153 | 154 | - name: Set latest_commit 155 | id: latest_commit 156 | run: echo "commit=$(ruby -e 'puts JRUBY_REVISION')" >> $GITHUB_OUTPUT 157 | 158 | - name: Upload Built Ruby 159 | env: 160 | GH_TOKEN: ${{ github.token }} 161 | GH_REPO: ${{ github.repository }} 162 | shell: bash 163 | run: | 164 | gh release upload "${{ needs.release.outputs.tag }}" "jruby-head-${{ steps.platform.outputs.platform }}.tar.gz" 165 | 166 | publish: 167 | name: Publish Release 168 | needs: [prepare, release, build] 169 | runs-on: ubuntu-latest 170 | steps: 171 | - name: Publish Release 172 | env: 173 | GH_TOKEN: ${{ github.token }} 174 | GH_REPO: ${{ github.repository }} 175 | run: | 176 | body="jruby/jruby@${{ needs.build.outputs.commit }} ${{ needs.prepare.outputs.url }}" 177 | gh release edit "${{ needs.release.outputs.tag }}" --draft=false --notes "$body" 178 | - uses: eregon/keep-last-n-releases@v1 179 | env: 180 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 181 | with: 182 | n: 3 183 | remove_tags_without_release: false 184 | --------------------------------------------------------------------------------