Skip to content

Commit

Permalink
Use the same workflow as truffleruby-dev-builder
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Sep 30, 2023
1 parent 6d82e9b commit 7e809c7
Showing 1 changed file with 66 additions and 32 deletions.
98 changes: 66 additions & 32 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,92 @@
name: JRuby Dev Builds
on:
workflow_dispatch:
push:
tags:
- '*'
schedule:
- cron: '0 19 * * *'
jobs:
prepare:
name: Check if the latest jruby commit is already built
runs-on: ubuntu-latest
outputs:
should_build: ${{ steps.check_commit.outputs.result }}
commit: ${{ steps.latest_commit.outputs.commit }}
steps:
- name: Clone jruby
uses: actions/checkout@v3
with:
repository: jruby/jruby
path: jruby
- name: Set latest_commit
id: latest_commit
working-directory: jruby
run: echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT

- name: Check if latest commit already built
uses: actions/github-script@v6
id: check_commit
with:
script: |
const latestDevCommit = "${{ steps.latest_commit.outputs.commit }}"
const { owner, repo } = context.repo
let { data: release } = await github.rest.repos.getLatestRelease({ owner, repo })
const latestReleaseCommit = release.body.split('@')[1]
console.log(`Latest release commit: ${latestReleaseCommit}`)
console.log(`Latest jruby commit: ${latestDevCommit}`)
if (latestReleaseCommit === latestDevCommit) {
return 'false'
} else {
return 'true'
}
result-encoding: string

release:
name: Create GitHub Release
needs: [prepare]
if: needs.prepare.outputs.should_build == 'true'
runs-on: ubuntu-latest
outputs:
release_id: ${{ steps.create_release.outputs.id }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
tag: ${{ steps.tag.outputs.tag }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
if: github.event_name == 'schedule'
- name: Create tag
id: create_tag
shell: bash
if: github.event_name != 'push'

- name: Set tag name
id: tag
run: |
if [[ "${{ github.event_name }}" == "schedule" ]]; then
if [[ "${{ github.event_name }}" != "push" ]]; then
tag=v$(date +%Y%m%d.%H%M%S)
else
tag=$(basename "${{ github.ref }}")
fi
echo "tag=$tag" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.create_tag.outputs.tag }}
release_name: ${{ steps.create_tag.outputs.tag }}
draft: true
prerelease: false
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
tag="${{ steps.tag.outputs.tag }}"
body="jruby/jruby@${{ needs.prepare.outputs.commit }}"
gh release create --draft "$tag" --title "$tag" --notes "$body"
build:
needs: [release]
needs: [prepare, release]
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04, ubuntu-22.04, macos-11, windows-2019 ]
runs-on: ${{ matrix.os }}
env: # https://github.com/jruby/jruby/issues/7182
JAVA_OPTS: -Djdk.io.File.enableADS=true
steps:
- name: Clone jruby
uses: actions/checkout@v3
with:
repository: jruby/jruby
ref: ${{ needs.prepare.outputs.commit }}

- name: Set platform
id: platform
shell: bash
Expand All @@ -58,7 +97,6 @@ jobs:
echo "platform=$platform" >> $GITHUB_OUTPUT
# Build
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
Expand Down Expand Up @@ -123,25 +161,21 @@ jobs:
- run: bundle exec rake --version

- name: Upload Built Ruby
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: jruby-head-${{ steps.platform.outputs.platform }}.tar.gz
asset_name: jruby-head-${{ steps.platform.outputs.platform }}.tar.gz
asset_content_type: application/gzip
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: gh release upload "${{ needs.release.outputs.tag }}" "jruby-head-${{ steps.platform.outputs.platform }}.tar.gz"

metadata:
publish:
name: Publish Release
needs: [release, build]
runs-on: ubuntu-latest
steps:
- uses: eregon/publish-release@v1
- name: Publish Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ needs.release.outputs.release_id }}
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: gh release edit "${{ needs.release.outputs.tag }}" --draft=false
- uses: eregon/keep-last-n-releases@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down

0 comments on commit 7e809c7

Please sign in to comment.