|
| 1 | +# Release Workflow Guide |
| 2 | + |
| 3 | +This document explains the CI/CD setup and release process for Variable Content Width. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The project uses GitHub Actions to automatically build and distribute the CSS snippet. This ensures: |
| 8 | +- Clean git history (no built files committed) |
| 9 | +- Reproducible builds (consistent environment) |
| 10 | +- Automated releases (one command to publish) |
| 11 | +- Build validation on every PR |
| 12 | + |
| 13 | +## Architecture |
| 14 | + |
| 15 | +### Source Code (Git) |
| 16 | +``` |
| 17 | +src/ |
| 18 | +├── variable-content-width.css # Entry point |
| 19 | +└── modules/ |
| 20 | + ├── _vars.css # Variables |
| 21 | + ├── _containers.css # Container queries |
| 22 | + ├── preview.css # Preview mode |
| 23 | + ├── source.css # Source mode |
| 24 | + ├── mobile.css # Mobile styles |
| 25 | + ├── a11y.css # Accessibility |
| 26 | + ├── print.css # Print styles |
| 27 | + └── debug.css # Debug mode |
| 28 | +``` |
| 29 | + |
| 30 | +### Built Output (NOT in Git) |
| 31 | +``` |
| 32 | +variable-content-width.css # Built, distributed via releases |
| 33 | +variable-content-width.css.map # Source maps (dev only) |
| 34 | +``` |
| 35 | + |
| 36 | +### CI/CD Workflows |
| 37 | + |
| 38 | +#### 1. Build Workflow (`build.yml`) |
| 39 | +**Triggers**: Every push/PR to main or version branches |
| 40 | + |
| 41 | +**Purpose**: Validate that code builds successfully |
| 42 | + |
| 43 | +**Steps**: |
| 44 | +1. Checkout code |
| 45 | +2. Install dependencies (`npm ci`) |
| 46 | +3. Build CSS (`npm run build`) |
| 47 | +4. Verify output exists |
| 48 | +5. Upload artifact (available for 30 days) |
| 49 | + |
| 50 | +**Result**: Green checkmark on PRs means code will build successfully |
| 51 | + |
| 52 | +#### 2. Release Workflow (`release.yml`) |
| 53 | +**Triggers**: When a version tag is pushed (e.g., `v0.2.0`) |
| 54 | + |
| 55 | +**Purpose**: Automatically create releases with built CSS |
| 56 | + |
| 57 | +**Steps**: |
| 58 | +1. Checkout code |
| 59 | +2. Install dependencies |
| 60 | +3. Build CSS from source |
| 61 | +4. Create GitHub release with the tag |
| 62 | +5. Attach built CSS as downloadable asset |
| 63 | +6. Auto-generate release notes |
| 64 | + |
| 65 | +**Result**: Users can download `variable-content-width.css` from the release page |
| 66 | + |
| 67 | +## Creating a Release |
| 68 | + |
| 69 | +### Method 1: Using the Prepare Script (Recommended) |
| 70 | + |
| 71 | +```bash |
| 72 | +npm run prepare-release |
| 73 | +``` |
| 74 | + |
| 75 | +This interactive script will: |
| 76 | +1. Check for uncommitted changes |
| 77 | +2. Prompt for version bump type |
| 78 | +3. Update `package.json` |
| 79 | +4. Build CSS to verify it works |
| 80 | +5. Remind you to update `CHANGELOG.md` |
| 81 | +6. Provide exact commands to complete the release |
| 82 | + |
| 83 | +### Method 2: Manual Steps |
| 84 | + |
| 85 | +1. **Update version in package.json** |
| 86 | + ```bash |
| 87 | + npm version patch # or minor, or major |
| 88 | + # This creates: 0.2.0 → 0.2.1 (patch) |
| 89 | + # 0.2.0 → 0.3.0 (minor) |
| 90 | + # 0.2.0 → 1.0.0 (major) |
| 91 | + ``` |
| 92 | + |
| 93 | +2. **Update CHANGELOG.md** |
| 94 | + - Change `## [0.2.0] - TBD` to `## [0.2.0] - 2025-10-05` |
| 95 | + - Add release notes under appropriate sections |
| 96 | + |
| 97 | +3. **Test the build locally** |
| 98 | + ```bash |
| 99 | + npm run build |
| 100 | + # Verify it builds without errors |
| 101 | + # Built file will be ignored by git |
| 102 | + ``` |
| 103 | + |
| 104 | +4. **Commit changes** |
| 105 | + ```bash |
| 106 | + git add package.json CHANGELOG.md |
| 107 | + git commit -m "Release v0.2.0" |
| 108 | + git push origin main |
| 109 | + ``` |
| 110 | + |
| 111 | +5. **Create and push the version tag** |
| 112 | + ```bash |
| 113 | + git tag v0.2.0 |
| 114 | + git push origin v0.2.0 |
| 115 | + ``` |
| 116 | + |
| 117 | +6. **Wait for GitHub Actions** |
| 118 | + - Go to: https://github.com/Bregor/obsidian-variable-content-width/actions |
| 119 | + - Watch the "Release" workflow run |
| 120 | + - Should complete in ~1-2 minutes |
| 121 | + |
| 122 | +7. **Verify the release** |
| 123 | + - Go to: https://github.com/Bregor/obsidian-variable-content-width/releases |
| 124 | + - Verify the release was created |
| 125 | + - Verify `variable-content-width.css` is attached |
| 126 | + - Test downloading and using it in Obsidian |
| 127 | + |
| 128 | +## Versioning Strategy |
| 129 | + |
| 130 | +Follow [Semantic Versioning](https://semver.org/): |
| 131 | + |
| 132 | +- **Patch** (0.2.0 → 0.2.1): Bug fixes, no new features |
| 133 | +- **Minor** (0.2.0 → 0.3.0): New features, backward compatible |
| 134 | +- **Major** (0.2.0 → 1.0.0): Breaking changes |
| 135 | + |
| 136 | +## Distribution Model |
| 137 | + |
| 138 | +### For Users |
| 139 | +1. Go to [Releases](https://github.com/Bregor/obsidian-variable-content-width/releases) |
| 140 | +2. Download `variable-content-width.css` from latest release |
| 141 | +3. Install in Obsidian snippets folder |
| 142 | + |
| 143 | +### For Contributors |
| 144 | +1. Clone repository |
| 145 | +2. Edit source files in `src/` |
| 146 | +3. Run `npm run watch` for live rebuilding |
| 147 | +4. Submit PR (built file is NOT included) |
| 148 | +5. CI validates the build automatically |
| 149 | + |
| 150 | +## Troubleshooting |
| 151 | + |
| 152 | +### Build fails in CI |
| 153 | +- Run `npm run build` locally to see the error |
| 154 | +- Fix the issue in source files |
| 155 | +- Commit and push the fix |
| 156 | + |
| 157 | +### Release workflow doesn't trigger |
| 158 | +- Ensure you pushed the tag: `git push origin v0.2.0` |
| 159 | +- Check that tag format matches `v*` pattern |
| 160 | +- Verify workflows are enabled in repository settings |
| 161 | + |
| 162 | +### Release created but no CSS attached |
| 163 | +- Check workflow logs for build errors |
| 164 | +- Verify `variable-content-width.css` is created during build |
| 165 | +- Check file path in `release.yml` is correct |
| 166 | + |
| 167 | +### Want to delete a bad release |
| 168 | +```bash |
| 169 | +# Delete the tag locally |
| 170 | +git tag -d v0.2.0 |
| 171 | + |
| 172 | +# Delete the tag remotely |
| 173 | +git push origin :refs/tags/v0.2.0 |
| 174 | + |
| 175 | +# Delete the release on GitHub (use web UI) |
| 176 | +``` |
| 177 | + |
| 178 | +Then fix the issue and create a new release with a bumped version. |
| 179 | + |
| 180 | +## Best Practices |
| 181 | + |
| 182 | +1. **Always test locally before tagging** |
| 183 | + ```bash |
| 184 | + npm run build |
| 185 | + # Test the built CSS in Obsidian |
| 186 | + ``` |
| 187 | + |
| 188 | +2. **Update CHANGELOG.md before releasing** |
| 189 | + - Users read this to understand changes |
| 190 | + - Include migration notes for breaking changes |
| 191 | + |
| 192 | +3. **Use meaningful commit messages** |
| 193 | + - CI logs will reference these |
| 194 | + - Helps with debugging failed releases |
| 195 | + |
| 196 | +4. **One release at a time** |
| 197 | + - Don't create multiple tags simultaneously |
| 198 | + - Wait for previous release workflow to complete |
| 199 | + |
| 200 | +5. **Monitor the Actions tab** |
| 201 | + - Watch for build failures |
| 202 | + - Address issues quickly |
| 203 | + |
| 204 | +## Future Enhancements |
| 205 | + |
| 206 | +Potential improvements to consider: |
| 207 | + |
| 208 | +- [ ] Automated changelog generation from commits |
| 209 | +- [ ] Pre-release/beta distribution via branches |
| 210 | +- [ ] CSS minification for smaller file size |
| 211 | +- [ ] Automated testing of CSS validity |
| 212 | +- [ ] Version bump suggestions based on commit messages |
| 213 | +- [ ] Slack/Discord notifications on releases |
0 commit comments