Skip to content

Commit

Permalink
Technical/Add autoreleasing
Browse files Browse the repository at this point in the history
* Fixed security vulnerability issue CVE-2023-27530
* Added bunch of linters, configs
* Added auto creating release notes on GitHub
* Added auto releasing scripts
* Updated runtime/development dependencies
* Updated CircleCI/CodeClimate configs
* Updated application version, changelog
  • Loading branch information
bestwebua committed Mar 11, 2023
1 parent ecaf8e6 commit a2c73b8
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 35 deletions.
43 changes: 43 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,51 @@ jobs:
command: |
./cc-test-reporter sum-coverage --output - --parts $CIRCLE_NODE_TOTAL coverage/codeclimate.*.json | ./cc-test-reporter upload-coverage --debug --input -
tag:
<<: *defaults

steps:
- checkout

- add_ssh_keys:
fingerprints:
- "4c:59:4d:fb:7a:74:00:7a:8e:e3:72:88:34:fc:6e:74"

- run:
name: Publishing new tag to GitHub
command: |
./.circleci/scripts/tag.sh
release:
<<: *defaults

steps:
- checkout

- add_ssh_keys:
fingerprints:
- "4c:59:4d:fb:7a:74:00:7a:8e:e3:72:88:34:fc:6e:74"

- run:
name: Publishing new release to GitHub
command: |
./.circleci/scripts/release.sh
workflows:
build:
jobs:
- linters
- tests
- tag:
requires:
- linters
- tests
filters:
branches:
only: master
- release:
filters:
branches:
ignore: /.*/
tags:
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
42 changes: 42 additions & 0 deletions .circleci/scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh
set -e

GH_CLI_RELEASES_URL="https://github.com/cli/cli/releases"
FILE_NAME="gh"
BUILD_ARCHITECTURE="linux_amd64.deb"
DELIMETER="_"
PACKAGE_FILE="$FILE_NAME$DELIMETER$BUILD_ARCHITECTURE"

gh_cli_latest_release() {
curl -sL -o /dev/null -w '%{url_effective}' "$GH_CLI_RELEASES_URL/latest" | rev | cut -f 1 -d '/'| rev
}

download_gh_cli() {
test -z "$VERSION" && VERSION="$(gh_cli_latest_release)"
test -z "$VERSION" && {
echo "Unable to get GitHub CLI release." >&2
exit 1
}
curl -s -L -o "$PACKAGE_FILE" "$GH_CLI_RELEASES_URL/download/$VERSION/$FILE_NAME$DELIMETER$(printf '%s' "$VERSION" | cut -c 2-100)$DELIMETER$BUILD_ARCHITECTURE"
}

install_gh_cli() {
sudo dpkg -i "$PACKAGE_FILE"
rm "$PACKAGE_FILE"
}

get_release_candidate_tag() {
git tag --sort=v:refname | grep -E "v[0-9]+\.[0-9]+\.[0-9]+" | tail -n 1
}

RELEASE_CANDIDATE_TAG=$(get_release_candidate_tag)

release_to_github() {
echo "Downloading and installing latest gh cli..."
download_gh_cli
install_gh_cli
echo "Publishing new release notes to GitHub..."
gh release create "$RELEASE_CANDIDATE_TAG" --generate-notes
}

release_to_github
30 changes: 30 additions & 0 deletions .circleci/scripts/tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh
set -e

SEMVER_REGEX_PATTERN="[0-9]+\.[0-9]+\.[0-9]+"

latest_changelog_tag() {
grep -Po "(?<=\#\# \[)$SEMVER_REGEX_PATTERN?(?=\])" CHANGELOG.md | head -n 1
}

latest_git_tag() {
git tag --sort=v:refname | grep -E "v$SEMVER_REGEX_PATTERN" | tail -n 1
}

TAG_CANDIDATE="v$(latest_changelog_tag)"

if [ "$TAG_CANDIDATE" != "$(latest_git_tag)" ]
then
echo "Configuring git..."
git config --global user.email "${PUBLISHER_EMAIL}"
git config --global user.name "${PUBLISHER_NAME}"
echo "Pushing new semver tag to GitHub..."
git tag "$TAG_CANDIDATE"
git push --tags
echo "Updating develop branch with new semver tag..."
git checkout develop
git merge "$TAG_CANDIDATE" --ff --no-edit
git push origin develop
else
echo "Latest changelog tag ($TAG_CANDIDATE) already released on GitHub. Tagging is not required."
fi
2 changes: 1 addition & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ checks:
plugins:
rubocop:
enabled: true
channel: rubocop-1-43
channel: rubocop-1-48

reek:
enabled: true
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.7.0] - 2023-03-11

### Added

