@oorabona/release-it-preset 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +404 -62
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -9,6 +9,24 @@ Shared [release-it](https://github.com/release-it/release-it) configuration and
9
9
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.3+-blue.svg)](https://www.typescriptlang.org/)
10
10
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
11
11
 
12
+ ## Table of Contents
13
+
14
+ - [Features](#features)
15
+ - [Installation](#installation)
16
+ - [Quick Start](#quick-start)
17
+ - [Available Configurations](#available-configurations)
18
+ - [CLI Usage](#cli-usage)
19
+ - [Scripts](#scripts)
20
+ - [Environment Variables](#environment-variables)
21
+ - [Configuration Override](#configuration-override)
22
+ - [Borrowing Scripts & Workflows](#borrowing-scripts--workflows)
23
+ - [Release Workflow](#release-workflow)
24
+ - [GitHub Actions Workflows](#github-actions-workflows)
25
+ - [Reusable Workflows](#reusable-workflows)
26
+ - [Workflow Reference](#workflow-reference)
27
+ - [Best Practices](#best-practices)
28
+ - [Troubleshooting](#troubleshooting)
29
+
12
30
  ## Features
13
31
 
14
32
  - 📦 Multiple release configurations for different scenarios
@@ -87,8 +105,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
87
105
 
88
106
  ## GitHub Actions
89
107
 
90
- - Reuse the PR validation workflow from this package:
108
+ ### Quick Start: Reusable Workflows
109
+
110
+ Import pre-configured workflows into your repository:
91
111
 
112
+ **PR Validation:**
92
113
  ```yaml
93
114
  name: PR Checks
94
115
 
@@ -96,16 +117,40 @@ on:
96
117
  pull_request:
97
118
  types: [opened, synchronize, reopened]
98
119
 
120
+ permissions:
121
+ contents: read
122
+ pull-requests: write
123
+
99
124
  jobs:
100
125
  validate:
101
126
  uses: oorabona/release-it-preset/.github/workflows/reusable-verify.yml@main
102
127
  with:
103
128
  base-ref: origin/${{ github.base_ref }}
104
129
  head-ref: ${{ github.sha }}
130
+ run-tests: true
105
131
  secrets: inherit
106
132
  ```
107
133
 
108
- Pair it with a follow-up job to post a summary comment using the outputs exposed by the reusable workflow (see `.github/workflows/validate-pr.yml` in this repo for a full example).
134
+ **Publish on Tag:**
135
+ ```yaml
136
+ name: Publish
137
+
138
+ on:
139
+ push:
140
+ tags: ['v*']
141
+
142
+ permissions:
143
+ contents: write
144
+ id-token: write
145
+
146
+ jobs:
147
+ publish:
148
+ uses: oorabona/release-it-preset/.github/workflows/publish.yml@main
149
+ secrets:
150
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
151
+ ```
152
+
153
+ 📖 **[Full Reusable Workflows Documentation](examples/reusable-workflows.md)** | 📚 **[CI/CD Integration Examples](examples/ci-integration.md)**
109
154
 
110
155
  ## Available Configurations
111
156
 
@@ -665,18 +710,154 @@ jobs:
665
710
 
666
711
  This repository includes several GitHub Actions workflows for automated CI/CD and release management.
667
712
 
668
- ### Available Workflows
713
+ ### Reusable Workflows
714
+
715
+ Two workflows are designed for reuse in your own projects:
716
+
717
+ #### 🔄 `reusable-verify.yml` - PR Validation & Hygiene Checks
718
+
719
+ Validates TypeScript compilation, runs tests, checks release readiness, and evaluates PR hygiene (changelog updates, conventional commits).
720
+
721
+ **When to use:** Import this workflow in your PR validation to ensure code quality and release readiness.
722
+
723
+ **Inputs:**
724
+
725
+ | Input | Type | Default | Description |
726
+ |-------|------|---------|-------------|
727
+ | `node-version` | string | `'20'` | Node.js version to use |
728
+ | `run-tests` | boolean | `false` | Run `pnpm test` after compilation |
729
+ | `base-ref` | string | `''` | Base ref for diff comparisons (e.g., `origin/main`) |
730
+ | `head-ref` | string | `'HEAD'` | Head ref for comparisons |
731
+ | `install-args` | string | `'--frozen-lockfile'` | Additional pnpm install arguments |
732
+ | `fetch-depth` | number | `0` | Git fetch depth for checkout |
733
+
734
+ **Outputs:**
735
+
736
+ | Output | Description |
737
+ |--------|-------------|
738
+ | `release_validation` | `'true'` when release validation passes |
739
+ | `changelog_status` | Changelog status: `updated`, `skipped`, or `missing` |
740
+ | `skip_changelog` | `'true'` when `[skip-changelog]` detected in commits |
741
+ | `conventional_commits` | `'true'` when conventional commits detected |
742
+ | `commit_messages` | Base64 encoded JSON array of analyzed commit messages |
743
+ | `changed_files` | Base64 encoded JSON array of changed files |
744
+
745
+ **Example usage in your project:**
746
+
747
+ ```yaml
748
+ # .github/workflows/validate-pr.yml
749
+ name: PR Validation
750
+
751
+ on:
752
+ pull_request:
753
+ types: [opened, synchronize, reopened]
754
+
755
+ jobs:
756
+ validate:
757
+ uses: oorabona/release-it-preset/.github/workflows/reusable-verify.yml@main
758
+ with:
759
+ node-version: '20'
760
+ base-ref: origin/${{ github.base_ref }}
761
+ head-ref: ${{ github.sha }}
762
+ run-tests: true
763
+ secrets: inherit
764
+
765
+ comment:
766
+ needs: validate
767
+ runs-on: ubuntu-latest
768
+ if: always()
769
+ permissions:
770
+ pull-requests: write
771
+ steps:
772
+ - uses: actions/github-script@v7
773
+ with:
774
+ script: |
775
+ const summary = `## 📋 PR Validation
776
+
777
+ ${needs.validate.outputs.release_validation === 'true' ? '✅' : '⚠️'} Release validation
778
+ ${needs.validate.outputs.changelog_status === 'updated' ? '✅' : 'ℹ️'} Changelog: ${needs.validate.outputs.changelog_status}
779
+ ${needs.validate.outputs.conventional_commits === 'true' ? '✅' : 'ℹ️'} Conventional commits
780
+ `;
781
+
782
+ github.rest.issues.createComment({
783
+ owner: context.repo.owner,
784
+ repo: context.repo.repo,
785
+ issue_number: context.issue.number,
786
+ body: summary
787
+ });
788
+ ```
789
+
790
+ #### 🔄 `build-dist.yml` - Build Compiled Distribution
791
+
792
+ Builds TypeScript sources to `dist/` and uploads as artifact for reuse in other jobs.
793
+
794
+ **When to use:** When you need compiled outputs across multiple jobs without rebuilding.
795
+
796
+ **Inputs:**
797
+
798
+ | Input | Type | Default | Description |
799
+ |-------|------|---------|-------------|
800
+ | `artifact_name` | string | `'dist-build'` | Name for the uploaded dist artifact |
801
+ | `ref` | string | (current) | Optional git ref to checkout before building |
669
802
 
670
- You can copy these files into your own repository (adjusting names, branches, and secrets to match your context). They are designed to work as-is with the release-it-preset CLI defaults but feel free to trim the jobs that you don’t need.
803
+ **Outputs:**
671
804
 
672
- #### 1. **CI** (`.github/workflows/ci.yml`)
805
+ | Output | Description |
806
+ |--------|-------------|
807
+ | `artifact_name` | Name of the uploaded dist artifact |
673
808
 
674
- **Triggers:** Push to main, Pull Requests, Manual (workflow_dispatch)
809
+ **Example usage in your project:**
810
+
811
+ ```yaml
812
+ # .github/workflows/ci.yml
813
+ jobs:
814
+ build:
815
+ uses: oorabona/release-it-preset/.github/workflows/build-dist.yml@main
816
+ with:
817
+ artifact_name: my-dist
818
+ ref: ${{ github.sha }}
819
+
820
+ test:
821
+ needs: build
822
+ runs-on: ubuntu-latest
823
+ steps:
824
+ - uses: actions/checkout@v4
825
+ - uses: actions/download-artifact@v4
826
+ with:
827
+ name: ${{ needs.build.outputs.artifact_name }}
828
+ path: dist
829
+ - run: pnpm test
830
+ ```
831
+
832
+ ### Workflow Reference
833
+
834
+ #### Overview Table
835
+
836
+ | Workflow | Type | Trigger | Purpose |
837
+ |----------|------|---------|---------|
838
+ | 🔄 [reusable-verify.yml](#-reusable-verifyyml---pr-validation--hygiene-checks) | Reusable | `workflow_call` | PR validation & hygiene checks |
839
+ | 🔄 [build-dist.yml](#-build-distyml---build-compiled-distribution) | Reusable | `workflow_call` | Build TypeScript distribution |
840
+ | ⚙️ [ci.yml](#1-️-ci-github-workflowsciyml) | Standalone | Push, PR, Manual | Continuous Integration |
841
+ | ✅ [validate-pr.yml](#2--validate-pr-github-workflowsvalidate-pryml) | Standalone | PR | Pull request validation |
842
+ | 🚨 [hotfix.yml](#3--hotfix-release-github-workflowshotfixyml) | Manual | `workflow_dispatch` | Emergency hotfix releases |
843
+ | 🔄 [retry-publish.yml](#4--retry-publish-github-workflowsretry-publishyml) | Manual | `workflow_dispatch` | Retry failed publishing |
844
+ | ⚠️ [republish.yml](#5-️-republish-exceptional-github-workflowsrepublishyml) | Manual | `workflow_dispatch` | Republish existing version |
845
+ | 📦 [publish.yml](#6--publish-github-workflowspublishyml) | Reusable | Tag push, `workflow_call` | Automated publishing |
846
+
847
+ You can copy these workflows into your own repository (adjusting names, branches, and secrets to match your context). They work with the release-it-preset CLI defaults.
848
+
849
+ #### 1. ⚙️ **CI** (`.github/workflows/ci.yml`)
850
+
851
+ **Triggers:**
852
+ - Push to `main`
853
+ - Pull Requests to `main`
854
+ - Manual (`workflow_dispatch`)
675
855
 
676
856
  **Jobs:**
677
- - **validate** - Validates TypeScript compilation and file structure
678
- - **test-cli** - Tests all CLI commands (help, check, validate, init)
679
- - **release** - Manual release creation (workflow_dispatch only)
857
+ - `build-dist` - Builds compiled distribution using reusable workflow
858
+ - `tests` - Runs unit tests with coverage
859
+ - `test-cli` - Tests all CLI commands (help, check, validate, init)
860
+ - `release` - Manual release creation (workflow_dispatch only)
680
861
 
681
862
  **Manual Release:**
682
863
  ```bash
@@ -684,88 +865,249 @@ You can copy these files into your own repository (adjusting names, branches, an
684
865
  # Select increment type: patch, minor, or major
685
866
  ```
686
867
 
687
- #### 2. **Validate PR** (`.github/workflows/validate-pr.yml`)
868
+ **Secrets required:**
869
+ - `NPM_TOKEN` - npm automation token (for release job)
870
+ - `CODECOV_TOKEN` - Codecov upload token (optional)
688
871
 
689
- **Trigger:** Pull Request opened/updated
872
+ #### 2. ✅ **Validate PR** (`.github/workflows/validate-pr.yml`)
690
873
 
691
- **What it does:**
692
- - Validates TypeScript compilation
693
- - Runs release validation checks
694
- - Checks if CHANGELOG.md was updated
695
- - Validates conventional commits format
696
- - Posts summary comment on PR
874
+ **Triggers:**
875
+ - Pull Request `opened`, `synchronize`, `reopened`
876
+ - Can be called as reusable workflow (`workflow_call`)
877
+
878
+ **Jobs:**
879
+ - `validate` - Uses `reusable-verify.yml` for hygiene checks
880
+ - `summarize` - Posts validation summary comment on PR
881
+
882
+ **What it checks:**
883
+ - ✅ TypeScript compilation
884
+ - ✅ Release validation (with `--allow-dirty`)
885
+ - ✅ CHANGELOG.md updates (or `[skip-changelog]` marker)
886
+ - ✅ Conventional commits format
887
+ - ✅ Commit messages analysis
888
+
889
+ **Permissions required:**
890
+ ```yaml
891
+ permissions:
892
+ contents: read
893
+ pull-requests: write # For posting comments
894
+ ```
697
895
 
698
- **Helpful for:**
699
- - Ensuring PRs follow best practices
700
- - Catching issues before merge
701
- - Promoting conventional commits usage
896
+ **No secrets required** (uses `GITHUB_TOKEN` automatically)
702
897
 
703
- #### 3. **Hotfix Release** (`.github/workflows/hotfix.yml`)
898
+ #### 3. 🚨 **Hotfix Release** (`.github/workflows/hotfix.yml`)
704
899
 
705
- **Trigger:** Manual (workflow_dispatch)
900
+ **Trigger:** Manual (`workflow_dispatch`)
706
901
 
707
902
  **Inputs:**
708
- - `increment` - patch or minor (required)
709
- - `commit` - Specific commit SHA (optional)
710
- - `dry_run` - Test without publishing (boolean)
903
+
904
+ | Input | Type | Required | Default | Description |
905
+ |-------|------|----------|---------|-------------|
906
+ | `increment` | choice | ✅ | `patch` | Version bump: `patch` or `minor` |
907
+ | `commit` | string | ❌ | latest | Specific commit SHA to release |
908
+ | `dry_run` | boolean | ❌ | `false` | Test without actual publishing |
909
+
910
+ **Jobs:**
911
+ - `validate` - Validates TypeScript compilation and builds
912
+ - `hotfix` - Creates emergency hotfix release and publishes
711
913
 
712
914
  **What it does:**
713
- - Validates code
714
- - Creates emergency hotfix release
715
- - Uses `release-it-preset hotfix` config
716
- - Auto-generates changelog from commits
915
+ 1. Validates code at specified commit
916
+ 2. Auto-generates changelog from recent commits
917
+ 3. Creates hotfix release (patch/minor bump)
918
+ 4. Pushes git tag
919
+ 5. **Publishes to npm with provenance**
920
+ 6. **Creates GitHub Release**
717
921
 
718
- **When to use:**
719
- Critical bugs that need immediate patch release.
922
+ **When to use:** Critical bugs needing immediate patch release
720
923
 
721
- #### 4. **Retry Publish** (`.github/workflows/retry-publish.yml`)
924
+ **Permissions required:**
925
+ ```yaml
926
+ permissions:
927
+ contents: write # For git operations
928
+ id-token: write # For npm provenance
929
+ ```
722
930
 
723
- **Trigger:** Manual (workflow_dispatch)
931
+ **Secrets required:**
932
+ - `NPM_TOKEN` - npm automation token
933
+ - `GITHUB_TOKEN` - Provided automatically
934
+
935
+ #### 4. 🔄 **Retry Publish** (`.github/workflows/retry-publish.yml`)
936
+
937
+ **Trigger:** Manual (`workflow_dispatch`)
724
938
 
725
939
  **Inputs:**
726
- - `tag_name` - Tag to republish (defaults to latest)
727
- - `npm_only` - Publish to npm only
728
- - `github_only` - Create GitHub Release only
940
+
941
+ | Input | Type | Required | Default | Description |
942
+ |-------|------|----------|---------|-------------|
943
+ | `tag_name` | string | ❌ | latest tag | Git tag to republish |
944
+ | `npm_only` | boolean | ❌ | `false` | Publish to npm only (skip GitHub Release) |
945
+ | `github_only` | boolean | ❌ | `false` | Create GitHub Release only (skip npm) |
946
+
947
+ **Jobs:**
948
+ - `determine-tag` - Validates and determines which tag to publish
949
+ - `build-dist` - Builds distribution using reusable workflow
950
+ - `retry-publish` - Republishes to npm and/or GitHub
729
951
 
730
952
  **What it does:**
731
- - Republishes existing tag to npm and/or GitHub
732
- - Runs pre-flight checks
733
- - Extracts changelog for release notes
953
+ 1. Verifies git tag exists
954
+ 2. Runs pre-flight checks (`retry-publish.js` script)
955
+ 3. Republishes to selected destination(s)
956
+ 4. Uses existing changelog for release notes
734
957
 
735
- **When to use:**
736
- When previous publish failed (network issue, auth problem, etc.)
958
+ **When to use:** Previous publish failed (network issue, auth problem, etc.)
737
959
 
738
- #### 5. **Republish (EXCEPTIONAL)** (`.github/workflows/republish.yml`)
960
+ **Permissions required:**
961
+ ```yaml
962
+ permissions:
963
+ contents: write # For GitHub releases
964
+ id-token: write # For npm provenance
965
+ ```
966
+
967
+ **Secrets required:**
968
+ - `NPM_TOKEN` - npm automation token (if npm publish enabled)
969
+ - `GITHUB_TOKEN` - Provided automatically
970
+
971
+ #### 5. ⚠️ **Republish (EXCEPTIONAL)** (`.github/workflows/republish.yml`)
739
972
 
740
- **Trigger:** Manual (workflow_dispatch)
973
+ **Trigger:** Manual (`workflow_dispatch`)
974
+
975
+ **⚠️ DANGER:** Moves existing git tag (breaks semver immutability)
741
976
 
742
977
  **Inputs:**
743
- - `version` - Version to republish (e.g., 1.2.3)
744
- - `confirmation` - Must type "I understand the risks"
978
+
979
+ | Input | Type | Required | Description |
980
+ |-------|------|----------|-------------|
981
+ | `version` | string | ✅ | Version to republish (e.g., `1.2.3`) |
982
+ | `confirmation` | string | ✅ | Must type exactly `"I understand the risks"` |
983
+
984
+ **Jobs:**
985
+ - `pre-flight-checks` - Validates confirmation, version format, and tag existence
986
+ - `build-dist` - Builds distribution using reusable workflow
987
+ - `validate` - Validates TypeScript compilation
988
+ - `republish` - Moves git tag and republishes
745
989
 
746
990
  **What it does:**
747
- ⚠️ **DANGER**: Moves existing git tag (breaks semver immutability)
748
- - Pre-flight safety checks
749
- - 10-second delay before execution
750
- - Validates code
751
- - Moves git tag to current commit
752
- - Updates changelog
753
- - Republishes to npm
754
- - Updates GitHub Release
755
- - Creates audit trail document
991
+ 1. **Pre-flight safety checks:**
992
+ - Validates confirmation phrase
993
+ - Checks version format
994
+ - Verifies tag exists
995
+ - Displays warning message
996
+ - **10-second safety delay** ⏰
997
+ 2. Validates code compilation
998
+ 3. **Moves git tag to current commit** (⚠️ breaks immutability)
999
+ 4. Updates changelog for current version
1000
+ 5. Republishes to npm with provenance
1001
+ 6. Updates GitHub Release
1002
+ 7. Creates audit trail document
1003
+
1004
+ **When to use:** ONLY for exceptional emergencies where a published version has critical security issues
1005
+
1006
+ **Permissions required:**
1007
+ ```yaml
1008
+ permissions:
1009
+ contents: write # For git tag operations
1010
+ id-token: write # For npm provenance
1011
+ ```
1012
+
1013
+ **Secrets required:**
1014
+ - `NPM_TOKEN` - npm automation token
1015
+ - `GITHUB_TOKEN` - Provided automatically
1016
+
1017
+ **Concurrency:** Prevents parallel republish operations for same version
1018
+
1019
+ #### 6. 📦 **Publish** (`.github/workflows/publish.yml`)
756
1020
 
757
- **When to use:**
758
- ONLY for exceptional cases where a published version has critical issues and must be replaced.
1021
+ **Triggers:**
1022
+ - Tag push matching `v*` pattern
1023
+ - Can be called as reusable workflow (`workflow_call`)
759
1024
 
760
- #### 6. **Publish** (`.github/workflows/publish.yml`)
1025
+ **Inputs (for `workflow_call`):**
761
1026
 
762
- **Trigger:** Tag push (v*)
1027
+ | Input | Type | Required | Description |
1028
+ |-------|------|----------|-------------|
1029
+ | `tag` | string | ❌ | Override tag (auto-detected from `github.ref_name`) |
1030
+
1031
+ **Jobs:**
1032
+ - `build-dist` - Builds distribution using reusable workflow
1033
+ - `publish` - Updates GitHub release and publishes to npm
763
1034
 
764
1035
  **What it does:**
765
- - Runs `release-it-preset retry-publish --ci` to refresh the GitHub release notes and publish to npm with provenance
766
- - Triggered automatically when release-it creates and pushes a tag
1036
+ 1. Builds compiled distribution
1037
+ 2. Runs `release-it-preset retry-publish --ci`
1038
+ 3. Creates/updates GitHub Release with changelog
1039
+ 4. Publishes to npm with provenance attestation
1040
+
1041
+ **When it runs:** Automatically triggered when a tag is pushed (e.g., by `default` or `hotfix` workflows)
1042
+
1043
+ **Permissions required:**
1044
+ ```yaml
1045
+ permissions:
1046
+ contents: write # For GitHub releases
1047
+ id-token: write # For npm provenance attestation
1048
+ ```
767
1049
 
768
- **Note:** The workflow exports `GITHUB_RELEASE=true` and `NPM_PUBLISH=true`, so both actions happen together in CI.
1050
+ **Secrets required (for `workflow_call`):**
1051
+ - `NPM_TOKEN` - npm automation token (must be passed explicitly)
1052
+
1053
+ **Secrets required (for tag push):**
1054
+ - `NPM_TOKEN` - npm automation token (repository secret)
1055
+ - `GITHUB_TOKEN` - Provided automatically
1056
+
1057
+ **Environment variables set:**
1058
+ - `GITHUB_RELEASE=true` - Enables GitHub release creation
1059
+ - `NPM_PUBLISH=true` - Enables npm publishing
1060
+
1061
+ ---
1062
+
1063
+ ### Workflows Summary Diagram
1064
+
1065
+ ```mermaid
1066
+ graph TB
1067
+ subgraph "Reusable Workflows"
1068
+ RV[🔄 reusable-verify.yml<br/>PR validation & hygiene]
1069
+ BD[🔄 build-dist.yml<br/>Build TypeScript dist]
1070
+ end
1071
+
1072
+ subgraph "Development Flow"
1073
+ PR[Pull Request] --> VPR[✅ validate-pr.yml]
1074
+ VPR --> RV
1075
+ VPR --> Comment[Post PR comment]
1076
+ end
1077
+
1078
+ subgraph "Release Flow"
1079
+ Manual[Manual Trigger] --> CI[⚙️ ci.yml]
1080
+ CI --> BD
1081
+ CI --> Tag[Create Tag]
1082
+ Tag --> PUB[📦 publish.yml]
1083
+ PUB --> BD
1084
+ PUB --> NPM[npm publish]
1085
+ PUB --> GH[GitHub Release]
1086
+ end
1087
+
1088
+ subgraph "Emergency Flow"
1089
+ Critical[Critical Bug] --> HF[🚨 hotfix.yml]
1090
+ HF --> BD
1091
+ HF --> Tag
1092
+ end
1093
+
1094
+ subgraph "Recovery Flow"
1095
+ Failed[Failed Publish] --> RP[🔄 retry-publish.yml]
1096
+ RP --> BD
1097
+ RP --> Decision{Retry What?}
1098
+ Decision -->|npm only| NPM
1099
+ Decision -->|GitHub only| GH
1100
+ Decision -->|Both| Both[npm + GitHub]
1101
+ end
1102
+
1103
+ style RV fill:#e1f5fe
1104
+ style BD fill:#e1f5fe
1105
+ style VPR fill:#c8e6c9
1106
+ style CI fill:#fff9c4
1107
+ style HF fill:#ffccbc
1108
+ style RP fill:#b2ebf2
1109
+ style PUB fill:#d1c4e9
1110
+ ```
769
1111
 
770
1112
  ## Best Practices
771
1113
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oorabona/release-it-preset",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "Shared release-it configuration and scripts for the organisation",
5
5
  "type": "module",
6
6
  "keywords": [