You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+190Lines changed: 190 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -456,3 +456,193 @@ Warnings play a critical role in guiding users toward resolving potential issues
456
456
```
457
457
458
458
By following this classification, you ensure that warnings, information, and exceptions are used appropriately, providing clear guidance to the user without cluttering the system with unnecessary messages.
459
+
460
+
461
+
## Making a release
462
+
463
+
> [!NOTE]
464
+
> VERSION needs to be formatted following the `v{major}.{minor}.{patch}` convention. We need to follow this convention to be able to retrieve versioned scripts.
465
+
466
+
To create the package for PyPI.
467
+
468
+
#### 0. Prerequisites
469
+
470
+
- Dependencies:
471
+
- twine: `pip install build twine`
472
+
- Create an account in (and join the `trl` project):
473
+
- PyPI: https://pypi.org/
474
+
- Test PyPI: https://test.pypi.org/
475
+
476
+
#### 1. Ensure your local repository is up to date with the upstream repository
477
+
478
+
```bash
479
+
git checkout main
480
+
git pull origin main
481
+
```
482
+
483
+
> [!WARNING]
484
+
> Do not merge other pull requests into `main`until the release is done. This is to ensure that the release is stable and does not include any untested changes. Announce internally (#trl-internal) to other maintainers that you are doing a release and that they must not merge PRs until the release is done.
485
+
486
+
#### 2. Create a release branch from main
487
+
488
+
```bash
489
+
git checkout -b release-v{major}.{minor}
490
+
```
491
+
492
+
#### 3. Change the version in the following files
493
+
494
+
- `.github/workflows/tests_latest.yml`:
495
+
```diff
496
+
- with: { ref: v{major}.{minor-1}-release }
497
+
+ with: { ref: v{major}.{minor}-release }
498
+
```
499
+
- `CITATION.cff`
500
+
```diff
501
+
- version: {major}.{minor-1}
502
+
+ version: {major}.{minor}
503
+
```
504
+
- `__init__.py`
505
+
```diff
506
+
- __version__ = "{major}.{minor}.0.dev0"
507
+
+ __version__ = "{major}.{minor}.0"
508
+
```
509
+
- `setup.cfg`
510
+
```diff
511
+
- version = {major}.{minor}.0.dev0
512
+
+ version = {major}.{minor}.0
513
+
```
514
+
515
+
#### 4. Commit and push these changes
516
+
517
+
```shell
518
+
git commit -m 'Release: {major}.{minor}'
519
+
git push origin release-v{major}.{minor}
520
+
```
521
+
522
+
#### 5. Create a pull request
523
+
524
+
from `release-v{major}.{minor}` to `main`, named `Release: v{major}.{minor}`, waitfor tests to pass, and request a review.
525
+
526
+
#### 6. Once the pull request is approved, merge it into `main`
527
+
528
+
#### 7. Add a tag in git to mark the release
529
+
530
+
```shell
531
+
git checkout main
532
+
git pull origin main
533
+
git tag -a v{major}.{minor}.0 -m 'Adds tag v{major}.{minor}.0 for PyPI'
534
+
git push origin v{major}.{minor}.0
535
+
```
536
+
537
+
#### 8. Create a branch `v{major}.{minor}-release` for future patch releases.
538
+
539
+
```shell
540
+
git checkout -b v{major}.{minor}-release
541
+
git push origin v{major}.{minor}-release
542
+
```
543
+
544
+
This ensures that future patch releases (`v{major}.{minor}.1`, `v{major}.{minor}.2`, etc.) can be made separately from `main`.
545
+
546
+
#### 9. Create the wheels for your release
547
+
548
+
These are the artifacts that will be uploaded to PyPI and installed by users via `pip install trl`.
549
+
550
+
Clean previous builds:
551
+
552
+
```shell
553
+
rm -rf build dist
554
+
```
555
+
556
+
At the root of your repo, run
557
+
558
+
```bash
559
+
python -m build .
560
+
```
561
+
562
+
This will create a folders named `dist` with the new versions of your package.
563
+
564
+
#### 10. Upload the package to PyPI Test
565
+
566
+
> [!IMPORTANT]
567
+
> Do not skip this step. It is important to test the package before uploading it to the main PyPI server.
568
+
569
+
```shell
570
+
twine upload dist/* -r testpypi
571
+
```
572
+
573
+
Then in a fresh environment containing all dependencies you need, try to install your new package from the PyPI test server.
574
+
575
+
```bash
576
+
pip install -i https://test.pypi.org/simple/ trl
577
+
```
578
+
579
+
You might get errors for missing dependencies since the PyPI test server does not contain all packages like PyPI does. To make sure you have everything you can do:
580
+
581
+
```bash
582
+
pip install trl
583
+
pip uninstall trl
584
+
```
585
+
586
+
(the second line will remove trl but keep all its dependencies).
587
+
588
+
Also make sure you can actually use the package! Run the following line:
589
+
590
+
```bash
591
+
python -c "from trl import *"
592
+
```
593
+
594
+
along with anything that tests:
595
+
596
+
- the core feature of your package
597
+
- the new features you’re adding in the release
598
+
599
+
#### 11. Publish on PyPI
600
+
601
+
> [!WARNING]
602
+
> This can't be reverted. Make sure you have tested everything before doing this step.
603
+
604
+
```shell
605
+
twine upload dist/*
606
+
```
607
+
608
+
#### 12. Create a GitHub Release
609
+
610
+
1. Go to the repo’s [releases section](https://github.com/huggingface/trl/releases) on GitHub.
611
+
2. Click **Draft a new release**.
612
+
3. Select the `v{major}.{minor}.0` tag you just created in step 7.
613
+
4. Add a title (`v{major}.{minor}.0`) and a short description of what’s new.
614
+
5. Click **Publish Release**.
615
+
616
+
#### 13. Bump to dev version
617
+
618
+
1. Create a branch `bump-dev-version-{major}.{minor+1}` from `main` and checkout to it.
0 commit comments