Skip to content

.github: build native gem (#20) #72

.github: build native gem (#20)

.github: build native gem (#20) #72

name: Build and release ruby gem
on:
pull_request:
branches: [ master ]
push:
jobs:
build-release-pipeline:
runs-on: ubuntu-latest
steps:
- run: sudo apt-get -y install protobuf-compiler
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.3
bundler-cache: true
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --quiet --default-toolchain=1.73.0 --profile=minimal
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Compile dependencies
run: bundle exec rake compile
- name: Test
run: bundle exec rake spec
- name: Build gem
if: success() && github.ref == 'refs/heads/master'
run: |
bundle exec rake gem:x86_64-linux
echo "::set-output name=gem_version::v$(bundle exec rake version)"
- name: Release to rubygems
if: success() && github.ref == 'refs/heads/master'
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem push pkg/vinted-prometheus-client-mmap-*.gem -V
env:
GEM_HOST_API_KEY: "${{ secrets.RUBYGEMS_AUTH_TOKEN }}"
- name: Tag repo with new gem version
if: success() && github.ref == 'refs/heads/master'
uses: actions/github-script@v3
with:
github-token: ${{ github.token }}
script: |
github.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ steps.build.outputs.gem_version }}",
sha: context.sha
})