Skip to content

Commit 87f8b2d

Browse files
committed
📝 Documentation
- Add TODO for rake build task override
1 parent fa66275 commit 87f8b2d

File tree

4 files changed

+73
-7
lines changed

4 files changed

+73
-7
lines changed

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ platform :mri do
1414
### Debugging (MRI Only)
1515
gem "byebug", ">= 11"
1616
end
17+
18+
gem "appraisal", github: "pboling/appraisal", branch: "galtzo"

README.md

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
A ruby script, and rake task, to generate SHA-256 and SHA-512 checksums of RubyGem libraries, shipped as a RubyGem.
44

5+
You may be familiar with the standard rake task `build:checksum` from RubyGems.
6+
This gem ships an improved version as `build:checksums`, based on the
7+
[RubyGems pull request and discussion here](https://github.com/rubygems/rubygems/pull/6022).
8+
9+
```shell
10+
rake build:checksums
11+
```
12+
13+
It is different from, and improves on, the standard rake task in that it:
14+
- does various checks to ensure the generated checksums will be valid
15+
- does `git commit` the generated checksums
16+
517
## Installation
618

719
Install the gem and add to the gem's Gemfile by executing:
@@ -27,14 +39,70 @@ gem install gem_checksums
2739

2840
## Usage
2941

30-
TODO: Write usage instructions here
42+
You may be familiar with the standard rake task `build:checksum` from RubyGems.
43+
This gem ships an improved version as `build:checksums`, based on the
44+
[RubyGems pull request and discussion here](https://github.com/rubygems/rubygems/pull/6022).
45+
46+
```shell
47+
rake build:checksums
48+
```
49+
50+
Generating checksums makes sense when you are building and releasing a gem, so how does it fit into that process?
51+
52+
### How To: Release gem with checksums generated by `gem_checksums`
53+
54+
NOTE: This is an example process which assumes your project has bundler binstubs, and a version.rb file,
55+
with notes for `zsh` and `bash` shells.
56+
57+
1. Run `bin/setup && bin/rake` as a tests, coverage, & linting sanity check
58+
2. Update the version number in `version.rb`
59+
3. Run `bin/setup && bin/rake` again as a secondary check, and to update `Gemfile.lock`
60+
4. Run `git commit -am "🔖 Prepare release v<VERSION>"` to commit the changes
61+
5. Run `git push` to trigger the final CI pipeline before release, & merge PRs
62+
- NOTE: Remember to [check the build][🧪build]!
63+
6. Run `export GIT_TRUNK_BRANCH_NAME="$(git remote show origin | grep 'HEAD branch' | cut -d ' ' -f5)" && echo $GIT_TRUNK_BRANCH_NAME`
64+
7. Run `git checkout $GIT_TRUNK_BRANCH_NAME`
65+
8. Run `git pull origin $GIT_TRUNK_BRANCH_NAME` to ensure you will release the latest trunk code
66+
9. Set `SOURCE_DATE_EPOCH` so `rake build` and `rake release` use same timestamp, and generate same checksums
67+
- Run `export SOURCE_DATE_EPOCH=$EPOCHSECONDS && echo $SOURCE_DATE_EPOCH`
68+
- If the echo above has no output, then it didn't work.
69+
- Note that you'll need the `zsh/datetime` module, if running `zsh`.
70+
- In `bash` you can use `date +%s` instead, i.e. `export SOURCE_DATE_EPOCH=$(date +%s) && echo $SOURCE_DATE_EPOCH`
71+
10. Run `bundle exec rake build`
72+
11. Run `gem_checksums` (from this gem, and added to path in .envrc,
73+
more context [1][🔒️rubygems-checksums-pr] and [2][🔒️rubygems-guides-pr]) to create SHA-256 and SHA-512 checksums
74+
- Checksums will be committed automatically by the script, but not pushed
75+
12. Run `bundle exec rake release` which will create a git tag for the version,
76+
push git commits and tags, and push the `.gem` file to [rubygems.org][💎rubygems]
77+
78+
[🧪build]: https://github.com/pboling/gem_checksums/actions
79+
[🤝conduct]: https://github.com/pboling/gem_checksums/blob/main/CODE_OF_CONDUCT.md
80+
[🖐contrib-rocks]: https://contrib.rocks
81+
[🚎contributors]: https://gitlab.com/pboling/gem_checksums/-/graphs/main
82+
[🖐contributors]: https://github.com/pboling/gem_checksums/graphs/contributors
83+
[🖐contributors-img]: https://contrib.rocks/image?repo=pboling/gem_checksums
84+
[📗keep-changelog]: https://keepachangelog.com/en/1.0.0/
85+
[📗keep-changelog-img]: https://img.shields.io/badge/keep--a--changelog-1.0.0-FFDD67.svg?style=flat
86+
[💎rubygems]: https://rubygems.org
87+
[🔒️rubygems-security-guide]: https://guides.rubygems.org/security/#building-gems
88+
[🔒️rubygems-checksums-pr]: https://github.com/rubygems/rubygems/pull/6022
89+
[🔒️rubygems-guides-pr]: https://github.com/rubygems/guides/pull/325
90+
[🚎src-main]: https://github.com/pboling/gem_checksums
91+
92+
It is different from, and improves on, the standard rake task in that it:
93+
- does various checks to ensure the generated checksums will be valid
94+
- does `git commit` the generated checksums
3195

3296
## Development
3397

3498
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
3599

36100
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
37101

102+
### TODOs
103+
104+
- [] Prepend `rake build` task with check for `SOURCE_DATE_EPOCH` environment variable, and raise error if not set.
105+
38106
## Contributing
39107

40108
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gem_checksums. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/gem_checksums/blob/main/CODE_OF_CONDUCT.md).

Rakefile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22

33
require "bundler/gem_tasks"
44

5-
require "gem_checksums"
6-
7-
# frozen_string_literal: true
8-
9-
require "bundler/gem_tasks"
10-
115
begin
126
require "rspec/core/rake_task"
137

lib/gem_checksums/rakelib/gem_checksums.rake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# TODO: Override rake build task with check for SOURCE_DATE_EPOCH environment variable, and raise error if not set.
2+
13
namespace :build do
24
desc "Generate both SHA256 & SHA512 checksums into the checksums directory, and git commit them"
35
task :checksums do

0 commit comments

Comments
 (0)