build-ruby #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: build | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Release version (e.g., 0.2.7)' | |
| required: false | |
| default: '' | |
| repository_dispatch: | |
| types: [build-ruby] | |
| env: | |
| NIM_VERSION: '2.2.0' | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| max-parallel: 1 | |
| matrix: | |
| include: | |
| - runner: macos-13 | |
| arch: x86_64-darwin | |
| ext: bundle | |
| - runner: macos-latest | |
| arch: arm64-darwin | |
| ext: bundle | |
| - runner: ubuntu-22.04 | |
| arch: x86_64-linux | |
| ext: so | |
| steps: | |
| - name: "Checkout tim-ruby" | |
| uses: actions/checkout@v4 | |
| with: | |
| path: tim-ruby | |
| - name: "Checkout tim (main repo)" | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: tim-engine/tim | |
| token: ${{ secrets.TIM_EXT_PAT }} | |
| path: tim-main | |
| - uses: jiro4989/setup-nim-action@v1 | |
| with: | |
| nim-version: ${{ env.NIM_VERSION }} | |
| - uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.2' | |
| - run: sudo apt-get update && sudo apt-get install -y ruby ruby-dev | |
| if: runner.os == 'Linux' | |
| - name: "Install Clue" | |
| run: nimble install -y clue@#head | |
| working-directory: tim-main | |
| - name: "Build Ruby extension" | |
| run: nimble ruby | |
| working-directory: tim-main | |
| - name: "Copy binary" | |
| run: | | |
| mkdir -p tim-ruby/lib | |
| cp tim-main/build/Tim.bundle "tim-ruby/lib/tim_engine-${{ matrix.arch }}.${{ matrix.ext }}" | |
| - name: "Update gemspec version" | |
| run: | | |
| VERSION="${{ github.event.inputs.version || github.event.client_payload.version }}" | |
| if [ -n "$VERSION" ]; then | |
| cd tim-ruby | |
| sed -i "s/s.version.*=.*\".*\"/s.version = \"${VERSION#v}\"/" tim.gemspec | |
| fi | |
| - name: "Commit and push" | |
| run: | | |
| cd tim-ruby | |
| git config user.name "OpenPeeps Bot" | |
| git config user.email "bot@openpeeps.dev" | |
| VERSION="${{ github.event.inputs.version || github.event.client_payload.version }}" | |
| TAG="" | |
| if [ -n "$VERSION" ]; then | |
| TAG="v${VERSION#v}" | |
| fi | |
| git add -A | |
| git commit -m "Tim Engine ${TAG:-update} (${{ matrix.arch }})" || echo "Nothing to commit" | |
| if [ -n "$TAG" ]; then | |
| git tag -f "$TAG" | |
| fi | |
| git push origin main --tags |