From 53810ffcd725f832f2745eda108631ed4dfd8400 Mon Sep 17 00:00:00 2001 From: Peter Boling Date: Mon, 24 Feb 2025 02:23:44 +0700 Subject: [PATCH] Release Prep (#5) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 📝 73 lines of code * ♻️ Move warning string to constant * 🚸 Code Coverage with CodeCov * 🚸 Code Coverage with CodeClimate * 🚸 Dependency tracking with Depfu --- README.md | 12 +++++------ lib/gem_checksums.rb | 49 ++++++++++++++++++++++---------------------- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 8757959..ce57102 100644 --- a/README.md +++ b/README.md @@ -363,15 +363,15 @@ or one of the others at the head of this README. [👽version]: https://rubygems.org/gems/gem_checksums [👽versioni]: https://img.shields.io/gem/v/gem_checksums.svg [🔑cc-mnt]: https://codeclimate.com/github/pboling/gem_checksums/maintainability -[🔑cc-mnti♻️]: https://api.codeclimate.com/v1/badges/e26c543320ca0d14e871/maintainability +[🔑cc-mnti♻️]: https://api.codeclimate.com/v1/badges/ff2234fcbe9051436f37/maintainability [🔑cc-cov]: https://codeclimate.com/github/pboling/gem_checksums/test_coverage -[🔑cc-covi♻️]: https://api.codeclimate.com/v1/badges/e26c543320ca0d14e871/test_coverage +[🔑cc-covi♻️]: https://api.codeclimate.com/v1/badges/ff2234fcbe9051436f37/test_coverage [🔑codecov]: https://codecov.io/gh/pboling/gem_checksums -[🔑codecovi♻️]: https://codecov.io/gh/pboling/gem_checksums/branch/main/graph/badge.svg?token=cc6UdZCpAL +[🔑codecovi♻️]: https://codecov.io/gh/pboling/gem_checksums/branch/main/graph/badge.svg?token=iQykVGCFME [🔑coveralls]: https://coveralls.io/github/pboling/gem_checksums?branch=main [🔑coveralls-img]: https://coveralls.io/repos/github/pboling/gem_checksums/badge.svg?branch=main [🔑depfu]: https://depfu.com/github/pboling/gem_checksums -[🔑depfui♻️]: https://badges.depfu.com/badges/6c9b45362951b872127f9e46d39bed76/count.svg +[🔑depfui♻️]: https://badges.depfu.com/badges/85187dfdd2ecf7839b2ec78c64d2bf4e/count.svg [🖐codeQL]: https://github.com/pboling/gem_checksums/security/code-scanning [🖐codeQL-img]: https://github.com/pboling/gem_checksums/actions/workflows/codeql-analysis.yml/badge.svg [🚎1-an-wf]: https://github.com/pboling/gem_checksums/actions/workflows/ancient.yml @@ -431,7 +431,7 @@ or one of the others at the head of this README. [🤝issues]: https://github.com/pboling/gem_checksums/issues [🤝pulls]: https://github.com/pboling/gem_checksums/pulls [🤝contributing]: CONTRIBUTING.md -[🔑codecov-g♻️]: https://codecov.io/gh/pboling/gem_checksums/graphs/tree.svg?token=cc6UdZCpAL +[🔑codecov-g♻️]: https://codecov.io/gh/pboling/gem_checksums/graphs/tree.svg?token=iQykVGCFME [🖐contrib-rocks]: https://contrib.rocks [🖐contributors]: https://github.com/pboling/gem_checksums/graphs/contributors [🖐contributors-img]: https://contrib.rocks/image?repo=pboling/gem_checksums @@ -447,7 +447,7 @@ or one of the others at the head of this README. [📗keep-changelog]: https://keepachangelog.com/en/1.0.0/ [📗keep-changelog-img]: https://img.shields.io/badge/keep--a--changelog-1.0.0-FFDD67.svg?style=flat [🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ -[🧮kloc-img]: https://img.shields.io/badge/KLOC-0.058-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue +[🧮kloc-img]: https://img.shields.io/badge/KLOC-0.073-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue [🔐security]: SECURITY.md [🔐security-img]: https://img.shields.io/badge/security-policy-brightgreen.svg?style=flat [📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year diff --git a/lib/gem_checksums.rb b/lib/gem_checksums.rb index a546a4e..251a4c8 100644 --- a/lib/gem_checksums.rb +++ b/lib/gem_checksums.rb @@ -19,12 +19,34 @@ class Error < StandardError; end # See: https://learnbyexample.github.io/Ruby_Regexp/lookarounds.html#positive-lookarounds # Used to pattern match against a gem package name, which always ends with .gem. # The positive lookahead ensures it is present, and prevents it from being captured. - VERSION_REGEX = /((\d+\.\d+\.\d+)([-.][0-9A-Za-z-]+)*)(?=\.gem)/ + VERSION_REGEX = /((\d+\.\d+\.\d+)([-.][0-9A-Za-z-]+)*)(?=\.gem)/.freeze RUNNING_AS = File.basename($PROGRAM_NAME) BUILD_TIME_ERROR_MESSAGE = "Environment variable SOURCE_DATE_EPOCH must be set. You'll need to rebuild the gem. See gem_checksums/README.md" GIT_DRY_RUN_ENV = ENV.fetch("GEM_CHECKSUMS_GIT_DRY_RUN", "false").casecmp("true") == 0 CHECKSUMS_DIR = ENV.fetch("GEM_CHECKSUMS_CHECKSUMS_DIR", "checksums") PACKAGE_DIR = ENV.fetch("GEM_CHECKSUMS_PACKAGE_DIR", "pkg") + BUILD_TIME_WARNING = <<-BUILD_TIME_WARNING +WARNING: Build time not provided via environment variable SOURCE_DATE_EPOCH. + To ensure consistent SHA-256 & SHA-512 checksums, + you must set this environment variable *before* building the gem. + +IMPORTANT: After setting the build time, you *must re-build the gem*, i.e. bundle exec rake build, or gem build. + +How to set the build time: + +In zsh shell: + - export SOURCE_DATE_EPOCH=$EPOCHSECONDS && echo $SOURCE_DATE_EPOCH + - If the echo above has no output, then it didn't work. + - Note that you'll need the `zsh/datetime` module enabled. + +In fish shell: + - set -x SOURCE_DATE_EPOCH (date +%s) + - echo $SOURCE_DATE_EPOCH + +In bash shell: + - export SOURCE_DATE_EPOCH=$(date +%s) && echo $SOURCE_DATE_EPOCH` + + BUILD_TIME_WARNING # Make this gem's rake tasks available in your Rakefile: # @@ -47,30 +69,7 @@ def generate(git_dry_run: false) warn("Will run git commit with --dry-run") if git_dry_run_flag if build_time_missing - warn( - <<-BUILD_TIME_WARNING, -WARNING: Build time not provided via environment variable SOURCE_DATE_EPOCH. - To ensure consistent SHA-256 & SHA-512 checksums, - you must set this environment variable *before* building the gem. - -IMPORTANT: After setting the build time, you *must re-build the gem*, i.e. bundle exec rake build, or gem build. - -How to set the build time: - -In zsh shell: - - export SOURCE_DATE_EPOCH=$EPOCHSECONDS && echo $SOURCE_DATE_EPOCH - - If the echo above has no output, then it didn't work. - - Note that you'll need the `zsh/datetime` module enabled. - -In fish shell: - - set -x SOURCE_DATE_EPOCH (date +%s) - - echo $SOURCE_DATE_EPOCH - -In bash shell: - - export SOURCE_DATE_EPOCH=$(date +%s) && echo $SOURCE_DATE_EPOCH` - - BUILD_TIME_WARNING - ) + warn(BUILD_TIME_WARNING) raise Error, BUILD_TIME_ERROR_MESSAGE end