simple-ts-sum 1.0.0

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.
package/README.md ADDED
@@ -0,0 +1,270 @@
1
+ CI/CD Pipeline Documentation
2
+
3
+ Overview
4
+ This repository implements a fully automated CI/CD pipeline for a TypeScript package following semantic release practices. The pipeline uses GitHub Actions and is designed with reusable workflows.
5
+
6
+ Labels System
7
+ Available Labels
8
+ Label Purpose Trigger
9
+ verify Triggers integration/E2E tests When added to a PR
10
+ publish Triggers release candidate generation and publishing When added to a PR
11
+ How Labels Work
12
+ Default PR Checks: Every PR automatically runs:
13
+
14
+ Linting
15
+
16
+ Build
17
+
18
+ Unit tests
19
+
20
+ Branch validation (up-to-date with main, linear history)
21
+
22
+ With verify Label:
23
+
24
+ yaml
25
+ # Additional checks triggered:
26
+ - Integration tests
27
+ - End-to-end validation
28
+ - Cross-module compatibility tests
29
+ With publish Label:
30
+
31
+ yaml
32
+ # Additional workflow:
33
+ - Version validation (checks if version exists)
34
+ - Release candidate generation
35
+ - Pre-release npm build (with -dev suffix)
36
+ - Artifact creation
37
+ Both Labels (verify + publish):
38
+
39
+ Runs all verification steps
40
+
41
+ Generates release candidate
42
+
43
+ Performs full validation before merge
44
+
45
+ Release Process Flow
46
+ 1. Development Phase
47
+ text
48
+ Developer → Creates Feature Branch → Makes Changes → Opens PR
49
+ 2. Pull Request Validation
50
+ text
51
+ PR Created → Automatic Checks Run:
52
+ ├── Code linting (ESLint/Prettier)
53
+ ├── TypeScript compilation
54
+ ├── Unit test execution
55
+ ├── Dependency validation (package-lock.json)
56
+ └── Branch policy validation
57
+ 3. Label Application
58
+ text
59
+ Maintainer Reviews → Applies Labels:
60
+ ├── `verify` → Integration tests run
61
+ ├── `publish` → Release candidate generated
62
+ └── Both → Full validation + release prep
63
+ 4. Release Candidate Generation (Pre-Merge)
64
+ text
65
+ With `publish` label:
66
+ ├── Version checked (must not exist on npm)
67
+ ├── Pre-release version created (e.g., 1.2.3-dev-abc123)
68
+ ├── Package built with dev suffix
69
+ ├── Artifacts created
70
+ └── Ready for final review
71
+ 5. Merge & Automatic Release
72
+ text
73
+ PR Merged → Automatic Release:
74
+ ├── Full validation (re-runs all checks)
75
+ ├── Version bump validation
76
+ ├── npm publication (@latest)
77
+ ├── Git tag creation (vX.Y.Z)
78
+ └── GitHub Release generation
79
+ How to Trigger Deployments
80
+ Option 1: Standard Feature Development
81
+ bash
82
+ # 1. Create feature branch
83
+ git checkout -b feature/new-feature
84
+
85
+ # 2. Make changes and commit
86
+ git add .
87
+ git commit -m "Add new feature"
88
+
89
+ # 3. Push and create PR
90
+ git push origin feature/new-feature
91
+ # Then create PR via GitHub UI
92
+ Option 2: Release Preparation
93
+ bash
94
+ # 1. Update package.json version
95
+ # Manually bump version following semver:
96
+ # - patch: 1.0.0 → 1.0.1 (bug fixes)
97
+ # - minor: 1.0.0 → 1.1.0 (new features, backward compatible)
98
+ # - major: 1.0.0 → 2.0.0 (breaking changes)
99
+
100
+ # 2. Create release branch
101
+ git checkout -b release/v1.2.3
102
+
103
+ # 3. Update version and commit
104
+ npm version patch --no-git-tag-version
105
+ git add package.json package-lock.json
106
+ git commit -m "chore: bump version to 1.2.3"
107
+
108
+ # 4. Push and create PR
109
+ git push origin release/v1.2.3
110
+
111
+ # 5. Add labels via GitHub UI:
112
+ # - Add `verify` label for integration tests
113
+ # - Add `publish` label for release candidate
114
+ Option 3: Hotfix Deployment
115
+ bash
116
+ # 1. Create hotfix from main
117
+ git checkout main
118
+ git pull
119
+ git checkout -b hotfix/critical-bug
120
+
121
+ # 2. Fix the issue and bump patch version
122
+ npm version patch --no-git-tag-version
123
+
124
+ # 3. Commit and push
125
+ git add .
126
+ git commit -m "fix: critical bug resolution"
127
+ git push origin hotfix/critical-bug
128
+
129
+ # 4. Create PR with both labels
130
+ # Labels: `verify` + `publish`
131
+ # Merge after approval → Automatic deployment
132
+ Versioning Strategy
133
+ Pre-Merge vs Post-Merge Versioning
134
+ Pre-Merge (Development Builds)
135
+ Format: X.Y.Z-dev-<short-sha>
136
+
137
+ Example: 1.2.3-dev-abc123def
138
+
139
+ When used: During PR validation with publish label
140
+
141
+ Purpose: Test the exact build that will be published
142
+
143
+ npm tag: next or dev
144
+
145
+ Key characteristic: Unique per commit, not published as latest
146
+
147
+ Post-Merge (Production Release)
148
+ Format: X.Y.Z
149
+
150
+ Example: 1.2.3
151
+
152
+ When used: After PR merge to main
153
+
154
+ Purpose: Stable production release
155
+
156
+ npm tag: latest
157
+
158
+ Key characteristic: Stable, semantic version
159
+
160
+ Version Bump Rules
161
+ yaml
162
+ # In package.json, follow SemVer:
163
+ major.X.Y (2.0.0):
164
+ - Breaking API changes
165
+ - Incompatible with previous versions
166
+
167
+ minor.X.Y (1.3.0):
168
+ - New backward-compatible features
169
+ - Deprecated functionality (still working)
170
+
171
+ patch.X.Y (1.2.4):
172
+ - Bug fixes
173
+ - Performance improvements
174
+ - Documentation updates
175
+ Example Flow
176
+
177
+
178
+
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+ Branch Protection Rules
189
+ Automated Setup
190
+ The pipeline automatically configures:
191
+
192
+ ✅ Require PR before merging
193
+
194
+ ✅ Require 1 approval minimum
195
+
196
+ ✅ Require up-to-date branch
197
+
198
+ ✅ Require status checks to pass
199
+
200
+ ✅ Linear commit history (rebase only)
201
+
202
+ ✅ Admin bypass enabled
203
+
204
+ ❌ No force pushes allowed
205
+
206
+ ❌ No branch deletions allowed
207
+
208
+ Manual Override
209
+ Admins can merge even if checks fail (for emergency fixes).
210
+
211
+ Reusable Workflows
212
+ Location
213
+ text
214
+ maksim-sialitski-innowise/devops-automation/
215
+ └── .github/workflows/
216
+ ├── pr-verification.yml # PR validation
217
+ ├── integration-tests.yml # Label: verify
218
+ ├── publish-release.yml # Label: publish + release
219
+ └── setup-repository.yml # Branch protection
220
+ Usage in Projects
221
+ yaml
222
+ # In your project's .github/workflows/ci-cd.yml
223
+ jobs:
224
+ verification:
225
+ uses: maksim-sialitski-innowise/devops-automation/.github/workflows/pr-verification.yml@main
226
+
227
+ integration:
228
+ if: contains(github.event.pull_request.labels.*.name, 'verify')
229
+ uses: maksim-sialitski-innowise/devops-automation/.github/workflows/integration-tests.yml@main
230
+ Troubleshooting
231
+ Common Issues
232
+ PR checks not running
233
+
234
+ Ensure branch is up-to-date with main
235
+
236
+ Check if package-lock.json is committed
237
+
238
+ Version already exists error
239
+
240
+ Bump version in package.json
241
+
242
+ Ensure unique version for each release
243
+
244
+ Label not triggering workflows
245
+
246
+ Labels are case-sensitive
247
+
248
+ Wait for GitHub to register label changes
249
+
250
+ npm publish failure
251
+
252
+ Check NPM_TOKEN secret exists
253
+
254
+ Verify package name is available
255
+
256
+ Emergency Procedures
257
+ Bypass all checks (Admin only):
258
+
259
+ bash
260
+ # 1. Temporarily disable branch protection
261
+ # 2. Push directly to main
262
+ # 3. Re-enable protection
263
+ # 4. Create follow-up PR to fix pipeline
264
+
265
+ Support
266
+ For pipeline issues, check:
267
+ GitHub Actions logs
268
+ npm audit results
269
+ TypeScript compilation errors
270
+ Test execution reports
@@ -0,0 +1,2 @@
1
+ export declare function sum(a: number, b: number): number;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhD"}
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sum = sum;
4
+ function sum(a, b) {
5
+ return a + b;
6
+ }
7
+ // test commit4
8
+ const result = sum(3, 5);
9
+ console.log("Result:", result);
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,kBAEC;AAFD,SAAgB,GAAG,CAAC,CAAS,EAAE,CAAS;IACtC,OAAO,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AACD,eAAe;AACf,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACzB,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "simple-ts-sum",
3
+ "version": "1.0.0",
4
+ "description": "TypeScript package with sum function for CI/CD demo",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "lint": "eslint src/ --ext .ts",
10
+ "test": "jest",
11
+ "test:integration": "jest tests/integration/",
12
+ "test:watch": "jest --watch"
13
+ },
14
+ "keywords": ["typescript", "ci-cd", "demo"],
15
+ "author": "maksim-sialitski-innowise",
16
+ "license": "ISC",
17
+ "devDependencies": {
18
+ "@types/jest": "^29.5.12",
19
+ "@typescript-eslint/eslint-plugin": "^6.20.0",
20
+ "@typescript-eslint/parser": "^6.20.0",
21
+ "eslint": "^8.56.0",
22
+ "jest": "^29.7.0",
23
+ "ts-jest": "^29.1.2",
24
+ "typescript": "^5.3.3"
25
+ },
26
+ "files": [
27
+ "dist"
28
+ ],
29
+ "engines": {
30
+ "node": ">=18.0.0"
31
+ }
32
+ }