Release RubyGem #10
This file contains 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: Release RubyGem | |
on: workflow_dispatch | |
env: | |
SUPPORTED_RUBY_VERSIONS: "3.1,3.2,3.3" | |
LATEST_RUBY_VERSION: "3.3" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: Build native gems | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
platform: | |
- aarch64-linux | |
- arm64-darwin | |
- x86_64-darwin | |
- x86_64-linux | |
- x86_64-linux-musl | |
- x64-mingw-ucrt | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: oxidize-rb/actions/setup-ruby-and-rust@v1 | |
with: | |
ruby-version: "${{ env.LATEST_RUBY_VERSION }}" | |
bundler-cache: false | |
cargo-cache: true | |
cargo-vendor: true | |
cache-version: v1-${{ matrix.platform }} | |
- uses: oxidize-rb/actions/cross-gem@main | |
id: cross-gem | |
with: | |
platform: ${{ matrix.platform }} | |
ruby-versions: "${{ env.SUPPORTED_RUBY_VERSIONS }}" | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: cross-gem | |
path: ${{ steps.cross-gem.outputs.gem-path }} | |
- name: Display structure of built gems | |
run: ls -R | |
working-directory: pkg/ | |
- name: Smoke gem install | |
if: matrix.platform == 'x86_64-linux' # GitHub actions architecture | |
run: | | |
gem install pkg/reprise-*.gem --verbose | |
echo "✅ Gem installed successfully" | |
release: | |
name: Release | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: oxidize-rb/actions/setup-ruby-and-rust@v1 | |
with: | |
ruby-version: "${{ env.LATEST_RUBY_VERSION }}" | |
bundler-cache: true | |
cargo-cache: true | |
cache-version: v1 | |
# It seems that v4 is not compatible with how artifacts are uploaded by | |
# oxidize-rb/cross-gem. So this must stay as v3 until the issue | |
# below is fixed. | |
# See https://github.com/oxidize-rb/actions/issues/27, for more details. | |
- uses: actions/download-artifact@v3 | |
with: | |
name: cross-gem | |
path: pkg | |
- name: Push Gem | |
working-directory: pkg/ | |
env: | |
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} | |
run: | | |
mkdir -p $HOME/.gem | |
touch $HOME/.gem/credentials | |
chmod 0600 $HOME/.gem/credentials | |
printf -- "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}\n" > $HOME/.gem/credentials | |
ls -l | |
for i in *.gem; do | |
if [ -f "$i" ]; then | |
if ! gem push "$i" >push.out; then | |
gemerr=$? | |
sed 's/^/::error:: /' push.out | |
if ! grep -q "Repushing of gem" push.out; then | |
exit $gemerr | |
fi | |
fi | |
fi | |
done | |
- name: Get Version | |
id: get-version | |
run: | | |
version=$(grep VERSION lib/reprise/version.rb |rev |cut -d '"' -f2 |rev) | |
echo "version=$version" >> $GITHUB_OUTPUT | |
echo "Found version $version from lib/reprise/version.rb" | |
- name: Create GitHub release | |
uses: ncipollo/release-action@v1 | |
id: create-release | |
with: | |
artifacts: "pkg/*" | |
allowUpdates: true | |
generateReleaseNotes: true | |
draft: true | |
omitBodyDuringUpdate: true | |
omitNameDuringUpdate: true | |
omitPrereleaseDuringUpdate: true | |
skipIfReleaseExists: true | |
tag: ${{ steps.get-version.outputs.version }} | |
token: ${{ secrets.GITHUB_TOKEN }} |