|
3 | 3 | push: |
4 | 4 | tags: |
5 | 5 | - "[0-9]*.[0-9]*.[0-9]*" |
| 6 | + - "v[0-9]*.[0-9]*.[0-9]*" |
6 | 7 |
|
7 | 8 | jobs: |
8 | | - build_gem: |
| 9 | + build_source_gem: |
9 | 10 | name: Build source gem |
10 | 11 | runs-on: ubuntu-latest |
11 | 12 | steps: |
12 | | - - uses: actions/checkout@v4 |
13 | | - - uses: ruby/setup-ruby-pkgs@v1 |
| 13 | + - uses: actions/checkout@v6.0.2 |
| 14 | + - uses: ruby/setup-ruby@v1 |
14 | 15 | with: |
15 | | - ruby-version: 3.4 |
16 | | - - run: sudo apt-get update && sudo apt-get install -y libopencv-dev libvips |
17 | | - - run: gem update --system |
18 | | - - run: rake gem |
| 16 | + ruby-version: "3.4" |
| 17 | + bundler-cache: true |
| 18 | + - run: bundle exec rake build |
19 | 19 | - name: Upload source gem |
20 | | - uses: actions/upload-artifact@v4 |
| 20 | + uses: actions/upload-artifact@v7.0.0 |
21 | 21 | with: |
22 | | - name: libfacedetection.gem |
| 22 | + name: source-gem |
23 | 23 | path: pkg/*.gem |
24 | 24 | retention-days: 1 |
25 | 25 |
|
26 | | - compile_native_gems: |
27 | | - name: Compile native gem |
28 | | - needs: build_gem |
| 26 | + build_native_gems: |
| 27 | + name: Build native gem (${{ matrix.platform }}) |
| 28 | + runs-on: ubuntu-latest |
29 | 29 | strategy: |
| 30 | + fail-fast: false |
30 | 31 | matrix: |
31 | | - include: |
32 | | - - os: ubuntu-24.04 |
33 | | - platform: x86_64-linux |
34 | | - ruby: "3.4" |
35 | | - - os: ubuntu-24.04-arm |
36 | | - platform: aarch64-linux |
37 | | - ruby: "3.4" |
38 | | - - os: macos-latest |
39 | | - platform: arm64-darwin |
40 | | - ruby: "3.4" |
41 | | - runs-on: ${{ matrix.os }} |
| 32 | + platform: |
| 33 | + - x86_64-linux |
| 34 | + - aarch64-linux |
| 35 | + - x86_64-darwin |
| 36 | + - arm64-darwin |
42 | 37 | steps: |
43 | | - - uses: actions/checkout@v4 |
44 | | - |
45 | | - - uses: ruby/setup-ruby-pkgs@v1 |
46 | | - with: |
47 | | - ruby-version: ${{ matrix.ruby }} |
48 | | - |
49 | | - - name: Install system dependencies on Linux |
50 | | - if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-latest-arm64' |
51 | | - run: sudo apt-get update && sudo apt-get install -y libopencv-dev libvips |
52 | | - |
53 | | - - name: Install system dependencies on macOS |
54 | | - if: matrix.os == 'macos-latest' |
55 | | - run: brew install opencv vips |
56 | | - |
57 | | - - name: Install gem-compiler |
58 | | - run: gem install gem-compiler |
59 | | - |
60 | | - - name: Download source gem |
61 | | - uses: actions/download-artifact@v4 |
| 38 | + - uses: actions/checkout@v6.0.2 |
| 39 | + - uses: ruby/setup-ruby@v1 |
62 | 40 | with: |
63 | | - name: libfacedetection.gem |
64 | | - path: pkg/ |
65 | | - |
66 | | - - name: Compile gem |
67 | | - run: | |
68 | | - SOURCE_GEM=$(ls pkg/*.gem | grep -v -- '-x86_64-linux\|aarch64-linux\|arm64-darwin') |
69 | | - gem compile $SOURCE_GEM --prune |
70 | | -
|
71 | | - - name: Upload compiled gem |
72 | | - uses: actions/upload-artifact@v4 |
| 41 | + ruby-version: "3.4" |
| 42 | + bundler-cache: true |
| 43 | + - name: Build native gems |
| 44 | + run: bundle exec rb-sys-dock --platform ${{ matrix.platform }} --build |
| 45 | + - name: Upload native gems |
| 46 | + uses: actions/upload-artifact@v7.0.0 |
73 | 47 | with: |
74 | | - name: libfacedetection-${{ matrix.platform }}.gem |
75 | | - path: ./*.gem |
| 48 | + name: native-gem-${{ matrix.platform }} |
| 49 | + path: pkg/*-${{ matrix.platform }}.gem |
76 | 50 | retention-days: 1 |
77 | 51 |
|
78 | 52 | release: |
79 | 53 | name: Create GitHub Release |
80 | | - needs: compile_native_gems |
| 54 | + needs: |
| 55 | + - build_source_gem |
| 56 | + - build_native_gems |
81 | 57 | runs-on: ubuntu-latest |
| 58 | + permissions: |
| 59 | + contents: write |
82 | 60 | steps: |
83 | | - - uses: actions/checkout@v4 |
84 | | - |
85 | 61 | - name: Extract version |
86 | | - id: extract_version |
87 | 62 | run: | |
88 | 63 | VERSION=${GITHUB_REF#refs/tags/} |
| 64 | + VERSION=${VERSION#v} |
89 | 65 | echo "GEM_VERSION=$VERSION" >> $GITHUB_ENV |
90 | 66 |
|
91 | 67 | - name: Download all artifacts |
92 | | - uses: actions/download-artifact@v4 |
| 68 | + uses: actions/download-artifact@v8.0.1 |
93 | 69 | with: |
94 | 70 | path: artifacts |
95 | 71 |
|
96 | | - - name: Rename gem files with version |
97 | | - run: | |
98 | | - mkdir -p release_gems |
99 | | - for gem in artifacts/libfacedetection-*.gem/*.gem; do |
100 | | - platform=$(basename $gem | sed -E 's/libfacedetection-([^-]+-[^-]+)\.gem/\1/') |
101 | | -
|
102 | | - # Construct the target filename: NAME-VERSION-PLATFORM.gem |
103 | | - target_filename="libfacedetection-${GEM_VERSION}-${platform}.gem" |
104 | | - target_path="release_gems/$target_filename" |
105 | | - mv "$gem" "$target_path" |
106 | | - done |
107 | | - # Move source gem to release_gems directory |
108 | | - mv artifacts/libfacedetection.gem/*.gem release_gems/libfacedetection-${GEM_VERSION}.gem |
109 | | -
|
110 | 72 | - name: Create release |
111 | 73 | uses: softprops/action-gh-release@v2 |
112 | 74 | with: |
113 | | - tag_name: ${{ env.GEM_VERSION }} |
114 | | - files: release_gems/*.gem |
| 75 | + tag_name: ${{ github.ref_name }} |
| 76 | + name: libfacedetection ${{ env.GEM_VERSION }} |
| 77 | + files: artifacts/**/*.gem |
115 | 78 | generate_release_notes: true |
0 commit comments