- Added [`cspell`](https://cspell.org) linter
- Added [`markdownlint`](https://github.com/DavidAnson/markdownlint) linter
- Added [`shellcheck`](https://www.shellcheck.net) linter
- Added [`yamllint`](https://yamllint.readthedocs.io) linter
- Added [`lefthook`](https://github.com/evilmartians/lefthook) linters aggregator
- Added `changeloglint`
- Added auto creating release notes on GitHub
- Added auto releasing scripts

### Fixed

- Fixed security vulnerability issue [CVE-2023-27530](https://github.com/advisories/GHSA-3h57-hmj3-gj3p)

### Changed

- Updated application dependencies (`rack` 2.2.6.3, `truemail` 3.0.7)
- Updated development dependencies
- Updated application version
- Updated readme

## [0.6.0] - 2023-01-20

### Fixed
Expand Down
10 changes: 5 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ ruby(::File.read(::File.join(::File.dirname(__FILE__), '.ruby-version')).strip[/

gem 'dry-struct', '~> 1.6'
gem 'net-smtp', '~> 0.3.3'
gem 'rack', '~> 2.2', '>= 2.2.6.2'
gem 'rack', '~> 2.2', '>= 2.2.6.3'
gem 'thin', '~> 1.8', '>= 1.8.1'
gem 'truemail', '~> 3.0', '>= 3.0.5'
gem 'truemail', '~> 3.0', '>= 3.0.7'

group :development, :test do
gem 'pry-byebug', '~> 3.10', '>= 3.10.1'
Expand All @@ -19,9 +19,9 @@ group :development, :test do
gem 'bundler-audit', '~> 0.9.1', require: false
gem 'fasterer', '~> 0.10.0', require: false
gem 'reek', '~> 6.1', '>= 6.1.4', require: false
gem 'rubocop', '~> 1.43', require: false
gem 'rubocop-performance', '~> 1.15', '>= 1.15.2', require: false
gem 'rubocop-rspec', '~> 2.18', '>= 2.18.1', require: false
gem 'rubocop', '~> 1.48', require: false
gem 'rubocop-performance', '~> 1.16', require: false
gem 'rubocop-rspec', '~> 2.19', require: false
end

group :test do
Expand Down
56 changes: 28 additions & 28 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ GEM
byebug (11.1.3)
coderay (1.1.3)
colorize (0.8.1)
concurrent-ruby (1.1.10)
concurrent-ruby (1.2.2)
daemons (1.4.1)
diff-lcs (1.5.0)
docile (1.4.0)
Expand All @@ -25,11 +25,11 @@ GEM
dry-types (>= 1.7, < 2)
ice_nine (~> 0.11)
zeitwerk (~> 2.6)
dry-types (1.7.0)
dry-types (1.7.1)
concurrent-ruby (~> 1.0)
dry-core (~> 1.0, < 2)
dry-inflector (~> 1.0, < 2)
dry-logic (>= 1.4, < 2)
dry-core (~> 1.0)
dry-inflector (~> 1.0)
dry-logic (~> 1.4)
zeitwerk (~> 2.6)
eventmachine (1.2.7)
fasterer (0.10.0)
Expand All @@ -47,29 +47,29 @@ GEM
net-smtp (0.3.3)
net-protocol
parallel (1.22.1)
parser (3.2.0.0)
parser (3.2.1.1)
ast (~> 2.4.1)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.10.1)
byebug (~> 11.0)
pry (>= 0.13, < 0.15)
rack (2.2.6.2)
rack (2.2.6.3)
rack-test (2.0.2)
rack (>= 1.3)
rainbow (3.1.1)
reek (6.1.4)
kwalify (~> 0.7.0)
parser (~> 3.2.0)
rainbow (>= 2.0, < 4.0)
regexp_parser (2.6.2)
regexp_parser (2.7.0)
rexml (3.2.5)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.0)
rspec-core (3.12.1)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.2)
diff-lcs (>= 1.2.0, < 2.0)
Expand All @@ -78,28 +78,28 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
rubocop (1.43.0)
rubocop (1.48.0)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.2.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.24.1, < 2.0)
rubocop-ast (>= 1.26.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.24.1)
parser (>= 3.1.1.0)
rubocop-capybara (2.17.0)
rubocop-ast (1.27.0)
parser (>= 3.2.1.0)
rubocop-capybara (2.17.1)
rubocop (~> 1.41)
rubocop-performance (1.15.2)
rubocop-performance (1.16.0)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rspec (2.18.1)
rubocop-rspec (2.19.0)
rubocop (~> 1.33)
rubocop-capybara (~> 2.17)
ruby-progressbar (1.11.0)
ruby_parser (3.19.2)
ruby-progressbar (1.13.0)
ruby_parser (3.20.0)
sexp_processor (~> 4.16)
sexp_processor (4.16.1)
simplecov (0.22.0)
Expand All @@ -115,17 +115,17 @@ GEM
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
thor (1.2.1)
timeout (0.3.1)
truemail (3.0.5)
timeout (0.3.2)
truemail (3.0.7)
simpleidn (~> 0.2.1)
unf (0.1.4)
unf_ext
unf_ext (0.0.8.2)
unicode-display_width (2.4.2)
zeitwerk (2.6.6)
zeitwerk (2.6.7)

PLATFORMS
x86_64-darwin-22
arm64-darwin-22

DEPENDENCIES
bundler-audit (~> 0.9.1)
Expand All @@ -134,19 +134,19 @@ DEPENDENCIES
json_matchers (~> 0.11.1)
net-smtp (~> 0.3.3)
pry-byebug (~> 3.10, >= 3.10.1)
rack (~> 2.2, >= 2.2.6.2)
rack (~> 2.2, >= 2.2.6.3)
rack-test (~> 2.0, >= 2.0.2)
reek (~> 6.1, >= 6.1.4)
rspec (~> 3.12)
rubocop (~> 1.43)
rubocop-performance (~> 1.15, >= 1.15.2)
rubocop-rspec (~> 2.18, >= 2.18.1)
rubocop (~> 1.48)
rubocop-performance (~> 1.16)
rubocop-rspec (~> 2.19)
simplecov (~> 0.22.0)
thin (~> 1.8, >= 1.8.1)
truemail (~> 3.0, >= 3.0.5)
truemail (~> 3.0, >= 3.0.7)

RUBY VERSION
ruby 3.2.0p0

BUNDLED WITH
2.4.4
2.4.6
2 changes: 1 addition & 1 deletion app/truemail_server/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module TruemailServer
VERSION = '0.6.0'
VERSION = '0.7.0'
end

0 comments on commit a2c73b8

Please sign in to comment.