@afoures/auto-release 0.2.12 → 0.4.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.
@@ -0,0 +1,195 @@
1
+ # Configuration
2
+
3
+ ## Projects
4
+
5
+ The `projects` object defines each releasable unit:
6
+
7
+ ```typescript
8
+ projects: {
9
+ 'my-app': {
10
+ // Components: where versions are read/written
11
+ components: [
12
+ node('packages/my-app'),
13
+ node('packages/shared'),
14
+ ],
15
+
16
+ // Versioning strategy
17
+ versioning: semver(),
18
+
19
+ // Changelog file path
20
+ changelog: 'apps/my-app/CHANGELOG.md',
21
+ },
22
+ }
23
+ ```
24
+
25
+ ## Grouping Projects
26
+
27
+ Projects can be grouped to release together in a single pull/merge request using the `release_group` option.
28
+
29
+ ### Default Behavior
30
+
31
+ By default, each project is its own group (releases individually). The group name defaults to the project name.
32
+
33
+ ### Custom Groups
34
+
35
+ ```typescript
36
+ export default define_config({
37
+ projects: {
38
+ "web-app": {
39
+ release_group: "frontend", // Groups with other "frontend" projects
40
+ components: [...],
41
+ versioning: semver(),
42
+ changelog: "./CHANGELOG.md",
43
+ },
44
+ "mobile-app": {
45
+ release_group: "frontend", // Same group - released together
46
+ components: [...],
47
+ versioning: semver(),
48
+ changelog: "./CHANGELOG.md",
49
+ },
50
+ "api": {
51
+ // No release_group - defaults to "api" (individual release)
52
+ components: [...],
53
+ versioning: semver(),
54
+ changelog: "./CHANGELOG.md",
55
+ },
56
+ },
57
+ });
58
+ ```
59
+
60
+ **Resulting behavior:**
61
+
62
+ - Changes to `web-app` or `mobile-app` create a single PR with both projects
63
+ - Changes to `api` create an individual PR
64
+ - Branch name: `release/frontend` for grouped, `release/api` for individual
65
+ - PR title: `release: web-app@1.2.0, mobile-app@2.0.0` for grouped
66
+
67
+ ### Default Project Config
68
+
69
+ Set default options for all projects:
70
+
71
+ ```typescript
72
+ export default define_config({
73
+ default_project_config: {
74
+ release_group: "shared", // All projects default to this group
75
+ options: {
76
+ skip_release_if_no_change_file: true,
77
+ },
78
+ },
79
+ projects: { ... },
80
+ });
81
+ ```
82
+
83
+ ### Options
84
+
85
+ #### `skip_release_if_no_change_file`
86
+
87
+ When `true`, skip creating a release PR for projects without change files.
88
+
89
+ ```typescript
90
+ projects: {
91
+ "my-app": {
92
+ components: [...],
93
+ versioning: semver(),
94
+ changelog: "CHANGELOG.md",
95
+ options: {
96
+ skip_release_if_no_change_file: true,
97
+ },
98
+ },
99
+ }
100
+ ```
101
+
102
+ Useful for grouped projects where some projects may not have changes in every release cycle.
103
+
104
+ ## Versioning Strategies
105
+
106
+ ```typescript
107
+ import { semver, calver, markver } from 'auto-release/versioning'
108
+
109
+ // Semantic versioning: 1.2.3
110
+ versioning: semver() // Change types: major, minor, patch
111
+
112
+ // Calendar versioning: 2025.1.2
113
+ versioning: calver() // Change types: feature, fix
114
+
115
+ // Marketing versioning: 1.0.0
116
+ versioning: markver() // Change types: marketing, feature, fix
117
+ ```
118
+
119
+ ## Git Platforms
120
+
121
+ ### GitHub
122
+
123
+ ```typescript
124
+ import { github } from 'auto-release/providers'
125
+
126
+ git: {
127
+ platform: github({
128
+ token: process.env.GITHUB_TOKEN!,
129
+ owner: 'your-org',
130
+ repo: 'your-repo',
131
+ }),
132
+ target_branch: 'main',
133
+ tag_generator: ({ project, version }) => `${project.name}-${version}`,
134
+ }
135
+ ```
136
+
137
+ ### GitLab
138
+
139
+ ```typescript
140
+ import { gitlab } from 'auto-release/providers'
141
+
142
+ git: {
143
+ platform: gitlab({
144
+ token: process.env.GITLAB_TOKEN!,
145
+ project_id: 'your-project-id',
146
+ }),
147
+ target_branch: 'main',
148
+ }
149
+ ```
150
+
151
+ ## Tag Generator
152
+
153
+ Customize the format of git tags created during release:
154
+
155
+ ```typescript
156
+ git: {
157
+ // ... other options
158
+ tag_generator: ({ project, version }) => `${project.name}-${version}`,
159
+ }
160
+ ```
161
+
162
+ **Default**: `project-name@version` (e.g., `my-app@1.2.3`)
163
+
164
+ **Custom examples**:
165
+
166
+ ```typescript
167
+ // Version only: 1.2.3
168
+ tag_generator: ({ version }) => `${version}`
169
+
170
+ // Prefixed: v1.2.3
171
+ tag_generator: ({ version }) => `v${version}`
172
+
173
+ // With prefix: release/my-app-1.2.3
174
+ tag_generator: ({ project, version }) => `release/${project.name}-${version}`
175
+ ```
176
+
177
+ ## Components
178
+
179
+ Components define version sources:
180
+
181
+ - **`node(path)`**: any node project with package.json
182
+ - **`bun(path)`**: any bun project with package.json
183
+ - **`expo(path)`**: any Expo project with package.json and app.json
184
+ - **`php(path)`**: any PHP project with composer.json
185
+
186
+ ```typescript
187
+ import { node, expo, php } from 'auto-release/components'
188
+
189
+ components: [
190
+ node('packages/web'),
191
+ bun('packages/bff'),
192
+ expo('apps/mobile'),
193
+ php('packages/api'),
194
+ ]
195
+ ```
@@ -0,0 +1,23 @@
1
+ # `auto-release` Lexicon
2
+
3
+ This is a list of words and phrases used in `auto-release` to help contributors and users have a shared understanding of various concepts in the project.
4
+
5
+ - **change file** - A markdown file documenting a single change to a project. Change files are stored in the changes directory with the format `<kind>.<slug>.md` (e.g., `major.add-authentication.md`). Change files are stackable, running `generate-release-pr` will apply any number of change files correctly to calculate the next version and generate changelog entries.
6
+ - **changes directory** - The `.changes/` folder where change files are stored. This directory contains subdirectories for each project (e.g., `.changes/my-app/`), and each subdirectory contains the change files for that project.
7
+ - **change kind** - The type of change represented by a change file (e.g., `major`, `minor`, `patch`, `feature`, `fix`). The valid kinds for a project are defined by its versioning strategy's `allowed_changes`. This determines how the version will be bumped.
8
+ - **slug** - A unique identifier for a change file, used in the filename between the kind and the `.md` extension. Generated automatically or provided by the user (e.g., `add-authentication` in `major.add-authentication.md`).
9
+ - **project** - A releasable unit in your repository or monorepo. Each project has its own independent versioning strategy, one or more components, its own changelog, and a dedicated subdirectory in the changes directory. Projects are defined in the configuration file.
10
+ - **component** - A source of version information within a project. Components define where versions are read from and written to. Built-in component types include `node()/bun()` for package.json files, `expo()` for app.json files, and `php()` for composer.json files. All components within a project must have the same version.
11
+ - **versioning strategy** - Defines how versions are calculated and formatted for a project. Each strategy specifies valid change kinds and a `bump()` function to compute the next version from the current version and collected change kinds.
12
+ - **bump**
13
+ - (1) The command/process to apply all current change files, calculate new versions, update all component files, update changelogs, and remove processed change files.
14
+ - (2) The act of updating a project's version to a new version based on change files.
15
+ - **changelog** - A markdown file where release entries are appended for a project. Each project specifies its changelog path in the configuration. Changelog entries are generated from change file summaries using the formatter.
16
+ - **formatter** - Controls how changelogs and release notes are generated from change files. The formatter can parse markdown from change files and format changelog sections. The default formatter groups changes by kind and outputs markdown lists.
17
+ - **target branch** - The main branch where releases are merged to (typically `main` or `master`). This is the branch that release PRs target and where version tags are created.
18
+ - **release branch** - A branch created by the `generate-release-pr` command containing updated versions in all component files, new changelog entries, and removed change files. Format: `<prefix>/<project-name>` (e.g., `release/my-app`).
19
+ - **release PR** - A pull request from a release branch to the target branch, containing all version updates and changelog changes for a release. Created or updated by the `generate-release-pr` command.
20
+ - **git platform** - The hosting service for your git repository (GitHub or GitLab). The git platform integration is used to create and update release PRs, manage release notes, and interact with the repository API. Configured in the configuration file with authentication tokens.
21
+ - **tag** - A git tag created when a version change is detected on the target branch after a release PR is merged. Format: `<project-name>@<version>` (e.g., `my-app@1.2.3`). Created by the `tag-release-commit` command, typically run in CI.
22
+ - **release** - The combination of versioning, updating changelogs, creating a git tag, and publishing release notes on the git platform. This happens when a release PR is merged and the `tag-release-commit` command detects the version change.
23
+ - **config file** - The `auto-release.config.ts` TypeScript configuration file at the root of your repository. Defines projects, their components, versioning strategies, changelog paths, and git platform settings.
@@ -0,0 +1,155 @@
1
+ # Recommended Usage Guide
2
+
3
+ This guide explains the recommended automated release workflow for the `auto-release` CLI.
4
+
5
+ ## Overview
6
+
7
+ This release workflow streamlines your release process by combining developer-led change tracking with CI-driven release generation. This approach offers several key benefits:
8
+
9
+ - **Testing before production**: Release candidates can be tested on staging before final deployment
10
+ - **Automated changelogs**: Change descriptions are automatically compiled into changelog
11
+ - **Safety through PRs**: All releases go through pull request review, preventing accidental deployments
12
+ - **Audit trail**: Every release is traceable through recorded change files and version history
13
+
14
+ ## Workflow Diagram
15
+
16
+ // TODO
17
+
18
+ ## The Automated Release Workflow
19
+
20
+ ### Step 1: Developer Records Changes
21
+
22
+ Throughout development, developers record changes as they are made:
23
+
24
+ ```bash
25
+ # Record a feature change for a specific project
26
+ auto-release record-change --project myapp --type feature
27
+
28
+ # Record a bug fix
29
+ auto-release record-change --project myapp --type fix
30
+
31
+ # Record a breaking change
32
+ auto-release record-change --project myapp --type breaking
33
+ ```
34
+
35
+ This command:
36
+
37
+ - Creates a change file in `.changes/<project>/`
38
+ - Opens your default editor for a detailed description
39
+ - Generates a unique filename with timestamp
40
+
41
+ After recording, commit the change file alongside your code changes:
42
+
43
+ ```bash
44
+ git add .changes/myapp/
45
+ git commit -m "feat: add new login feature"
46
+ git push
47
+ ```
48
+
49
+ ### Step 2: Merge to Main Branch
50
+
51
+ Push your changes to the main branch through your normal process.
52
+
53
+ Before pushing, you can use (locally or in CI)
54
+
55
+ ```bash
56
+ auto-release check
57
+ ```
58
+
59
+ to validate configuration and change files.
60
+
61
+ ### Step 3: CI Generates Release PR
62
+
63
+ When changes are pushed to main, CI automatically generates a release PR:
64
+
65
+ ```bash
66
+ auto-release generate-release-pr --filter myapp
67
+ ```
68
+
69
+ This command:
70
+
71
+ - Scans `.changes/` for unreleased changes
72
+ - Bumps project's version numbers based on change types
73
+ - Generates a changelog from recorded changes
74
+ - Creates a release branch (`release/<project>`)
75
+ - Opens a pull request for review
76
+
77
+ ### Step 4: CI Tests and Deploys to Staging
78
+
79
+ The release PR can trigger testing and staging deployment:
80
+
81
+ ```bash
82
+ # Run your test suite
83
+ # Build the project
84
+ # Deploy to staging environment
85
+ ```
86
+
87
+ This step ensures the release candidate works correctly before production.
88
+
89
+ ### Step 5: Merge Release PR
90
+
91
+ After staging tests pass, the team reviews and merges the release PR:
92
+
93
+ - Review the version changes and changelog
94
+ - Approve and merge to main
95
+ - Version changes now land on main
96
+
97
+ ### Step 6: CI Tags and Deploys to Production
98
+
99
+ When the release PR is merged, CI creates tags and triggers production deployment:
100
+
101
+ ```bash
102
+ auto-release tag-release-commit
103
+ ```
104
+
105
+ This command:
106
+
107
+ - Compares HEAD with HEAD^1 to find the merge commit
108
+ - Creates git tags for each project (`<project>@<version>`)
109
+ - Creates releases on the platform (GitHub/GitLab)
110
+ - Tags trigger production deployment CI
111
+
112
+ ## Hot Fixes and Manual Releases
113
+
114
+ The `manual-release` command is available for special scenarios:
115
+
116
+ ```bash
117
+ auto-release manual-release --project myapp
118
+ ```
119
+
120
+ **Usecases:**
121
+
122
+ - Local testing of release workflows
123
+ - Emergency hot fixes requiring immediate release
124
+ - Initial release setup
125
+
126
+ **Important warnings:**
127
+
128
+ - Not intended for CI use
129
+ - Bypasses the automated workflow safety checks
130
+ - Use only when the automated workflow is not suitable
131
+
132
+ ## Best Practices for Developers
133
+
134
+ ### When to Record Changes
135
+
136
+ Record changes as soon as you complete a feature or fix. Don't wait until release time, this ensures accurate changelogs and better documentation.
137
+
138
+ ### Writing Effective Change Descriptions
139
+
140
+ Keep descriptions clear and concise:
141
+
142
+ - Explain what changed and why
143
+ - Include relevant context for end users
144
+ - Mention breaking changes prominently
145
+ - Include migration strategies if needed
146
+
147
+ ### Reviewing Release PRs
148
+
149
+ When reviewing release PRs:
150
+
151
+ - Verify the version bump is correct given your versioning strategy
152
+ - Read the generated changelog for clarity
153
+ - Ensure all expected changes are included
154
+
155
+ If changes are needed, you should not modify the release PR but submit code through your normal process.
package/package.json CHANGED
@@ -1,18 +1,31 @@
1
1
  {
2
2
  "name": "@afoures/auto-release",
3
- "version": "0.2.12",
3
+ "version": "0.4.0",
4
4
  "description": "A file based release management tool for monorepos",
5
5
  "homepage": "https://github.com/afoures/auto-release#readme",
6
6
  "bugs": {
7
7
  "url": "https://github.com/afoures/auto-release/issues"
8
8
  },
9
+ "license": "MIT",
10
+ "author": "Antoine Fourès <contact@afoures.com>",
9
11
  "repository": {
10
12
  "type": "git",
11
13
  "url": "git+https://github.com/afoures/auto-release.git"
12
14
  },
13
- "author": "Antoine Fourès <contact@afoures.com>",
15
+ "bin": {
16
+ "auto-release": "./dist/bin.mjs"
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "docs",
21
+ "package.json",
22
+ "README.md"
23
+ ],
24
+ "keywords": [],
14
25
  "type": "module",
15
26
  "main": "./dist/index.mjs",
27
+ "module": "./dist/index.mjs",
28
+ "types": "./dist/index.d.mts",
16
29
  "exports": {
17
30
  ".": {
18
31
  "types": "./dist/index.d.mts",
@@ -32,16 +45,6 @@
32
45
  "import": "./dist/versioning.mjs"
33
46
  }
34
47
  },
35
- "module": "./dist/index.mjs",
36
- "types": "./dist/index.d.mts",
37
- "bin": {
38
- "auto-release": "./dist/bin.mjs"
39
- },
40
- "files": [
41
- "dist",
42
- "package.json",
43
- "README.md"
44
- ],
45
48
  "dependencies": {
46
49
  "@clack/prompts": "1.0.0-alpha.9",
47
50
  "arkregex": "^0.0.5",
@@ -54,23 +57,23 @@
54
57
  "devDependencies": {
55
58
  "@types/mdast": "^4.0.4",
56
59
  "@types/node": "^24.10.4",
57
- "bumpp": "^10.3.2",
58
60
  "oxfmt": "^0.20.0",
59
61
  "oxlint": "^1.35.0",
60
62
  "tsdown": "^0.18.3",
61
63
  "typescript": "^5.9.3",
62
64
  "vitest": "^4.0.16"
63
65
  },
64
- "packageManager": "pnpm@8.15.9+sha512.499434c9d8fdd1a2794ebf4552b3b25c0a633abcee5bb15e7b5de90f32f47b513aca98cd5cfd001c31f0db454bc3804edccd578501e4ca293a6816166bbd9f81",
65
66
  "engines": {
66
67
  "node": ">=22.0.0"
67
68
  },
69
+ "packageManager": "pnpm@8.15.9+sha512.499434c9d8fdd1a2794ebf4552b3b25c0a633abcee5bb15e7b5de90f32f47b513aca98cd5cfd001c31f0db454bc3804edccd578501e4ca293a6816166bbd9f81",
68
70
  "scripts": {
69
71
  "build": "tsdown",
70
72
  "dev": "tsdown --watch",
71
73
  "test": "vitest",
72
74
  "typecheck": "tsc --noEmit",
73
75
  "lint": "oxlint",
74
- "format": "oxfmt"
76
+ "format": "oxfmt",
77
+ "auto-release.local": "node ./dist/bin.mjs"
75
78
  }
76
79
  }