Open ronaldtse opened 3 months ago
To automate the upload of built runtimes to GitHub releases, you can extend your GitHub Actions workflow. Here's how you can modify the build_runtimes.yml
file to automatically create a release and upload the built runtimes:
name: Build and Release Tebako Runtimes
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
ruby-version: ['3.1.3', '3.2.4', '3.3.3']
include:
- os: ubuntu-latest
arch: x86_64
- os: macos-latest
arch: x86_64
- os: windows-latest
arch: x86_64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Build Tebako Runtime
run: |
ruby -r ./lib/tebako/runtime_manager -e "
repo = Tebako::TebakoRuntimeRepository.new('runtimes')
builder = Tebako::TebakoRuntimeBuilder.new(repo)
builder.build_runtime('${{ matrix.ruby-version }}', '${{ runner.os }}', '${{ matrix.arch }}')
"
- name: Upload Runtime Artifact
uses: actions/upload-artifact@v2
with:
name: tebako-runtime-${{ matrix.ruby-version }}-${{ runner.os }}-${{ matrix.arch }}
path: runtimes/ruby-${{ matrix.ruby-version }}-${{ runner.os }}-${{ matrix.arch }}.tar.gz
- name: Upload Metadata Artifact
uses: actions/upload-artifact@v2
with:
name: tebako-runtime-metadata
path: runtimes/tebako_runtime_metadata.yml
release:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2
- name: Download all workflow run artifacts
uses: actions/download-artifact@v2
- name: Prepare release assets
run: |
mkdir release_assets
cp -r tebako-runtime-*/* release_assets/
cp tebako-runtime-metadata/tebako_runtime_metadata.yml release_assets/
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ github.run_number }}
release_name: Release ${{ github.run_number }}
draft: false
prerelease: false
- name: Upload Release Assets
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./release_assets
asset_name: tebako-runtimes.zip
asset_content_type: application/zip
This updated workflow does the following:
The build
job remains largely the same, building runtimes for each combination of OS, Ruby version, and architecture.
A new release
job is added, which runs after all build
jobs complete.
The release
job:
build
jobs.actions/create-release
action.actions/upload-release-asset
action.The release is created only when there's a push to the main
branch, ensuring that releases are only created for merged changes.
The release is tagged and named using the GitHub run number, which increments automatically with each workflow run.
To use this workflow:
Make sure your repository has the GITHUB_TOKEN
secret available (this is typically provided automatically by GitHub Actions).
Commit this workflow file to your repository in the .github/workflows/
directory.
Push changes to the main
branch or manually trigger the workflow using the "workflow_dispatch" event.
After the workflow runs successfully, a new release will be created with all the built runtimes and the metadata file.
This setup automates the entire process of building, packaging, and releasing Tebako runtimes. Users can then download these runtimes directly from the GitHub releases page, or use the release URL in their TebakoRuntimeManager
to automatically download and use the pre-built runtimes.
Remember to update your TebakoRuntimeManager
to handle downloading from a zip file if you decide to package all assets into a single zip file for the release.
We want to pre-compile the Ruby runtimes on GitHub Actions, in the tebako-runtimes repository.
We need the notion of a "Tebako runtime repository" which will compile Ruby runtimes of:
Each Ruby version needs to be patched to be useable by Tebako.
We need code to manage this, so we can compile Ruby runtimes into a local repository, and load Ruby runtimes from a remote repository.
When the local repository is uploaded to a GitHub repository, we can use it as a remote repository, allowing users to build/customize their own Ruby runtimes (with the necessary Tebako patches, of course).
Let's create a system for managing Tebako runtime repositories, both local and remote. We'll create a
TebakoRuntimeRepository
class that can handle local and remote repositories, and aTebakoRuntimeBuilder
class for compiling Ruby runtimes with Tebako patches.First, let's define the structure:
This implementation provides:
TebakoRuntimeRepository
: Manages a local repository of Ruby runtimes.TebakoRuntimeBuilder
: Builds Ruby runtimes with Tebako patches.TebakoRuntimeManager
: Manages both local and remote repositories, ensuring runtimes are available.To use this system:
To set up the GitHub Actions workflow for building runtimes in the
tebako-runtimes
repository, create a.github/workflows/build_runtimes.yml
file:This workflow will build Ruby runtimes for different versions, operating systems, and architectures. The built runtimes and metadata will be uploaded as artifacts.
To make these runtimes available as a remote repository, you can create a release in the
tebako-runtimes
repository and upload the artifacts to the release. Then, users can use the release URL as the remote repository URL when initializing theTebakoRuntimeManager
.This system allows for building custom Ruby runtimes with Tebako patches, managing them in local repositories, and distributing them via remote repositories (like GitHub releases). Users can either build their own runtimes or download pre-built ones from a remote repository.