Skip to content

Commit

Permalink
Release Prep (#5)
Browse files Browse the repository at this point in the history
* 📝 73 lines of code

* ♻️ Move warning string to constant

* 🚸 Code Coverage with CodeCov

* 🚸 Code Coverage with CodeClimate

* 🚸 Dependency tracking with Depfu
  • Loading branch information
pboling authored Feb 23, 2025
1 parent 6e48bc6 commit 53810ff
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 31 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
49 changes: 24 additions & 25 deletions lib/gem_checksums.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand All @@ -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

Expand Down

0 comments on commit 53810ff

Please sign in to comment.