|
1 | 1 | name: JRuby Dev Builds |
2 | 2 | on: |
| 3 | + workflow_dispatch: |
3 | 4 | push: |
4 | 5 | tags: |
5 | 6 | - '*' |
6 | 7 | schedule: |
7 | 8 | - cron: '0 19 * * *' |
8 | 9 | jobs: |
| 10 | + prepare: |
| 11 | + name: Check if the latest jruby 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 jruby |
| 18 | + uses: actions/checkout@v3 |
| 19 | + with: |
| 20 | + repository: jruby/jruby |
| 21 | + path: jruby |
| 22 | + - name: Set latest_commit |
| 23 | + id: latest_commit |
| 24 | + working-directory: jruby |
| 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 jruby commit: ${latestDevCommit}`) |
| 38 | + if (latestReleaseCommit === latestDevCommit) { |
| 39 | + return 'false' |
| 40 | + } else { |
| 41 | + return 'true' |
| 42 | + } |
| 43 | + result-encoding: string |
| 44 | + |
9 | 45 | release: |
10 | 46 | name: Create GitHub Release |
| 47 | + needs: [prepare] |
| 48 | + # We don't build JRuby from the repo commit but from latest maven snapshort, so always run |
| 49 | + # if: needs.prepare.outputs.should_build == 'true' |
11 | 50 | runs-on: ubuntu-latest |
12 | 51 | outputs: |
13 | | - release_id: ${{ steps.create_release.outputs.id }} |
14 | | - upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 52 | + tag: ${{ steps.tag.outputs.tag }} |
15 | 53 | steps: |
16 | | - - uses: actions/checkout@v2 |
| 54 | + - uses: actions/checkout@v3 |
17 | 55 | with: |
18 | 56 | fetch-depth: 0 |
19 | | - if: github.event_name == 'schedule' |
20 | | - - name: Create tag |
21 | | - id: create_tag |
22 | | - shell: bash |
| 57 | + if: github.event_name != 'push' |
| 58 | + |
| 59 | + - name: Set tag name |
| 60 | + id: tag |
23 | 61 | run: | |
24 | | - if [[ "${{ github.event_name }}" == "schedule" ]]; then |
| 62 | + if [[ "${{ github.event_name }}" != "push" ]]; then |
25 | 63 | tag=v$(date +%Y%m%d.%H%M%S) |
26 | 64 | else |
27 | 65 | tag=$(basename "${{ github.ref }}") |
28 | 66 | fi |
29 | 67 | echo "tag=$tag" >> $GITHUB_OUTPUT |
30 | 68 | - name: Create Release |
31 | | - id: create_release |
32 | | - uses: actions/create-release@v1 |
33 | 69 | env: |
34 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
35 | | - with: |
36 | | - tag_name: ${{ steps.create_tag.outputs.tag }} |
37 | | - release_name: ${{ steps.create_tag.outputs.tag }} |
38 | | - draft: true |
39 | | - prerelease: false |
| 70 | + GH_TOKEN: ${{ github.token }} |
| 71 | + GH_REPO: ${{ github.repository }} |
| 72 | + run: | |
| 73 | + tag="${{ steps.tag.outputs.tag }}" |
| 74 | + body="jruby/jruby@${{ needs.prepare.outputs.commit }}" |
| 75 | + gh release create --draft "$tag" --title "$tag" --notes "$body" |
40 | 76 |
|
41 | 77 | build: |
42 | | - needs: [release] |
| 78 | + needs: [prepare, release] |
43 | 79 | strategy: |
44 | 80 | fail-fast: false |
45 | 81 | matrix: |
46 | 82 | os: [ ubuntu-20.04, ubuntu-22.04, macos-11, windows-2019 ] |
47 | 83 | runs-on: ${{ matrix.os }} |
48 | | - env: # https://github.com/jruby/jruby/issues/7182 |
49 | | - JAVA_OPTS: -Djdk.io.File.enableADS=true |
50 | 84 | steps: |
51 | 85 | - name: Set platform |
52 | 86 | id: platform |
|
58 | 92 | echo "platform=$platform" >> $GITHUB_OUTPUT |
59 | 93 |
|
60 | 94 | # Build |
61 | | - - uses: actions/checkout@v2 |
| 95 | + - name: Clone this repo to get find-jruby-head-url.rb |
| 96 | + uses: actions/checkout@v3 |
62 | 97 | - uses: ruby/setup-ruby@v1 |
63 | 98 | with: |
64 | 99 | ruby-version: 2.6 |
@@ -123,25 +158,21 @@ jobs: |
123 | 158 | - run: bundle exec rake --version |
124 | 159 |
|
125 | 160 | - name: Upload Built Ruby |
126 | | - uses: actions/upload-release-asset@v1 |
127 | 161 | env: |
128 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
129 | | - with: |
130 | | - upload_url: ${{ needs.release.outputs.upload_url }} |
131 | | - asset_path: jruby-head-${{ steps.platform.outputs.platform }}.tar.gz |
132 | | - asset_name: jruby-head-${{ steps.platform.outputs.platform }}.tar.gz |
133 | | - asset_content_type: application/gzip |
| 162 | + GH_TOKEN: ${{ github.token }} |
| 163 | + GH_REPO: ${{ github.repository }} |
| 164 | + run: gh release upload "${{ needs.release.outputs.tag }}" "jruby-head-${{ steps.platform.outputs.platform }}.tar.gz" |
134 | 165 |
|
135 | | - metadata: |
| 166 | + publish: |
136 | 167 | name: Publish Release |
137 | 168 | needs: [release, build] |
138 | 169 | runs-on: ubuntu-latest |
139 | 170 | steps: |
140 | | - - uses: eregon/publish-release@v1 |
| 171 | + - name: Publish Release |
141 | 172 | env: |
142 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
143 | | - with: |
144 | | - release_id: ${{ needs.release.outputs.release_id }} |
| 173 | + GH_TOKEN: ${{ github.token }} |
| 174 | + GH_REPO: ${{ github.repository }} |
| 175 | + run: gh release edit "${{ needs.release.outputs.tag }}" --draft=false |
145 | 176 | - uses: eregon/keep-last-n-releases@v1 |
146 | 177 | env: |
147 | 178 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
|
0 commit comments