From 7fb5261783bc975fdde6894a8c7f4ef778a19189 Mon Sep 17 00:00:00 2001 From: Matthew Strapp Date: Wed, 30 Oct 2024 15:01:13 -0500 Subject: feat: Ruby (#33) * bundle gem locusts Signed-off-by: Matt Strapp * Add changeset and flesh out gemspec Signed-off-by: Matt Strapp * Oops Signed-off-by: Matt Strapp * nothing Signed-off-by: Matt Strapp * actually draw the owl Signed-off-by: Matt Strapp * oops Signed-off-by: Matt Strapp * oops 2 Signed-off-by: Matt Strapp --------- Signed-off-by: Matt Strapp --- .github/workflows/ruby.yml | 81 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 .github/workflows/ruby.yml (limited to '.github/workflows/ruby.yml') diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml new file mode 100644 index 0000000..cbe07e1 --- /dev/null +++ b/.github/workflows/ruby.yml @@ -0,0 +1,81 @@ +name: Ruby + +on: + push: + paths: + - "**.rb" + - "**.gemspec" + - "Gemfile" + - "Gemfile.lock" + - "Rakefile" + - ".github/workflows/ruby.yml" + pull_request: + paths: + - "**.rb" + - "**.gemspec" + - "Gemfile" + - "Gemfile.lock" + - "Rakefile" + - ".github/workflows/ruby.yml" + +jobs: + build-and-test: + runs-on: ubuntu-latest + name: Ruby + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.3 + bundler-cache: true + - name: Build and test with Rake + run: bundle exec rake + + publish-preview: + runs-on: ubuntu-latest + needs: build-and-test + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + name: Publish Preview to GitHub Package Registry + permissions: + packages: write + contents: read + steps: + - uses: actions/checkout@v4 + - name: Set version to pre-release + run: sed "s/$(jq -r .version package.json)/$(jq -r .version package.json).pre/" locusts.gemspec -i + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.3 + bundler-cache: true + - name: Build gem + run: bundle exec rake build + - name: Set up GitHub Package Registry for RubyGems + run: | + mkdir -p ~/.gem + touch ~/.gem/credentials + chmod 0600 ~/.gem/credentials + echo ":github: Bearer ${{ secrets.GITHUB_TOKEN }}" >> ~/.gem/credentials + - name: Publish gem + run: gem push --key github --host https://rubygems.pkg.github.com/locusts-r-us pkg/*.gem + + publish-release: + name: Push gem to RubyGems.org + needs: build-and-test + if: ${{ github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/') }} + runs-on: ubuntu-latest + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + steps: + # Set up + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + ruby-version: 3.3 + - name: Build gem + run: bundle exec rake build + - name: Publish gem + run: gem push pkg/*.gem \ No newline at end of file -- cgit v1.2.3