Skip to content

Commit dec4c92

Browse files
committed
Document contributing workflow and add release helper
1 parent e2e27f4 commit dec4c92

3 files changed

Lines changed: 153 additions & 68 deletions

File tree

CONTRIBUTING.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Contributing
2+
3+
Thanks for helping improve the Transloadit Ruby SDK! This guide covers local development, testing, and publishing new releases.
4+
5+
## Local Development
6+
7+
After cloning the repository, install dependencies and run the test suite:
8+
9+
```bash
10+
bundle install
11+
bundle exec rake test
12+
```
13+
14+
To exercise the signature parity suite against the Node.js CLI, make sure `npx transloadit` is available and run:
15+
16+
```bash
17+
TEST_NODE_PARITY=1 bundle exec rake test
18+
```
19+
20+
You can warm the CLI cache ahead of time:
21+
22+
```bash
23+
TRANSLOADIT_KEY=... TRANSLOADIT_SECRET=... \
24+
npx --yes transloadit smart_sig --help
25+
TRANSLOADIT_KEY=... TRANSLOADIT_SECRET=... \
26+
npx --yes transloadit sig --algorithm sha384 --help
27+
```
28+
29+
Set `COVERAGE=0` to skip coverage instrumentation if desired:
30+
31+
```bash
32+
COVERAGE=0 bundle exec rake test
33+
```
34+
35+
## Docker Workflow
36+
37+
The repository ships with a helper that runs tests inside a reproducible Docker image:
38+
39+
```bash
40+
./scripts/test-in-docker.sh
41+
```
42+
43+
Pass a custom command to run alternatives (Bundler still installs first):
44+
45+
```bash
46+
./scripts/test-in-docker.sh bundle exec ruby -Itest test/unit/transloadit/test_request.rb
47+
```
48+
49+
The script forwards environment variables such as `TEST_NODE_PARITY` and credentials from `.env`, so you can combine parity checks and integration tests. End-to-end uploads are enabled by default; unset them by running:
50+
51+
```bash
52+
RUBY_SDK_E2E=0 ./scripts/test-in-docker.sh
53+
```
54+
55+
## Live End-to-End Test
56+
57+
To exercise the optional live upload:
58+
59+
```bash
60+
RUBY_SDK_E2E=1 TRANSLOADIT_KEY=... TRANSLOADIT_SECRET=... \
61+
./scripts/test-in-docker.sh bundle exec ruby -Itest test/integration/test_e2e_upload.rb
62+
```
63+
64+
The test uploads `chameleon.jpg`, resizes it, and asserts on a real assembly response.
65+
66+
## Releasing to RubyGems
67+
68+
1. Update the version and changelog:
69+
- Bump `lib/transloadit/version.rb`.
70+
- Add a corresponding entry to `CHANGELOG.md`.
71+
2. Run the full test suite (including Docker, parity, and e2e checks as needed).
72+
3. Commit the release changes and tag:
73+
```bash
74+
git commit -am "Release X.Y.Z"
75+
git tag -a vX.Y.Z -m "Release X.Y.Z"
76+
```
77+
4. Push the commit and tag:
78+
```bash
79+
git push origin main
80+
git push origin vX.Y.Z
81+
```
82+
5. Publish the gem using the helper script:
83+
```bash
84+
GEM_HOST_API_KEY=... ./scripts/notify-registry.sh
85+
```
86+
6. Draft a GitHub release from the new tag and publish the generated notes.
87+
88+
### RubyGems Credentials
89+
90+
- You must belong to the `transloadit` organization on RubyGems with permission to push the `transloadit` gem.
91+
- Generate an API key with **Push Rubygems** permissions at <https://rubygems.org/profile/edit>. Copy the token and keep it secure.
92+
- Export the token as `GEM_HOST_API_KEY` in your environment before running `./scripts/notify-registry.sh`. The script refuses to run if the variable is missing.
93+
94+
That’s it! Thank you for contributing.
95+

README.md

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -467,71 +467,4 @@ If you still need support for Ruby 2.x, 2.0.1 is the last version that supports
467467

468468
## Contributing
469469

