Skip to content

Commit

Permalink
Add install checks
Browse files Browse the repository at this point in the history
  • Loading branch information
razor-x committed Jan 13, 2023
1 parent 2d5334a commit 7a56152
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 28 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: _build

on:
workflow_call:
inputs:
ruby_version:
description: The Ruby version.
type: string
required: false
default: '3.2.0'
outputs:
artifact_name:
description: The artifact name.
value: build-${{ github.sha }}

jobs:
build:
name: Gem
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup
with:
ruby_version: ${{ inputs.ruby_version }}
- name: Build
run: bundle exec rake build
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: build-${{ github.sha }}
if-no-files-found: error
path: pkg/
8 changes: 6 additions & 2 deletions .github/workflows/_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ name: _publish
on:
workflow_call:
inputs:
artifact_name:
description: The artifact name.
type: string
required: true
registry_key:
description: The gem registry credentials key.
type: string
Expand All @@ -30,10 +34,10 @@ jobs:
with:
install_dependencies: 'false'
gem_credentials: ':${{ inputs.registry_key }}: ${{ secrets.registry_credentials }}'
- name: Download artifacts
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: ${{ github.sha }}
name: ${{ inputs.artifact_name }}
path: pkg/
- name: Publish
run: gem push --key $REGISTRY_KEY --host $REGISTRY_HOST $GEM_ARTIFACTS/*
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,48 @@ jobs:
ruby_version: ${{ matrix.ruby }}
- name: Lint
run: bundle exec rake lint
build:
name: Build
uses: ./.github/workflows/_build.yml
install:
name: Install (Ruby ${{ matrix.ruby }} on ${{ matrix.os_name }})
runs-on: ubuntu-latest
timeout-minutes: 30
needs: build
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
ruby:
- '3.0'
- '3.1'
- '3.2'
include:
- os: ubuntu-latest
os_name: Linux
- os: macos-latest
os_name: macOS
- os: windows-latest
os_name: Windows
steps:
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: ${{ matrix.ruby }}
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: ${{ needs.build.outputs.artifact_name }}
path: .
- name: Install
run: gem install *.gem
- name: Require
run: echo "require '$GEM_REQUIRE_NAME'" > main.rb
env:
GEM_REQUIRE_NAME: makenew-rbgem
- name: Run
run: ruby main.rb
40 changes: 14 additions & 26 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,21 @@ on:
- v*

jobs:
artifacts:
name: Build artifacts
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup
- name: Build
run: bundle exec rake build
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}
if-no-files-found: error
path: pkg/
build:
name: Build
uses: ./.github/workflows/_build.yml
release:
name: GitHub Releases
runs-on: ubuntu-latest
timeout-minutes: 30
needs: artifacts
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download artifacts
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: ${{ github.sha }}
name: ${{ needs.build.outputs.artifact_name }}
path: pkg/
- name: Create GitHub release
uses: softprops/action-gh-release@v1
Expand All @@ -49,20 +35,22 @@ jobs:
rubygems:
name: RubyGems.org
uses: ./.github/workflows/_publish.yml
needs: artifacts
needs: build
with:
registry_key: rubygems
registry_host: https://rubygems.org
artifact_name: ${{ needs.build.outputs.artifact_name }}
registry_key: rubygems
registry_host: https://rubygems.org
secrets:
registry_credentials: ${{ secrets.RUBYGEMS_API_KEY }}
github:
name: GitHub Packages
uses: ./.github/workflows/_publish.yml
permissions:
packages: write
needs: artifacts
needs: build
with:
registry_key: github
registry_host: https://rubygems.pkg.github.com/${{ github.repository_owner }}
artifact_name: ${{ needs.build.outputs.artifact_name }}
registry_key: github
registry_host: https://rubygems.pkg.github.com/${{ github.repository_owner }}
secrets:
registry_credentials: Bearer ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 7a56152

Please sign in to comment.