1- name : CD
2-
3- on :
4- workflow_run :
5- workflows : [CI]
6- types : [completed]
7- branches : [main]
8-
9- jobs :
10- call-workflow-from-shared-config :
11- uses : rubyatscale/shared-config/.github/workflows/cd.yml@main
12- secrets : inherit
1+ ---
2+ name : CD
3+
4+ on :
5+ workflow_dispatch :
6+ push :
7+ tags : ["v*"]
8+
9+ concurrency :
10+ group : ${{ github.workflow }}-${{ github.ref }}
11+ cancel-in-progress : true
12+
13+ jobs :
14+ ci-data :
15+ runs-on : ubuntu-latest
16+ outputs :
17+ result : ${{ steps.fetch.outputs.result }}
18+ steps :
19+ - id : fetch
20+ uses : oxidize-rb/actions/fetch-ci-data@v1
21+ with :
22+ supported-ruby-platforms : |
23+ # Excluding:
24+ # `arm-linux`: Cranelift doesn't support 32-bit architectures
25+ # `x64-mingw32`: `x64-mingw-ucrt` should be used for Ruby 3.1+ (https://github.com/rake-compiler/rake-compiler-dock?tab=readme-ov-file#windows)
26+ # 3.0 is deprecated as stable ruby version according to:
27+ # https://github.com/oxidize-rb/actions/blob/main/fetch-ci-data/evaluate.rb#L54
28+ exclude: [arm-linux, x64-mingw32]
29+ stable-ruby-versions : |
30+ exclude: [head]
31+
32+ build :
33+ name : Build native gems
34+ needs : ci-data
35+ runs-on : ubuntu-latest
36+ strategy :
37+ fail-fast : false
38+ matrix :
39+ ruby-platform : ${{ fromJSON(needs.ci-data.outputs.result).supported-ruby-platforms }}
40+ steps :
41+ - uses : actions/checkout@v4
42+
43+ - uses : ruby/setup-ruby@v1
44+ with :
45+ ruby-version : " 3.4"
46+
47+ - uses : oxidize-rb/actions/cross-gem@v1
48+ id : cross-gem
49+ with :
50+ platform : ${{ matrix.ruby-platform }}
51+ ruby-versions : ${{ join(fromJSON(needs.ci-data.outputs.result).stable-ruby-versions, ',') }}
52+
53+ - uses : actions/upload-artifact@v4
54+ with :
55+ name : cross-gem-${{ matrix.ruby-platform }}
56+ path : pkg/*-${{ matrix.ruby-platform }}.gem
57+ if-no-files-found : error
58+
59+ - name : Smoke gem install
60+ if : matrix.ruby-platform == 'ignore-for-now-x86_64-linux' # GitHub actions architecture
61+ run : |
62+ gem install pkg/fast_code_owners-*.gem --verbose
63+ script="puts FastCodeOwners::VERSION"
64+ ruby -rfast_code_owners -e "$script" | grep 0.1.0
65+ echo "✅ Successfully gem installed"
66+
67+ release :
68+ name : Release
69+ needs : build
70+ runs-on : ubuntu-latest
71+ steps :
72+ - uses : actions/checkout@v4
73+
74+ - uses : oxidize-rb/actions/setup-ruby-and-rust@v1
75+ with :
76+ ruby-version : " 3.4"
77+ bundler-cache : true
78+ cargo-cache : true
79+ cache-version : v1
80+
81+ - uses : actions/download-artifact@v4
82+ with :
83+ pattern : cross-gem-*
84+ merge-multiple : true
85+ path : pkg/
86+
87+ - name : Package source gem
88+ run : bundle exec rake pkg:ruby
89+
90+ - name : Ensure version matches the tag
91+ run : |
92+ GEM_VERSION=$(grep -Eo "[0-9]+\.[0-9]+\.[0-9]+" lib/fast_code_owners/version.rb | head -n 1)
93+ if [ "v$GEM_VERSION" != "${{ github.ref_name }}" ]; then
94+ echo "Gem version does not match tag"
95+ echo " v$GEM_VERSION != ${{ github.ref_name }}"
96+ exit 1
97+ fi
98+
99+ - name : Push Gem
100+ working-directory : pkg/
101+ env :
102+ GEM_HOST_API_KEY : ${{ secrets.RUBYGEMS_API_KEY }}
103+ run : |
104+ mkdir -p $HOME/.gem
105+ touch $HOME/.gem/credentials
106+ chmod 0600 $HOME/.gem/credentials
107+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
108+ ls -l
109+ for i in *.gem; do
110+ if [ -f "$i" ]; then
111+ if ! gem push "$i" >push.out; then
112+ gemerr=$?
113+ sed 's/^/::error:: /' push.out
114+ if ! grep -q "Repushing of gem" push.out; then
115+ exit $gemerr
116+ fi
117+ fi
118+ fi
119+ done
120+
121+ - name : Create GitHub release
122+ uses : ncipollo/release-action@v1
123+ with :
124+ allowUpdates : true
125+ generateReleaseNotes : true
126+ draft : true
127+ omitBodyDuringUpdate : true
128+ omitNameDuringUpdate : true
129+ omitPrereleaseDuringUpdate : true
130+ skipIfReleaseExists : true
0 commit comments