Merged
Conversation
Contributor
|
Size Change: +120 B (0%) Total Size: 10.3 MB
ℹ️ View Unchanged
|
Comment on lines
+9
to
+101
| name: Bump version based on PR label | ||
| runs-on: ubuntu-20.04 | ||
| if: | | ||
| github.event.pull_request.merged | ||
| && ( | ||
| contains(github.event.pull_request.labels.*.name, 'bump patch') | ||
| || contains(github.event.pull_request.labels.*.name, 'bump minor') | ||
| || contains(github.event.pull_request.labels.*.name, 'bump major') | ||
| ) | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.event.pull_request.base.ref }} | ||
| token: ${{ secrets.POSTHOG_BOT_GITHUB_TOKEN }} | ||
| fetch-depth: 0 | ||
|
|
||
| - uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 8.x.x | ||
|
|
||
| - name: Detect version bump type | ||
| id: bump-type | ||
| run: | | ||
| BUMP_TYPE=null | ||
| if [[ $BUMP_PATCH_PRESENT == 'true' ]]; then | ||
| BUMP_TYPE=patch | ||
| fi | ||
| if [[ $BUMP_MINOR_PRESENT == 'true' ]]; then | ||
| BUMP_TYPE=minor | ||
| fi | ||
| if [[ $BUMP_MAJOR_PRESENT == 'true' ]]; then | ||
| BUMP_TYPE=major | ||
| fi | ||
| echo "bump-type=$BUMP_TYPE" >> "$GITHUB_OUTPUT" | ||
| env: | ||
| BUMP_PATCH_PRESENT: ${{ contains(github.event.pull_request.labels.*.name, 'bump patch') }} | ||
| BUMP_MINOR_PRESENT: ${{ contains(github.event.pull_request.labels.*.name, 'bump minor') }} | ||
| BUMP_MAJOR_PRESENT: ${{ contains(github.event.pull_request.labels.*.name, 'bump major') }} | ||
|
|
||
| - name: Determine new version | ||
| id: versions | ||
| if: steps.bump-type.outputs.bump-type != 'null' | ||
| run: | | ||
| OLD_VERSION=$(jq ".version" package.json -r) | ||
| NEW_VERSION=$(npx semver $OLD_VERSION -i ${{ steps.bump-type.outputs.bump-type }}) | ||
| echo "old-version=$OLD_VERSION" >> "$GITHUB_OUTPUT" | ||
| echo "new-version=$NEW_VERSION" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Update version in package.json for packages we import in posthog | ||
| if: steps.bump-type.outputs.bump-type != 'null' | ||
| run: | | ||
| # Define the package paths | ||
| PACKAGES=( | ||
| "../packages/record" | ||
| "../packages/plugins/rrweb-plugin-console-record" | ||
| "../packages/types" | ||
| "../packages/rrweb" | ||
| ) | ||
|
|
||
| # Loop through each package and update the package.json | ||
| for PACKAGE in "${PACKAGES[@]}"; do | ||
| PACKAGE_JSON="$PACKAGE/package.json" | ||
|
|
||
| if [ -f "$PACKAGE_JSON" ]; then | ||
| echo "Updating version in $PACKAGE_JSON" | ||
| mv "$PACKAGE_JSON" "$PACKAGE_JSON.old" || { echo "Failed to rename $PACKAGE_JSON"; exit 1; } | ||
| jq --indent 4 '.version = "'${{ steps.versions.outputs.new-version }}'"' "$PACKAGE_JSON.old" > "$PACKAGE_JSON" || { echo "Failed to update version in $PACKAGE_JSON"; exit 1; } | ||
| rm "$PACKAGE_JSON.old" || { echo "Failed to remove backup file $PACKAGE_JSON.old"; exit 1; } | ||
| else | ||
| echo "Error: $PACKAGE_JSON does not exist" | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| - name: Update CHANGELOG.md | ||
| run: | | ||
| CHANGELOG_HEADING='## ${{ steps.versions.outputs.new-version }} - '$(date --iso-8601) | ||
| CHANGELOG_POINTS=$(git log v${{ steps.versions.outputs.old-version }}..${{ github.event.pull_request.base.ref }} --pretty=format:%s --grep='^.*\d*)$' | sed -e 's/^/- /') | ||
| mv CHANGELOG.md CHANGELOG.old.md | ||
| echo -e "$CHANGELOG_HEADING\n\n$CHANGELOG_POINTS\n\n$(cat CHANGELOG.old.md)" > CHANGELOG.md | ||
| rm CHANGELOG.old.md | ||
|
|
||
| - name: Update lockfile | ||
| run: pnpm i | ||
|
|
||
| - name: Commit bump | ||
| if: steps.bump-type.outputs.bump-type != 'null' | ||
| uses: EndBug/add-and-commit@v7 | ||
| with: | ||
| branch: ${{ github.event.pull_request.base.ref }} | ||
| message: "chore: Bump version to ${{ steps.versions.outputs.new-version }}" | ||
| github_token: ${{ secrets.POSTHOG_BOT_GITHUB_TOKEN }} |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
| token: ${{ secrets.POSTHOG_BOT_GITHUB_TOKEN }} | ||
| fetch-depth: 0 | ||
|
|
||
| - uses: pnpm/action-setup@v4 |
Check warning
Code scanning / CodeQL
Unpinned tag for a non-immutable Action in workflow Medium
|
|
||
| - name: Commit bump | ||
| if: steps.bump-type.outputs.bump-type != 'null' | ||
| uses: EndBug/add-and-commit@v7 |
Check warning
Code scanning / CodeQL
Unpinned tag for a non-immutable Action in workflow Medium
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
we need to be able to run this alongside upstream rrweb so we can migrate to it slowly
and need to test e.g. recordings from upstream rrweb can be played in our player and vice versa so we can flag both sides of this migration
rrweb releases lots of packages but we don't import them all in posthog
web sdk uses:
posthog main uses