Skip to content

Commit cda876a

Browse files
committed
Add release.sh script and simplify release workflow
- Create release.sh script with comprehensive pre-flight checks - Script performs version bump, CHANGELOG update, tag creation, and atomic push - Automatic rollback on push failure - Simplify .github/workflows/release.yml to trigger on v* tags only - Remove git operations from GitHub workflow (now done locally via script) - Update CONTRIBUTING.md with new release process documentation - Update BUILDING.md to reference release.sh script - Filter automated commits from release changelog
1 parent ef9d879 commit cda876a

4 files changed

Lines changed: 329 additions & 125 deletions

File tree

.github/workflows/release.yml

Lines changed: 9 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,7 @@ name: Release
33
on:
44
push:
55
tags:
6-
- 'release-patch'
7-
- 'release-minor'
8-
- 'release-major'
9-
workflow_dispatch:
10-
inputs:
11-
bump_type:
12-
description: 'Version bump type'
13-
required: true
14-
type: choice
15-
options:
16-
- patch
17-
- minor
18-
- major
6+
- 'v*' # Trigger on version tags (v0.6.4, v1.0.0, etc.)
197

208
permissions:
219
contents: write
@@ -29,10 +17,17 @@ jobs:
2917
- name: Checkout code
3018
uses: actions/checkout@v4
3119
with:
32-
ref: main # Always checkout main branch, not the tag
3320
fetch-depth: 0 # Full history needed for changelog
3421
token: ${{ secrets.GITHUB_TOKEN }}
3522

23+
- name: Get version from tag
24+
id: version
25+
run: |
26+
# Extract version from tag (v0.6.4 -> 0.6.4)
27+
VERSION=${GITHUB_REF#refs/tags/v}
28+
echo "version=$VERSION" >> $GITHUB_OUTPUT
29+
echo "Release version: $VERSION"
30+
3631
- name: Setup .NET 9
3732
uses: actions/setup-dotnet@v3
3833
with:
@@ -41,29 +36,6 @@ jobs:
4136
- name: Install zip utility
4237
run: sudo apt-get update && sudo apt-get install -y zip
4338

44-
- name: Extract bump type from tag or input
45-
id: bump
46-
run: |
47-
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
48-
BUMP_TYPE="${{ inputs.bump_type }}"
49-
else
50-
BUMP_TYPE=${GITHUB_REF#refs/tags/release-}
51-
fi
52-
echo "type=$BUMP_TYPE" >> $GITHUB_OUTPUT
53-
echo "Bump type: $BUMP_TYPE"
54-
55-
- name: Bump version in all files
56-
run: |
57-
chmod +x bump-version.sh get-version.sh
58-
./bump-version.sh ${{ steps.bump.outputs.type }} -y
59-
60-
- name: Get new version
61-
id: version
62-
run: |
63-
VERSION=$(./get-version.sh)
64-
echo "version=$VERSION" >> $GITHUB_OUTPUT
65-
echo "New version: $VERSION"
66-
6739
- name: Generate changelog from commits
6840
id: changelog
6941
run: |
@@ -93,44 +65,6 @@ jobs:
9365
echo "EOF"
9466
} >> $GITHUB_OUTPUT
9567
96-
- name: Update CHANGELOG.md
97-
run: |
98-
VERSION=${{ steps.version.outputs.version }}
99-
DATE=$(date +%Y-%m-%d)
100-
101-
# Create new version section with current date
102-
sed -i "s/## \[Unreleased\]/## [Unreleased]\n\n## [$VERSION] - $DATE/" CHANGELOG.md
103-
104-
# Update version comparison links at bottom
105-
PREV_TAG=$(git describe --tags --abbrev=0 --match "v[0-9]*" HEAD^ 2>/dev/null || echo "")
106-
if [ -n "$PREV_TAG" ]; then
107-
# Update [Unreleased] link
108-
sed -i "s|\[Unreleased\]:.*|[Unreleased]: https://github.com/${{ github.repository }}/compare/v$VERSION...HEAD|" CHANGELOG.md
109-
# Add new version link
110-
sed -i "/\[Unreleased\]:/a [$VERSION]: https://github.com/${{ github.repository }}/compare/${PREV_TAG}...v$VERSION" CHANGELOG.md
111-
else
112-
# First release
113-
sed -i "/\[Unreleased\]:/a [$VERSION]: https://github.com/${{ github.repository }}/releases/tag/v$VERSION" CHANGELOG.md
114-
fi
115-
116-
- name: Commit version changes
117-
run: |
118-
git config user.name "github-actions[bot]"
119-
git config user.email "github-actions[bot]@users.noreply.github.com"
120-
git add LocalizationManager.csproj CHANGELOG.md
121-
git commit -m "Bump version to ${{ steps.version.outputs.version }} [skip ci]"
122-
123-
- name: Push version commit to main
124-
run: |
125-
git push origin HEAD:main
126-
echo "✓ Pushed version commit to main"
127-
128-
- name: Create and push version tag
129-
run: |
130-
git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}"
131-
git push origin "v${{ steps.version.outputs.version }}"
132-
echo "✓ Created and pushed tag v${{ steps.version.outputs.version }}"
133-
13468
- name: Build all platforms
13569
run: |
13670
./build.sh
@@ -169,9 +103,3 @@ jobs:
169103
publish/lrm-win-arm64.zip
170104
draft: false
171105
prerelease: false
172-
173-
- name: Delete release trigger tag
174-
if: always()
175-
run: |
176-
git push origin --delete ${{ github.ref_name }} || true
177-
echo "✓ Cleaned up trigger tag"

