Skip to content

Commit 917a1c4

Browse files
committed
refac: padroniza workflow de deployment
1 parent 65591b9 commit 917a1c4

File tree

7 files changed

+73
-72
lines changed

7 files changed

+73
-72
lines changed

.github/workflows/build.yml

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,65 @@ on:
1010
paths-ignore:
1111
- '**.md'
1212
jobs:
13+
Linting:
14+
if: ${{ github.actor != 'dependabot[bot]' }}
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
- name: Setup Ruby
20+
uses: ruby/setup-ruby@v1
21+
with:
22+
ruby-version: '2.7'
23+
bundler-cache: true
24+
- name: Run Install
25+
run: |
26+
sudo apt-get -yqq install libpq-dev
27+
gem update --system --no-document
28+
gem install rake
29+
gem install bundler
30+
bundle install
31+
- name: Run Linter (rubocop)
32+
run: |
33+
bundle exec rubocop --parallel --fail-level warning --display-only-fail-level-offenses --format json -o report.json
1334
Testing:
1435
if: ${{ github.actor != 'dependabot[bot]' }}
36+
name: ${{ matrix.ruby }}
1537
runs-on: ubuntu-latest
38+
env:
39+
COVERAGE_RUBY_VERSION: 2.7
40+
BUNDLE_PATH: vendor/bundle
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
ruby:
45+
- 2.7
46+
- 3.0
47+
- 3.1
48+
- 3.2
1649
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v3
19-
- name: Setup Ruby
20-
uses: ruby/setup-ruby@v1
21-
with:
22-
ruby-version: '3.2.0'
23-
- name: Run Install
24-
run: |
25-
sudo apt-get -yqq install libpq-dev
26-
gem update --system
27-
gem install rake bundler
28-
bundle install
29-
- name: Run Linter (rubocop)
30-
run: bundle exec rubocop
31-
- name: Run Tests (rspec)
32-
run: bundle exec rspec
50+
- name: Checkout
51+
uses: actions/checkout@master
52+
- name: Setup ruby ${{ matrix.ruby }}
53+
uses: ruby/setup-ruby@v1
54+
with:
55+
ruby-version: ${{ matrix.ruby }}
56+
bundler-cache: true
57+
- name: Update rubygems
58+
run: |
59+
gem update --system --no-document
60+
- name: Restore cache
61+
uses: actions/cache@v2
62+
with:
63+
path: ${{ env.BUNDLE_PATH }}
64+
key: ruby-${{ matrix.ruby }}-gems-${{ hashFiles('cnab240_bancoabc.gemspec') }}
65+
restore-keys: |
66+
ruby-${{ matrix.ruby }}-gems-
67+
- name: Prepare environment
68+
run: |
69+
sudo apt-get -y install libsqlite3-dev libxslt1-dev
70+
- name: Install dependencies
71+
run: |
72+
bundle check || bundle install --full-index --jobs 6 --retry 3
73+
- name: Run RSpec
74+
run: bundle exec rspec

.github/workflows/release.yml

Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,12 @@
1-
name: Release
1+
name: Deploy Production
22
on:
33
workflow_dispatch:
44
push:
55
branches:
66
- master
77
jobs:
8-
RubyGems:
9-
runs-on: ubuntu-latest
10-
steps:
11-
- name: Checkout
12-
uses: actions/checkout@v2
13-
- name: Setup Ruby
14-
uses: ruby/setup-ruby@v1
15-
with:
16-
ruby-version: '3.2.0'
17-
- name: Set environment variables
18-
id: vars
19-
run: |
20-
echo ::set-output name=project_name::$(cat .ruby-gemset)
21-
echo ::set-output name=project_version::$(ruby bin/version)
22-
- name: Install dependencies
23-
run: bundle install --full-index --jobs 4 --retry 3
24-
- name: Configure the credentials
25-
run: |
26-
mkdir -p $HOME/.gem
27-
touch $HOME/.gem/credentials
28-
chmod 0600 $HOME/.gem/credentials
29-
printf -- "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}\n:github: Bearer ${GITHUB_KEY}\n" > $HOME/.gem/credentials
30-
env:
31-
GITHUB_KEY: "${{ secrets.GITHUB_TOKEN }}"
32-
RUBYGEMS_API_KEY: "${{ secrets.RUBYGEMS_API_KEY }}"
33-
- name: Build the Gem
34-
run: gem build ${{ steps.vars.outputs.project_name }}.gemspec
35-
- name: Push to the RubyGems
36-
continue-on-error: true
37-
run: gem push ${{ steps.vars.outputs.project_name }}-${{ steps.vars.outputs.project_version }}.gem
38-
- name: Push to the GitHub repository
39-
continue-on-error: true
40-
run: gem push --key github --host https://rubygems.pkg.github.com/Quasar-Flash ${{ steps.vars.outputs.project_name }}-${{ steps.vars.outputs.project_version }}.gem
41-
- name: Get Changelog Entry
42-
id: changelog_reader
43-
uses: mindsers/changelog-reader-action@v2
44-
with:
45-
validation_depth: 10
46-
version: ${{ steps.vars.outputs.project_version }}
47-
path: ./CHANGELOG.md
48-
- name: Create a GitHub release
49-
uses: ncipollo/release-action@v1
50-
with:
51-
tag: v${{ steps.vars.outputs.project_version }}
52-
name: v${{ steps.vars.outputs.project_version }}
53-
body: ${{ steps.changelog_reader.outputs.changes }}
54-
prerelease: ${{ steps.changelog_reader.outputs.status == 'prereleased' }}
55-
draft: ${{ steps.changelog_reader.outputs.status == 'unreleased' }}
56-
allowUpdates: true
57-
token: ${{ secrets.GITHUB_TOKEN }}
8+
Deploying:
9+
uses: Quasar-Flash/workflow-dpl-action/.github/workflows/deployment-ruby-package.yml@master
10+
with:
11+
release: true
12+
secrets: inherit

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ require:
33
- rubocop-performance
44

55
AllCops:
6-
TargetRubyVersion: 3.0
6+
TargetRubyVersion: 2.7
77
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
88
# to ignore them, so only the ones explicitly set in this file are enabled.
99
DisabledByDefault: true

.ruby-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

.version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.1

Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
FROM ruby:3.2.0-bullseye
1+
FROM ruby:latest
2+
3+
ENV TZ="America/Sao_Paulo"
24

35
WORKDIR /src
46

57
COPY . .
68

79
COPY Gemfile ./
810

11+
RUN gem update --system
12+
913
RUN gem install bundler
1014

11-
RUN bundle install --full-index
15+
RUN bundle check || bundle install --full-index --jobs 6 --retry 3
1216

1317
RUN rake install
1418

lib/bigid/auth/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ module Auth
99
# Major - Incremented for incompatible changes with previous release (or big enough new features)
1010
# Minor - Incremented for new backwards-compatible features + deprecations
1111
# Patch - Incremented for backwards-compatible bug fixes
12-
VERSION = "1.0.0"
12+
VERSION = File.read(".version").strip
1313
end
1414
end

0 commit comments

Comments
 (0)