Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 9 additions & 96 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,111 +5,24 @@ on:
- "[0-9]*.[0-9]*.[0-9]*"

jobs:
build_gem:
name: Build source gem
release:
name: Build source gem + create release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby-pkgs@v1
with:
ruby-version: 3.4
- run: sudo apt-get update && sudo apt-get install -y libopencv-dev libvips
ruby-version: "3.4"
- run: gem update --system
- run: rake gem
- name: Upload source gem
uses: actions/upload-artifact@v4
with:
name: libfacedetection.gem
path: pkg/*.gem
retention-days: 1

compile_native_gems:
name: Compile native gem
needs: build_gem
strategy:
matrix:
include:
- os: ubuntu-24.04
platform: x86_64-linux
ruby: "3.4"
- os: ubuntu-24.04-arm
platform: aarch64-linux
ruby: "3.4"
- os: macos-latest
platform: arm64-darwin
ruby: "3.4"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- uses: ruby/setup-ruby-pkgs@v1
with:
ruby-version: ${{ matrix.ruby }}

- name: Install system dependencies on Linux
if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-latest-arm64'
run: sudo apt-get update && sudo apt-get install -y libopencv-dev libvips

- name: Install system dependencies on macOS
if: matrix.os == 'macos-latest'
run: brew install opencv vips

- name: Install gem-compiler
run: gem install gem-compiler

- name: Download source gem
uses: actions/download-artifact@v4
with:
name: libfacedetection.gem
path: pkg/

- name: Compile gem
run: |
SOURCE_GEM=$(ls pkg/*.gem | grep -v -- '-x86_64-linux\|aarch64-linux\|arm64-darwin')
gem compile $SOURCE_GEM --prune

- name: Upload compiled gem
uses: actions/upload-artifact@v4
with:
name: libfacedetection-${{ matrix.platform }}.gem
path: ./*.gem
retention-days: 1

release:
name: Create GitHub Release
needs: compile_native_gems
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Extract version
id: extract_version
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo "GEM_VERSION=$VERSION" >> $GITHUB_ENV

- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Rename gem files with version
run: |
mkdir -p release_gems
for gem in artifacts/libfacedetection-*.gem/*.gem; do
platform=$(basename $gem | sed -E 's/libfacedetection-([^-]+-[^-]+)\.gem/\1/')

# Construct the target filename: NAME-VERSION-PLATFORM.gem
target_filename="libfacedetection-${GEM_VERSION}-${platform}.gem"
target_path="release_gems/$target_filename"
mv "$gem" "$target_path"
done
# Move source gem to release_gems directory
mv artifacts/libfacedetection.gem/*.gem release_gems/libfacedetection-${GEM_VERSION}.gem

run: echo "GEM_VERSION=${GITHUB_REF#refs/tags/}" >> "$GITHUB_ENV"
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.GEM_VERSION }}
files: release_gems/*.gem
tag_name: ${{ github.ref_name }}
name: libfacedetection ${{ env.GEM_VERSION }}
files: pkg/*.gem
generate_release_notes: true