BUILDING.md

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,37 @@ dotnet publish \
9696
Version is defined in `LocalizationManager.csproj`:
9797

9898
```xml
99-
<Version>0.6.0</Version>
100-
<AssemblyVersion>0.6.0.0</AssemblyVersion>
101-
<FileVersion>0.6.0.0</FileVersion>
99+
<Version>0.6.3</Version>
100+
<AssemblyVersion>0.6.3.0</AssemblyVersion>
101+
<FileVersion>0.6.3.0</FileVersion>
102102
```
103103

104-
To release a new version:
105-
1. Update version numbers in `.csproj`
106-
2. Update `VERSION` in `build.sh`
107-
3. Run `./build.sh`
108-
4. Test the executables
109-
5. Tag the release in git:
110-
```bash
111-
git tag -a v0.6.0 -m "Release v0.6.0"
112-
git push origin v0.6.0
113-
```
104+
### Creating a Release (Maintainers Only)
105+
106+
Use the automated release script:
107+
108+
```bash
109+
# Patch release (0.6.3 → 0.6.4)
110+
./release.sh patch
111+
112+
# Minor release (0.6.3 → 0.7.0)
113+
./release.sh minor
114+
115+
# Major release (0.6.3 → 1.0.0)
116+
./release.sh major
117+
```
118+
119+
The script will:
120+
1. Verify working directory is clean and on main branch
121+
2. Check push permissions to remote
122+
3. Bump version in `LocalizationManager.csproj` and `CHANGELOG.md`
123+
4. Create version commit and tag (e.g., `v0.6.4`)
124+
5. Push atomically to GitHub
125+
6. Trigger GitHub Actions to build and create release
126+
127+
**On failure:** All changes are automatically rolled back.
128+
129+
See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed release process documentation.
114130

115131
## Build Requirements
116132

@@ -144,11 +160,9 @@ chmod +x publish/linux-x64/lrm
144160

145161
Before releasing:
146162
- [ ] All tests passing (`dotnet test`)
147-
- [ ] Version updated in `.csproj` and `build.sh`
148-
- [ ] Build script runs successfully (`./build.sh`)
149-
- [ ] Linux executable tested (`./publish/linux-x64/lrm --version`)
150-
- [ ] Command functionality verified (`lrm validate --path TestData`)
151-
- [ ] Archives contain correct files
152-
- [ ] README files generated correctly
153-
- [ ] Git tag created
154-
- [ ] Release notes prepared
163+
- [ ] Working directory is clean (no uncommitted changes)
164+
- [ ] On main branch
165+
- [ ] Release script runs successfully (`./release.sh patch/minor/major`)
166+
- [ ] GitHub Actions workflow completes successfully
167+
- [ ] Release artifacts available on GitHub
168+
- [ ] Download and test released binaries

