7
7
schedule :
8
8
- cron : ' 0 19 * * *'
9
9
jobs :
10
+ prepare :
11
+ name : Check if the latest ruby commit is already built
12
+ runs-on : ubuntu-latest
13
+ outputs :
14
+ should_build : ${{ steps.check_commit.outputs.result }}
15
+ commit : ${{ steps.latest_commit.outputs.commit }}
16
+ steps :
17
+ - name : Clone ruby
18
+ uses : actions/checkout@v3
19
+ with :
20
+ repository : ruby/ruby
21
+ path : ruby
22
+ - name : Set latest_commit
23
+ id : latest_commit
24
+ working-directory : ruby
25
+ run : echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
26
+
27
+ - name : Check if latest commit already built
28
+ uses : actions/github-script@v6
29
+ id : check_commit
30
+ with :
31
+ script : |
32
+ const latestDevCommit = "${{ steps.latest_commit.outputs.commit }}"
33
+ const { owner, repo } = context.repo
34
+ let { data: release } = await github.rest.repos.getLatestRelease({ owner, repo })
35
+ const latestReleaseCommit = release.body.split('@')[1]
36
+ console.log(`Latest release commit: ${latestReleaseCommit}`)
37
+ console.log(`Latest ruby commit: ${latestDevCommit}`)
38
+ if (latestReleaseCommit === latestDevCommit) {
39
+ return 'false'
40
+ } else {
41
+ return 'true'
42
+ }
43
+ result-encoding : string
44
+
10
45
release :
11
46
name : Create GitHub Release
47
+ needs : [prepare]
48
+ if : needs.prepare.outputs.should_build == 'true'
12
49
runs-on : ubuntu-latest
13
50
outputs :
14
- release_id : ${{ steps.create_release.outputs.id }}
15
- upload_url : ${{ steps.create_release.outputs.upload_url }}
51
+ tag : ${{ steps.tag.outputs.tag }}
16
52
steps :
17
53
- uses : actions/checkout@v3
18
54
with :
@@ -29,33 +65,37 @@ jobs:
29
65
fi
30
66
echo "tag=$tag" >> $GITHUB_OUTPUT
31
67
- name : Create Release
32
- id : create_release
33
- uses : actions/create-release@v1
34
68
env :
35
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
69
+ GH_TOKEN : ${{ github.token }}
36
70
GH_REPO : ${{ github.repository }}
37
- with :
38
- tag_name : ${{ steps.tag.outputs.tag }}
39
- release_name : ${{ steps.tag.outputs.tag }}
40
- draft : true
41
- prerelease : false
71
+ run : |
72
+ tag="${{ steps.tag.outputs.tag }}"
73
+ body="ruby/ruby@${{ needs.prepare.outputs.commit }}"
74
+ gh release create --draft "$tag" --title "$tag" --notes "$body"
42
75
43
76
build :
44
- needs : [release]
77
+ needs : [prepare, release]
45
78
strategy :
46
79
fail-fast : false
47
80
matrix :
48
81
os : [ ubuntu-20.04, ubuntu-22.04, macos-11 ]
49
82
name : [ head, debug ]
50
83
runs-on : ${{ matrix.os }}
51
84
steps :
85
+ - name : Clone ruby
86
+ uses : actions/checkout@v3
87
+ with :
88
+ repository : ruby/ruby
89
+ ref : ${{ needs.prepare.outputs.commit }}
90
+
52
91
- name : Set platform
53
92
id : platform
54
93
run : |
55
94
platform=${{ matrix.os }}
56
95
platform=${platform/macos-*/macos-latest}
57
96
echo "platform=$platform" >> $GITHUB_OUTPUT
58
97
98
+ # Build
59
99
- name : apt-get update on Ubuntu
60
100
run : sudo apt-get update
61
101
if : startsWith(matrix.os, 'ubuntu')
@@ -71,11 +111,6 @@ jobs:
71
111
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off
72
112
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate
73
113
74
- - name : Clone Ruby
75
- uses : actions/checkout@v3
76
- with :
77
- repository : ruby/ruby
78
-
79
114
# ENABLE_PATH_CHECK=0: https://github.com/actions/virtual-environments/issues/267
80
115
- name : Set configure flags (head)
81
116
run : |
@@ -122,25 +157,21 @@ jobs:
122
157
run : ruby -e 'p RbConfig::CONFIG["cppflags"]; def Warning.warn(s); raise s; end; system RbConfig.ruby, "-e", "p :OK"'
123
158
124
159
- name : Upload Built Ruby
125
- uses : actions/upload-release-asset@v1
126
160
env :
127
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
128
- with :
129
- upload_url : ${{ needs.release.outputs.upload_url }}
130
- asset_path : ruby-${{ matrix.name }}-${{ steps.platform.outputs.platform }}.tar.gz
131
- asset_name : ruby-${{ matrix.name }}-${{ steps.platform.outputs.platform }}.tar.gz
132
- asset_content_type : application/gzip
161
+ GH_TOKEN : ${{ github.token }}
162
+ GH_REPO : ${{ github.repository }}
163
+ run : gh release upload "${{ needs.release.outputs.tag }}" "ruby-${{ matrix.name }}-${{ steps.platform.outputs.platform }}.tar.gz"
133
164
134
- metadata :
165
+ publish :
135
166
name : Publish Release
136
167
needs : [release, build]
137
168
runs-on : ubuntu-latest
138
169
steps :
139
- - uses : eregon/publish-release@v1
170
+ - name : Publish Release
140
171
env :
141
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
142
- with :
143
- release_id : ${{ needs.release.outputs.release_id }}
172
+ GH_TOKEN : ${{ github.token }}
173
+ GH_REPO : ${{ github.repository }}
174
+ run : gh release edit " ${{ needs.release.outputs.tag }}" --draft=false
144
175
- uses : eregon/keep-last-n-releases@v1
145
176
env :
146
177
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments