|
| 1 | +name: Release Sourcebot |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: "Version to release (e.g., 4.10.5)" |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + permissions: |
| 15 | + contents: write |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Validate version format |
| 19 | + run: | |
| 20 | + VERSION="${{ inputs.version }}" |
| 21 | + if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9._-]+)?(\+[a-zA-Z0-9._-]+)?$ ]]; then |
| 22 | + echo "Error: Version must follow semantic versioning format (X.Y.Z)" |
| 23 | + exit 1 |
| 24 | + fi |
| 25 | +
|
| 26 | + - name: Checkout repository |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + ref: main |
| 30 | + fetch-depth: 0 |
| 31 | + |
| 32 | + - name: Check if version already exists |
| 33 | + run: | |
| 34 | + VERSION="${{ inputs.version }}" |
| 35 | + if grep -q "## \[$VERSION\]" CHANGELOG.md; then |
| 36 | + echo "Error: Version $VERSION already exists in CHANGELOG.md" |
| 37 | + exit 1 |
| 38 | + fi |
| 39 | + if git tag | grep -q "^v$VERSION$"; then |
| 40 | + echo "Error: Tag v$VERSION already exists" |
| 41 | + exit 1 |
| 42 | + fi |
| 43 | +
|
| 44 | + - name: Update CHANGELOG.md |
| 45 | + run: | |
| 46 | + VERSION="${{ inputs.version }}" |
| 47 | + DATE=$(date +%Y-%m-%d) |
| 48 | +
|
| 49 | + # Insert the new version header after the [Unreleased] line |
| 50 | + sed -i "/## \[Unreleased\]/a\\ |
| 51 | + \\ |
| 52 | + ## [$VERSION] - $DATE" CHANGELOG.md |
| 53 | +
|
| 54 | + echo "Updated CHANGELOG.md with version $VERSION" |
| 55 | + cat CHANGELOG.md | head -n 15 |
| 56 | +
|
| 57 | + - name: Configure git |
| 58 | + run: | |
| 59 | + git config user.name "github-actions[bot]" |
| 60 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 61 | +
|
| 62 | + - name: Commit CHANGELOG |
| 63 | + run: | |
| 64 | + VERSION="${{ inputs.version }}" |
| 65 | + git add CHANGELOG.md |
| 66 | + git commit -m "Release v$VERSION" |
| 67 | +
|
| 68 | + - name: Create annotated tag |
| 69 | + run: | |
| 70 | + VERSION="${{ inputs.version }}" |
| 71 | + git tag -a "v$VERSION" -m "sourcebot v$VERSION" |
| 72 | +
|
| 73 | + - name: Push changes |
| 74 | + run: | |
| 75 | + git push origin main |
| 76 | + git push origin --tags |
| 77 | +
|
| 78 | + - name: Create GitHub release |
| 79 | + env: |
| 80 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 81 | + run: | |
| 82 | + VERSION="${{ inputs.version }}" |
| 83 | + gh release create "v$VERSION" \ |
| 84 | + --verify-tag \ |
| 85 | + --generate-notes \ |
| 86 | + --latest |
0 commit comments