CONTRIBUTING.md

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -233,22 +233,46 @@ public void Validate_ShouldDetectMissingKeys_WhenTranslationIsMissing()
233233

234234
## Release Process
235235

236-
Releases are fully automated via GitHub Actions:
236+
Releases are created using the `release.sh` script:
237237

238-
1. Maintainer pushes a release tag: `git tag release-patch && git push origin release-patch`
239-
- Use `release-patch` for bug fixes (0.6.2 → 0.6.3)
240-
- Use `release-minor` for new features (0.6.2 → 0.7.0)
241-
- Use `release-major` for breaking changes (0.6.2 → 1.0.0)
238+
**For Maintainers:**
242239

243-
2. GitHub Actions workflow automatically:
244-
- Bumps version in `.csproj` and `README.md`
240+
```bash
241+
# Create a patch release (0.6.3 → 0.6.4)
242+
./release.sh patch
243+
244+
# Create a minor release (0.6.3 → 0.7.0)
245+
./release.sh minor
246+
247+
# Create a major release (0.6.3 → 1.0.0)
248+
./release.sh major
249+
```
250+
251+
**What the script does:**
252+
253+
1. **Pre-flight checks:**
254+
- Verifies working directory is clean
255+
- Confirms you're on main branch
256+
- Tests remote connection and push permissions
257+
258+
2. **Version bump:**
259+
- Bumps version in `LocalizationManager.csproj`
245260
- Updates `CHANGELOG.md` with new version and date
246-
- Commits version changes back to main
247-
- Creates version tag (e.g., `v0.6.3`)
248-
- Runs all tests
249-
- Builds all 4 platforms (Linux/Windows x64/ARM64)
250-
- Creates GitHub release with binaries and changelog
251-
- Cleans up the trigger tag
261+
- Creates a commit with version changes
262+
263+
3. **Tag and push:**
264+
- Creates version tag (e.g., `v0.6.4`)
265+
- Pushes commit and tag atomically to GitHub
266+
267+
4. **On push failure:**
268+
- Automatically rolls back all changes
269+
- No manual cleanup needed
270+
271+
**GitHub Actions then:**
272+
- Triggers on the version tag
273+
- Runs all tests
274+
- Builds all 4 platforms (Linux/Windows x64/ARM64)
275+
- Creates GitHub release with binaries and changelog
252276

253277
**Note:** Contributors don't need to worry about version numbers or releases. Maintainers handle the release process.
254278

@@ -308,19 +332,17 @@ git commit -m "Added new export format"
308332

309333
### 3. Release Workflow (`.github/workflows/release.yml`)
310334

311-
**Triggers:** Push of special tags: `release-patch`, `release-minor`, `release-major`
335+
**Triggers:** Push of version tags (e.g., `v0.6.4`, `v1.0.0`)
312336

313337
**What it does:**
314-
- Bumps version in `.csproj` and `README.md`
315-
- Updates CHANGELOG.md with version and date
316-
- Commits version changes
317-
- Creates version tag (e.g., `v0.6.3`)
338+
- Extracts version from tag
339+
- Generates changelog from commits since last release
318340
- Runs all tests
319-
- Builds all 4 platforms
320-
- Creates GitHub release with binaries
321-
- Cleans up trigger tag
341+
- Builds all 4 platforms (Linux/Windows x64/ARM64)
342+
- Creates archives with static filenames (lrm-linux-x64.tar.gz, etc.)
343+
- Creates GitHub release with binaries and changelog
322344

323-
**Note:** Only maintainers trigger releases.
345+
**Note:** Version tags are created by the `release.sh` script. Only maintainers create releases.
324346

325347
## Development Workflow
326348

@@ -382,7 +404,7 @@ git pull upstream main # or: git pull origin main
382404
```
383405

384406
**Also pull after releases:**
385-
- When a maintainer creates a release, version files are updated
407+
- When a maintainer creates a release, `LocalizationManager.csproj` and `CHANGELOG.md` are updated
386408
- Always sync before starting new work to avoid conflicts
387409

388410
### Commit Message Best Practices

0 commit comments

Comments
 (0)