470-
Contributions are welcome!
471-
472-
### Running tests
473-
474-
```bash
475-
bundle install
476-
bundle exec rake test
477-
```
478-
479-
To also test parity against the Node.js reference implementation, ensure you can run `npx transloadit smart_sig` and `npx transloadit sig` (the CLI downloads on demand), then run:
480-
481-
```bash
482-
TEST_NODE_PARITY=1 bundle exec rake test
483-
```
484-
485-
You can warm the CLI cache ahead of time with:
486-
487-
```bash
488-
TRANSLOADIT_KEY=... TRANSLOADIT_SECRET=... \
489-
npx --yes transloadit smart_sig --help
490-
TRANSLOADIT_KEY=... TRANSLOADIT_SECRET=... \
491-
npx --yes transloadit sig --algorithm sha384 --help
492-
```
493-
494-
To disable coverage reporting, run:
495-
496-
```bash
497-
COVERAGE=0 bundle exec rake test
498-
```
499-
500-
#### Run tests in Docker
501-
502-
```bash
503-
./scripts/test-in-docker.sh
504-
```
505-
506-
This builds a local image, runs `bundle install`, and executes `bundle exec rake test`. Pass a custom command to run something else (Bundler still installs first):
507-
508-
```bash
509-
./scripts/test-in-docker.sh bundle exec ruby -Itest test/unit/transloadit/test_request.rb
510-
```
511-
512-
The script forwards environment variables such as `TEST_NODE_PARITY` or credentials defined in `.env`, so you can combine parity checks and integration tests inside Docker:
513-
514-
```bash
515-
TEST_NODE_PARITY=1 ./scripts/test-in-docker.sh
516-
```
517-
518-
To exercise the optional end-to-end upload against a real Transloadit account, provide `TRANSLOADIT_KEY` and `TRANSLOADIT_SECRET` (via environment variables or `.env`) and set `RUBY_SDK_E2E=1`:
519-
520-
```bash
521-
RUBY_SDK_E2E=1 ./scripts/test-in-docker.sh bundle exec ruby -Itest test/integration/test_e2e_upload.rb
522-
```
523-
524-
The test uploads `chameleon.jpg`, resizes it, and asserts on the live assembly results.
525-
526-
> **Note:** `./scripts/test-in-docker.sh` now defaults to `RUBY_SDK_E2E=1`. If you want to skip the live upload during local runs, invoke `RUBY_SDK_E2E=0 ./scripts/test-in-docker.sh` instead.
527-
528-
### Releasing on RubyGems
529-
530-
Let's say you wanted to release version `3.1.0`, here are the steps:
531-
532-
1. Update the version number in the version file `version.rb` and `CHANGELOG.md`
533-
2. Commit: `git add CHANGELOG.md lib/transloadit/version.rb && git commit -m "Release 3.1.0"`
534-
3. Create a git tag: `git tag -a v3.1.0 -m "Release 3.1.0"`
535-
4. Push the git tag: `git push origin v3.1.0`
536-
5. Release on RubyGems: `gem build transloadit.gemspec && gem push transloadit-3.1.0.gem`
537-
6. Draft a release [here](https://github.com/transloadit/ruby-sdk/releases). Click the `v3.1.0` tag and click `Generate release notes`. Inspect and Publish.
470+
See [CONTRIBUTING.md](CONTRIBUTING.md) for local development, testing, and release instructions.

scripts/notify-registry.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
IMAGE_NAME=${IMAGE_NAME:-transloadit-ruby-sdk-dev}
5+
6+
err() {
7+
echo "notify-registry: $*" >&2
8+
}
9+
10+
if ! command -v docker >/dev/null 2>&1; then
11+
err "Docker is required to publish the gem."
12+
exit 1
13+
fi
14+
15+
if [[ -z "${GEM_HOST_API_KEY:-}" ]]; then
16+
err "GEM_HOST_API_KEY environment variable is not set. Generate a RubyGems API key with push permissions and export it before running this script."
17+
exit 1
18+
fi
19+
20+
if ! docker image inspect "$IMAGE_NAME" >/dev/null 2>&1; then
21+
err "Docker image '$IMAGE_NAME' not found. Building it now..."
22+
docker build -t "$IMAGE_NAME" -f Dockerfile .
23+
fi
24+
25+
version=$(
26+
docker run --rm \
27+
-v "$PWD":/workspace \
28+
-w /workspace \
29+
"$IMAGE_NAME" \
30+
ruby -Ilib -e 'require "transloadit/version"; puts Transloadit::VERSION'
31+
)
32+
33+
gem_file="transloadit-${version}.gem"
34+
35+
err "Building ${gem_file}..."
36+
docker run --rm \
37+
--user "$(id -u):$(id -g)" \
38+
-e HOME=/workspace \
39+
-v "$PWD":/workspace \
40+
-w /workspace \
41+
"$IMAGE_NAME" \
42+
bash -lc "set -euo pipefail; rm -f ${gem_file}; gem build transloadit.gemspec >/dev/null"
43+
44+
err "Pushing ${gem_file} to RubyGems..."
45+
docker run --rm \
46+
--user "$(id -u):$(id -g)" \
47+
-e HOME=/workspace \
48+
-e GEM_HOST_API_KEY="$GEM_HOST_API_KEY" \
49+
-v "$PWD":/workspace \
50+
-w /workspace \
51+
"$IMAGE_NAME" \
52+
bash -lc "set -euo pipefail; gem push ${gem_file}"
53+
54+
err "Removing local ${gem_file}..."
55+
rm -f "${gem_file}"
56+
57+
echo "notify-registry: Successfully pushed ${gem_file} to RubyGems."

0 commit comments

Comments
 (0)