-
Notifications
You must be signed in to change notification settings - Fork 4
139 lines (127 loc) · 4.79 KB
/
gem-push.yml
File metadata and controls
139 lines (127 loc) · 4.79 KB
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
name: Ruby Gem
on:
push:
pull_request:
schedule:
# * is a special character in YAML so you have to quote this string, runs once a week o Sunday at 04:00 UTC
- cron: '0 4 * * 0'
jobs:
test:
name: Test
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
# ruby: ['2.6', '3.1', '3.3', '3.4', head, jruby-9.3.15, jruby, jruby-head, truffleruby, truffleruby-head]
# truffleruby, truffleruby-head fully excluded because of incompatibility with most current bundler releases
# jruby-9.4.12.0 is used to run test with Java 8
ruby: ['2.6', '2.7', '3.1', '3.2', '3.4', head, jruby-9.4.12.0, jruby, jruby-head]
exclude:
# Exclude combinations of os and version
- os: windows-latest
ruby: truffleruby
- os: windows-latest
ruby: truffleruby-head
runs-on: ${{ matrix.os }}
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v5
- name: Set up JDK 21 if jruby-head or jruby is used which is JRuby 10++ now
if: matrix.ruby == 'jruby-head' || matrix.ruby == 'jruby'
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
# see https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: false # runs 'bundle install' and caches installed gems automatically
- name: Run tests
env:
DEBUG: true
run: |
# !!! These commands must be executable in windows, macos and linux !!!
# Use the last version of bundler that supports Ruby < 3.0
java -version
ruby --version
ruby -e "puts 'Ruby platform = ' + RUBY_PLATFORM"
gem install bundler -v 2.4.22
bundle --version
which bundler
gem update bundler
bundle --version
which bundler
bundle install
bundle exec rake test 2>&1 | tee log/test.log
- name: Archive test log
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}_${{ matrix.ruby }}
path: |
log/test.log
test_*.jar
build:
name: Build + Publish
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/main'
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v5
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'
- name: Build
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem build jarbler.gemspec
JARBLER_RELEASE=`ls jarbler-*.gem | sed 's/jarbler-//' | sed 's/\.gem//'`
echo "JARBLER_RELEASE=$JARBLER_RELEASE" >> $GITHUB_ENV
# Ensure that exit code != 0 does not stop the build
set +e
echo "Check for existing release tag"
gh release view $JARBLER_RELEASE -R ${{ github.repository }}
if [[ $? -eq 0 ]]; then
echo "Github release tag $JARBLER_RELEASE already exists"
else
echo "Github release tag $JARBLER_RELEASE does not exist yet"
gh release create $JARBLER_RELEASE "./jarbler-${JARBLER_RELEASE}.gem#jarbler-${JARBLER_RELEASE}.gem: use also 'gem install jarbler'" --notes "Continuous development" --title "Jarbler $JARBLER_RELEASE"
if [ $? -eq 0 ]; then
echo "Release created"
else
echo "gh release create failed"
exit 1
fi
fi
echo "Checking rubygems.org for RELEASE=$JARBLER_RELEASE"
gem search jarbler | grep jarbler | grep $JARBLER_RELEASE
if [[ $? -eq 0 ]]; then
echo "RELEASE=$JARBLER_RELEASE already exists on rubygems.org, no push executed"
else
echo "RELEASE=$JARBLER_RELEASE does not exist on rubygems.org yet"
echo "Manual execution of 'gem push jarbler-${JARBLER_RELEASE}.gem' required! This will fix the CI at next run"
echo "Download the release from Github and execute 'gem push jarbler-${JARBLER_RELEASE}.gem'"
exit 1
# rdoc --all --ri --op doc
# gem push *.gem
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# GH_TOKEN: ${{ github.token }}
# GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
- name: Put gem file into artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: jarbler-${{ env.JARBLER_RELEASE }}.gem
path: jarbler-${{ env.JARBLER_RELEASE }}.gem