-
Notifications
You must be signed in to change notification settings - Fork 70
chore: improve release steps #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| name: Prepare Release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: 'Release version (e.g., 1.2.3 or 1.2.3-alpha.1)' | ||
| required: true | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| prepare-release: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Setup Git | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| - name: Validate version | ||
| id: validate_version | ||
| run: | | ||
| VERSION="${{ inputs.version }}" | ||
|
|
||
| # Use the validation script | ||
| ./scripts/validate-version.sh "$VERSION" | ||
|
|
||
| # If validation passed, output the version | ||
| echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Create release branch | ||
| run: | | ||
| git checkout main | ||
| git pull origin main | ||
| git checkout -b release/${{ steps.validate_version.outputs.version }} | ||
|
|
||
| - name: Update versions and changelog | ||
| run: | | ||
| ./scripts/bump-version.sh ${{ steps.validate_version.outputs.version }} | ||
|
|
||
| - name: Commit changes | ||
| run: | | ||
| git add -A | ||
| git commit -m "chore(release): bump to ${{ steps.validate_version.outputs.version }}" | ||
|
|
||
| - name: Push release branch | ||
| run: | | ||
| git push origin release/${{ steps.validate_version.outputs.version }} | ||
|
|
||
| - name: Create Pull Request | ||
| uses: peter-evans/create-pull-request@98357b18bf14b5342f975ff684046ec3b2a07725 # v8.0.0 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| branch: release/${{ steps.validate_version.outputs.version }} | ||
| base: main | ||
| title: "chore(release): bump to ${{ steps.validate_version.outputs.version }}" | ||
| body: | | ||
| ## Release ${{ steps.validate_version.outputs.version }} | ||
|
|
||
| This PR was automatically created by the release workflow. | ||
|
|
||
| ### Changes | ||
| - Updated version in pubspec.yaml | ||
| - Updated version in iOS (PostHogFlutterVersion.swift) | ||
| - Updated version in Android (PostHogVersion.kt) | ||
| - Updated CHANGELOG.md | ||
|
|
||
| ### Next Steps | ||
| 1. Review and approve this PR | ||
| 2. Merge to main | ||
| 3. The release tag will be created automatically after merge | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| name: Tag Release After Merge | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [closed] | ||
| branches: | ||
| - main | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| tag-release: | ||
| if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/') | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can also be a tag, no strong pref. |
||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Extract version from branch name | ||
| id: extract_version | ||
| run: | | ||
| BRANCH="${{ github.event.pull_request.head.ref }}" | ||
| VERSION="${BRANCH#release/}" | ||
| echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
|
|
||
| # Check if version has a suffix (prerelease) | ||
| if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+-.*$ ]]; then | ||
| echo "is_prerelease=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "is_prerelease=false" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Create and push tag | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| # Create annotated tag | ||
| git tag -a "${{ steps.extract_version.outputs.version }}" -m "Release ${{ steps.extract_version.outputs.version }}" | ||
|
|
||
| # Push the tag | ||
| git push origin "${{ steps.extract_version.outputs.version }}" | ||
|
|
||
| - name: Update GitHub Release | ||
| uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0 | ||
| with: | ||
| tag_name: ${{ steps.extract_version.outputs.version }} | ||
| name: Release ${{ steps.extract_version.outputs.version }} | ||
| draft: false | ||
| prerelease: ${{ steps.extract_version.outputs.is_prerelease }} | ||
| generate_release_notes: true | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it'd be cool to extract the notes from the changelog instead |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,48 @@ | ||
| Releasing | ||
| ========= | ||
|
|
||
| Since `main` is protected, releases are done via pull requests. | ||
|
|
||
| 1. Update the CHANGELOG.md with the version | ||
| 2. Choose a tag name (e.g. `3.0.0`), this is the version number of the release. | ||
| 1. Preview releases follow the pattern `3.0.0-alpha.1`, `3.0.0-beta.1`, `3.0.0-RC.1` | ||
| 2. Execute the script with the tag's name, the script will update the version file and create a release branch. | ||
|
|
||
| ```bash | ||
| ./scripts/prepare-release.sh 3.0.0 | ||
| ``` | ||
| 3. Create a PR from the release branch to `main` | ||
| 4. Get approval and merge the PR | ||
| 5. Go to [GH Releases](https://github.com/PostHog/posthog-flutter/releases) | ||
| 6. Choose a tag name (e.g. `3.0.0`), same as step 2. | ||
| 7. Choose a release name (e.g. `3.0.0`), ideally it matches the above. | ||
| 8. Write a description of the release. | ||
| 9. Publish the release. | ||
| 10. GH Action (publish.yml) is doing everything else [automatically](https://pub.dev/packages/posthog_flutter/admin). | ||
| 11. Done. | ||
| # Automated Release Process | ||
|
|
||
| This repository uses GitHub Actions to automate the release process. The workflow ensures that all version updates and changelog modifications are completed before creating the release tag. | ||
|
|
||
| ## How It Works | ||
|
|
||
| The release process is split into two workflows: | ||
|
|
||
| ### 1. Prepare Release Workflow (`prepare-release.yml`) | ||
| - Triggered manually via GitHub Actions UI with a version input | ||
| - Creates a release branch | ||
| - Updates version in all necessary files (pubspec.yaml, iOS, Android) | ||
| - Updates CHANGELOG.md (replaces `## Next` with the version or adds it at the top) | ||
| - Creates a Pull Request to main | ||
|
|
||
| ### 2. Tag Release Workflow (`tag-release.yml`) | ||
| - Automatically triggered when a release PR is merged to main | ||
| - Creates a git tag with the version | ||
| - Creates a GitHub Release with auto-generated release notes | ||
|
Comment on lines
+9
to
+19
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we're essentially moving the manual runs of the shell scripts into a workflow dispatch. I like this approach. I suppose the only potential gap we might have would be if someone modifies the CHANGELOG, but adds their changes under a specific version instead of 'next'. Seems like we should be able to solve that, though.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
we can also disable auto-generated and parse the changelog and pass it to the GH actions |
||
|
|
||
| ## Release Steps | ||
|
|
||
| ### Step 1: Prepare Your Changes | ||
| 1. Ensure all your changes are merged to main | ||
| 2. Update CHANGELOG.md with release notes under `## Next` section (optional - if not present, version will be added at the top) | ||
|
|
||
| ### Step 2: Trigger the Release | ||
| 1. Go to Actions tab in GitHub | ||
| 2. Select "Prepare Release" workflow | ||
| 3. Click "Run workflow" | ||
| 4. Enter the version number (e.g., `5.10.0` or `5.10.0-beta.1`) | ||
| 5. Click "Run workflow" | ||
|
|
||
| ### Step 3: Review and Merge | ||
| 1. The workflow will create a PR with all version updates | ||
| 2. Review the changes | ||
| 3. Approve and merge the PR | ||
|
|
||
| ### Step 4: Automatic Tag Creation | ||
| 1. Once the PR is merged, the tag-release workflow automatically: | ||
| - Creates a git tag (e.g., `v5.10.0`) | ||
| - Creates a GitHub Release with release notes | ||
|
|
||
| ## Version Format | ||
|
|
||
| The version must follow semantic versioning: | ||
| - Format: `X.Y.Z` or `X.Y.Z-suffix` | ||
| - Examples: `1.2.3`, `2.0.0-alpha.1`, `3.1.0-beta.2` | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Validates a version string against semantic versioning format | ||
| # Usage: ./scripts/validate-version.sh <version> | ||
| # Returns: 0 if valid, 1 if invalid | ||
|
|
||
| set -e | ||
|
|
||
| if [[ $# -ne 1 ]]; then | ||
| echo "Usage: $0 <version>" | ||
| echo "Example: $0 1.2.3" | ||
| echo "Example: $0 1.2.3-alpha.1" | ||
| exit 1 | ||
| fi | ||
|
|
||
| VERSION="$1" | ||
|
|
||
| # Validate version format (e.g., 1.2.3 or 1.2.3-alpha.1) | ||
| if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then | ||
| echo "Error: Invalid version format: $VERSION" >&2 | ||
| echo "Version must match pattern: X.Y.Z or X.Y.Z-suffix (e.g., 1.2.3 or 1.2.3-alpha.1)" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Version $VERSION is valid" | ||
| exit 0 |
Uh oh!
There was an error while loading. Please reload this page.