Skip to content
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

chore: auto publish alpha versions #1414

Merged
merged 23 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/label-alpha-bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Autobump

on:
check_suite:
types:
completed

jobs:
label-alpha-bump:
name: Bump version based on PR label
runs-on: ubuntu-20.04
if: |
github.event.check_suite.conclusion == 'success'
&& contains(github.event.pull_request.labels.*.name, 'bump alpha')
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: 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 pre-release --preid alpha)
echo "old-version=$OLD_VERSION" >> "$GITHUB_OUTPUT"
echo "new-version=$NEW_VERSION" >> "$GITHUB_OUTPUT"

- name: Update version in package.json
if: steps.bump-type.outputs.bump-type != 'null'
run: |
mv package.json package.old.json
jq --indent 4 '.version = "${{ steps.versions.outputs.new-version }}"' package.old.json > package.json
rm package.old.json

- name: Publish the alpha in the npm registry
run: npm publish --access public --dry-run
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ If you forget to add the label, don't try to update the version locally as you w

To release an alpha or beta version, you'll need to use the CLI locally:

#### CLI

Only one person is set as a collaborator on NPM, so they're the only person that can manually publish alphas

1. Make sure you're a collaborator on `posthog-js` in npm ([check here](https://www.npmjs.com/package/posthog-js)).
2. Make sure you're logged into the npm CLI (`npm login`).
3. Check out your work-in-progress branch (do not release an alpha/beta from `main`).
Expand All @@ -91,3 +95,8 @@ To release an alpha or beta version, you'll need to use the CLI locally:
```

5. Enjoy the new prerelease version. You can now use it locally, in a dummy app, or in the [main repo](https://github.com/posthog/PostHog).

#### Automagically
pauldambra marked this conversation as resolved.
Show resolved Hide resolved

Use the release-alpha label on your PR to have an alpha version bumped and published automatically.
Remember that these are public and folk might use them, so make sure they're not _too_ alpha 🙈
pauldambra marked this conversation as resolved.
Show resolved Hide resolved
Loading