Skip to content

Commit

Permalink
Refactor Workflows (kyledecot#98)
Browse files Browse the repository at this point in the history
* Refactor Workflows

* Add Rake

* Add Rakefile

* Add Tasks

* Remove bin/publish

* Remove Docker Steps from Workflow
  • Loading branch information
kyledecot authored Jun 16, 2020
1 parent 1dd541c commit 3d9ca69
Show file tree
Hide file tree
Showing 13 changed files with 226 additions and 139 deletions.
152 changes: 152 additions & 0 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
---
name: Default

on:
push:

jobs:
build:
name: Build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.x
- uses: actions/cache@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: ${{ runner.os }}-gems-
- name: Install Bundler
run: gem install bundler
- name: Configure Bundler
run: bundle config path vendor/bundle
- name: Bundle Install
run: bundle install --jobs 4 --retry 3
- name: Set APP_STORE_CONNECT_VERSION
run: echo ::set-env name=APP_STORE_CONNECT_VERSION::$(bundle exec rake version:current)
- name: Build
run: bundle exec rake build
- name: Upload Gem
uses: actions/upload-artifact@v1
with:
name: app_store_connect-${{ env.APP_STORE_CONNECT_VERSION }}.gem
path: app_store_connect-${{ env.APP_STORE_CONNECT_VERSION }}.gem

lint:
name: Lint
runs-on: ubuntu-latest
needs: [build]

steps:
- uses: actions/checkout@v2
- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.x
- uses: actions/cache@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: ${{ runner.os }}-gems-
- name: Install Bundler
run: gem install bundler
- name: Configure Bundler
run: bundle config path vendor/bundle
- name: Bundle Install
run: bundle install --jobs 4 --retry 3
- name: Run Rubocop
run: bundle exec rubocop

test:
name: Test
runs-on: ubuntu-latest
needs: [build]

steps:
- uses: actions/checkout@v2
- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.x
- uses: actions/cache@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: ${{ runner.os }}-gems-
- name: Install Bundler
run: gem install bundler
- name: Configure Bundler
run: bundle config path vendor/bundle
- name: Bundle Install
run: bundle install --jobs 4 --retry 3
- name: Run RSpec
run: bundle exec rake spec

release:
name: Release
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
needs: [test, lint]

steps:
- uses: actions/checkout@v2
- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.x
- uses: actions/cache@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: ${{ runner.os }}-gems-
- name: Install Bundler
run: gem install bundler
- name: Configure Bundler
run: bundle config path vendor/bundle

- name: Configure Gem
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${{secrets.RUBYGEMS_API_KEY}}\n:github: Bearer ${{secrets.PERSONAL_ACCESS_TOKEN}}" > $HOME/.gem/credentials
- name: Bundle Install
run: bundle install --jobs 4 --retry 3
- name: Set APP_STORE_CONNECT_VERSION
run: echo ::set-env name=APP_STORE_CONNECT_VERSION::$(bundle exec rake version:current)
- uses: actions/download-artifact@v1
with:
name: app_store_connect-${{ env.APP_STORE_CONNECT_VERSION }}.gem
path: /tmp
- run: mv /tmp/app_store_connect-${{ env.APP_STORE_CONNECT_VERSION }}.gem .
- name: Push Gem to Rubygems
run: bundle exec rake release[rubygems]
continue-on-error: true
- name: Push Gem to Github Package Registry
run: bundle exec rake release[github]
continue-on-error: true
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: app_store_connect-${{ env.APP_STORE_CONNECT_VERSION }}.gem
asset_name: app_store_connect-${{ env.APP_STORE_CONNECT_VERSION }}.gem
asset_content_type: application/binary

22 changes: 0 additions & 22 deletions .github/workflows/lint.yml

This file was deleted.

40 changes: 0 additions & 40 deletions .github/workflows/publish.yml

This file was deleted.

31 changes: 0 additions & 31 deletions .github/workflows/test.yml

This file was deleted.

4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ GEM
method_source (~> 0.9.0)
public_suffix (3.1.1)
rainbow (3.0.0)
rake (13.0.1)
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
ffi (~> 1.0)
Expand All @@ -94,6 +95,7 @@ GEM
ruby-progressbar (1.10.1)
ruby_dep (1.5.0)
safe_yaml (1.0.5)
semantic (1.6.1)
shellany (0.0.1)
simplecov (0.16.1)
docile (~> 1.1)
Expand Down Expand Up @@ -121,8 +123,10 @@ DEPENDENCIES
factory_bot (~> 5.0.2)
guard-rspec (~> 4.7.3)
pry (~> 0.12)
rake (~> 13.0)
rspec (~> 3.0)
rubocop (~> 0.75.0)
semantic (~> 1.5)
simplecov (~> 0.16.1)
timecop (~> 0.9.1)
webmock (~> 3.6.0)
Expand Down
8 changes: 8 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

require 'rspec/core/rake_task'

Dir.glob('lib/tasks/*.rake').each { |r| load r }

RSpec::Core::RakeTask.new(:spec)
task default: :spec
2 changes: 2 additions & 0 deletions app_store_connect.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'factory_bot', '~> 5.0.2'
spec.add_development_dependency 'guard-rspec', '~> 4.7.3'
spec.add_development_dependency 'pry', '~> 0.12'
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rspec', '~> 3.0'
spec.add_development_dependency 'rubocop', '~> 0.75.0'
spec.add_development_dependency 'semantic', '~> 1.5'
spec.add_development_dependency 'simplecov', '~> 0.16.1'
spec.add_development_dependency 'timecop', '~> 0.9.1'
spec.add_development_dependency 'webmock', '~> 3.6.0'
Expand Down
8 changes: 0 additions & 8 deletions bin/console

This file was deleted.

38 changes: 0 additions & 38 deletions bin/publish

This file was deleted.

8 changes: 8 additions & 0 deletions lib/tasks/build.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

require 'app_store_connect/version'

desc "Build app_store_connect-#{AppStoreConnect::VERSION}.gem"
task :build do
sh %(gem build app_store_connect.gemspec)
end
9 changes: 9 additions & 0 deletions lib/tasks/console.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

require 'pry'
require 'app_store_connect'

desc 'Start a pry console'
task :console do
Pry.start(AppStoreConnect::Client.new)
end
18 changes: 18 additions & 0 deletions lib/tasks/release.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

require 'app_store_connect/version'

version = AppStoreConnect::VERSION

desc "Release app_store_connect-#{version}.gem"
task :release, [:key] do |_task, args|
args.with_defaults(key: 'rubygems')

key = args.key.to_sym
host = {
rubygems: 'https://rubygems.org',
github: 'https://rubygems.pkg.github.com/kyledecot'
}.fetch(key)

sh %(gem push --key=#{key} --host=#{host} app_store_connect-#{version}.gem)
end
Loading

0 comments on commit 3d9ca69

Please sign in to comment.