-
Notifications
You must be signed in to change notification settings - Fork 31
132 lines (109 loc) · 4.56 KB
/
release-ruby-wrapper.yml
File metadata and controls
132 lines (109 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Build and Publish Native Ruby Gem
on:
workflow_dispatch:
jobs:
build-shared-library-binaries:
strategy:
matrix:
os: [ubuntu-latest, macos-13, windows-latest]
include:
# Config for Linux
- os: ubuntu-latest
platform_tasks: "compile:aarch64-linux compile:x86_64-linux"
artifact_name: "linux-binaries"
artifact_path: "spannerlib/wrappers/spannerlib-ruby/lib/spannerlib/*-linux/"
# Config for macOS (Apple Silicon + Intel)
# Note: macos-13 is an Intel runner (x86_64) but can cross-compile to Apple Silicon (aarch64)
- os: macos-13
platform_tasks: "compile:aarch64-darwin compile:x86_64-darwin"
artifact_name: "darwin-binaries"
artifact_path: "spannerlib/wrappers/spannerlib-ruby/lib/spannerlib/*-darwin/"
# Config for Windows
- os: windows-latest
platform_tasks: "compile:x64-mingw32"
artifact_name: "windows-binaries"
artifact_path: "spannerlib/wrappers/spannerlib-ruby/lib/spannerlib/x64-mingw32/"
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: 1.26.x
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4.8'
bundler-cache: true
working-directory: 'spannerlib/wrappers/spannerlib-ruby'
- name: Install cross-compilers (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
# GCC cross toolchain and binutils for aarch64
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
# Mingw-w64 cross toolchain for Windows target (x86_64)
sudo apt-get install -y gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64
echo "=== cross compiler versions ==="
aarch64-linux-gnu-gcc --version || true
aarch64-linux-gnu-g++ --version || true
x86_64-w64-mingw32-gcc --version || true
which aarch64-linux-gnu-gcc || true
which x86_64-w64-mingw32-gcc || true
# The cross-compiler step for macOS is removed,
# as the built-in Clang on macOS runners can handle both Intel and ARM.
- name: Compile Binaries
working-directory: spannerlib/wrappers/spannerlib-ruby
run: |
# This runs the specific Rake tasks for this OS
# e.g., "rake compile:aarch64-linux compile:x86_64-linux"
bundle exec rake ${{ matrix.platform_tasks }}
- name: Upload Binaries as Artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.artifact_path }}
publish:
name: Package and Publish Gem
# This job runs only after all 'build' jobs have succeeded
needs: build-shared-library-binaries
runs-on: ubuntu-latest
# This gives the job permission to publish to RubyGems
permissions:
id-token: write
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4.8'
bundler-cache: true
working-directory: 'spannerlib/wrappers/spannerlib-ruby'
- name: Download all binaries
uses: actions/download-artifact@v8
with:
# No name means it downloads ALL artifacts from this workflow
# The binaries will be placed in their original paths
path: spannerlib/wrappers/spannerlib-ruby/lib/spannerlib/
- name: List downloaded files (for debugging)
run: ls -R spannerlib/wrappers/spannerlib-ruby/lib/spannerlib/
- name: Build Gem
working-directory: spannerlib/wrappers/spannerlib-ruby
run: gem build spannerlib-ruby.gemspec
- name: Publish to RubyGems
working-directory: spannerlib/wrappers/spannerlib-ruby
run: |
# Make all built .gem files available to be pushed
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
# This uses the new "Trusted Publishing" feature.
# https://guides.rubygems.org/publishing/#publishing-with-github-actions
printf -- "---\n:rubygems_api_key: Bearer ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
# Push the gem
gem push *.gem
env:
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}