Skip to content

Commit 0bcd376

Browse files
committed
Add workflow
1 parent fae5d84 commit 0bcd376

File tree

3 files changed

+183
-0
lines changed

3 files changed

+183
-0
lines changed

.github/workflows/build.yml

+173
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
name: JRuby Dev Builds
2+
on:
3+
push:
4+
tags:
5+
- '*'
6+
schedule:
7+
- cron: '0 19 * * *'
8+
jobs:
9+
release:
10+
name: Create GitHub Release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
16+
if: github.event_name == 'schedule'
17+
- name: Create tag
18+
id: create_tag
19+
shell: bash
20+
run: |
21+
if [[ "${{ github.event_name }}" == "schedule" ]]; then
22+
tag=builds-$(date +%Y%m%d-%H%M%S)
23+
else
24+
tag=$(basename "${{ github.ref }}")
25+
fi
26+
echo "::set-output name=tag::$tag"
27+
- name: Create Release
28+
id: create_release
29+
uses: actions/create-release@v1
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
with:
33+
tag_name: ${{ steps.create_tag.outputs.tag }}
34+
release_name: ${{ steps.create_tag.outputs.tag }}
35+
draft: true
36+
prerelease: false
37+
- name: Create artifact files
38+
shell: bash
39+
run: |
40+
mkdir info
41+
echo "${{ steps.create_tag.outputs.tag }}" > info/tag
42+
echo "${{ steps.create_release.outputs.id }}" > info/release_id
43+
echo "${{ steps.create_release.outputs.upload_url }}" > info/upload_url
44+
- uses: actions/upload-artifact@v1
45+
with:
46+
name: info
47+
path: info
48+
49+
build:
50+
needs: [release]
51+
strategy:
52+
fail-fast: false
53+
matrix:
54+
os: [ ubuntu-16.04, ubuntu-18.04, macos-latest, windows-latest ]
55+
runs-on: ${{ matrix.os }}
56+
steps:
57+
- uses: actions/download-artifact@v1
58+
with:
59+
name: info
60+
- name: Set upload_url
61+
id: upload_info
62+
shell: bash
63+
run: |
64+
upload_url=$(cat info/upload_url)
65+
echo "::set-output name=upload_url::$upload_url"
66+
67+
# Build
68+
- uses: actions/checkout@v2
69+
- uses: actions/setup-ruby@v1
70+
with:
71+
ruby-version: '2.6.x'
72+
- name: Download latest jruby nightly archive
73+
shell: bash
74+
run: |
75+
url=$(ruby find-jruby-head-url.rb)
76+
echo "$url"
77+
curl --fail -L -o jruby-head.tar.gz "$url"
78+
- uses: eregon/clean-path@v1
79+
with:
80+
regexp: '\bruby\b'
81+
# Extracting must be done in the native shell: https://github.com/MSP-Greg/ruby-setup-ruby/issues/1
82+
- run: tar xf jruby-head.tar.gz
83+
- name: Rename to jruby-head
84+
shell: bash
85+
run: |
86+
ls -l jruby-*-SNAPSHOT/bin
87+
mv jruby-*-SNAPSHOT jruby-head
88+
ls -l jruby-head/bin
89+
- name: Add ruby alias
90+
if: "!startsWith(matrix.os, 'windows')"
91+
run: |
92+
cd jruby-head/bin
93+
ln -s jruby ruby
94+
- name: Add ruby alias (Windows)
95+
if: startsWith(matrix.os, 'windows')
96+
shell: bash
97+
run: |
98+
cd jruby-head/bin
99+
# Copy bash launcher, so 'ruby' works in bash
100+
cp jruby ruby
101+
# Create ruby.bat, so 'ruby' works in pwsh
102+
echo -en "@ECHO OFF\r\n@\"%~dp0jruby.exe\" %*\r\n" > ruby.bat
103+
- name: Install Bundler if needed
104+
shell: bash
105+
run: |
106+
if [ ! -e jruby-head/bin/bundle ]; then
107+
export PATH="$PWD/jruby-head/bin:$PATH"
108+
gem env
109+
gem install bundler -v '~> 1' --no-document
110+
fi
111+
112+
- name: Create archive
113+
run: tar czf jruby-head-${{ matrix.os }}.tar.gz jruby-head
114+
115+
# Test
116+
- run: echo "::add-path::$PWD/jruby-head/bin"
117+
- run: ruby --version
118+
- run: gem --version
119+
- run: rake --version
120+
- run: ruby -ropen-uri -e 'puts open(%{https://rubygems.org/}) { |f| f.read(1024) }'
121+
- run: gem install json:2.2.0 --no-document
122+
- run: bundle --version
123+
- run: bundle install
124+
- run: bundle exec rake --version
125+
126+
- name: Upload Built Ruby
127+
uses: actions/upload-release-asset@v1
128+
env:
129+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
130+
with:
131+
upload_url: ${{ steps.upload_info.outputs.upload_url }}
132+
asset_path: jruby-head-${{ matrix.os }}.tar.gz
133+
asset_name: jruby-head-${{ matrix.os }}.tar.gz
134+
asset_content_type: application/gzip
135+
136+
metadata:
137+
name: Publish Release
138+
needs: [build]
139+
runs-on: ubuntu-latest
140+
steps:
141+
- uses: actions/checkout@v2
142+
with:
143+
ref: metadata
144+
fetch-depth: 0
145+
- uses: actions/download-artifact@v1
146+
with:
147+
name: info
148+
- name: Set publish_info
149+
id: publish_info
150+
shell: bash
151+
run: |
152+
tag=$(cat info/tag)
153+
release_id=$(cat info/release_id)
154+
echo "::set-output name=tag::$tag"
155+
echo "::set-output name=release_id::$release_id"
156+
- uses: eregon/publish-release@v1
157+
env:
158+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
159+
with:
160+
release_id: ${{ steps.publish_info.outputs.release_id }}
161+
- shell: bash
162+
run: |
163+
echo "${{ steps.publish_info.outputs.tag }}" > latest_build.tag
164+
git config user.name "GitHub Actions"
165+
git config user.email automated@automated.org
166+
git commit -a -m 'Update latest_build.tag'
167+
git push
168+
- uses: eregon/keep-last-n-releases@v1
169+
env:
170+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
171+
with:
172+
n: 3
173+
last_tag_file: latest_build.tag

Gemfile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Used for testing
2+
source 'https://rubygems.org'
3+
4+
gem "rake"
5+
gem "path"
6+
gem "json", "2.2.0"

trigger.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
tag=builds-$(date +%Y%m%d-%H%M%S)
3+
git tag "$tag"
4+
git push origin "$tag"

0 commit comments

Comments
 (0)