Skip to content

Commit

Permalink
feat(preview releases): release the branch to be previewed instead of…
Browse files Browse the repository at this point in the history
… main and clean up docs a bit (#3040)
  • Loading branch information
ByronDWall authored Jan 15, 2025
1 parent 41d592e commit 49c85a8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
23 changes: 12 additions & 11 deletions .github/workflows/preview-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,20 @@ jobs:
env:
CI: true

- name: Storing release version for changeset
id: release_version
run: echo "VALUE=$(./scripts/print_release_version.sh)" >> $GITHUB_OUTPUT
shell: bash
# Publish preview releases only if the branch starts with "preview/" and the pr comment contains "[preview_deployment]"
- name: Publishing preview releases to npm registry
run: |
PREVIEW_TAG=$(echo "$BRANCH_NAME" | sed -e 's/^preview\///')
pnpm changeset version --snapshot ${PREVIEW_TAG}
pnpm changeset publish --tag ${PREVIEW_TAG}
env:
GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }}
BRANCH_NAME: ${{ steps.comment-branch.outputs.head_ref }}

# Publish preview releases only if the branch starts with "preview/" and the pr comment contains "[preview_deployment]"
- name: Publishing preview releases to npm registry
- name: Post workflow result on PR as a comment
if: always()
run: |
BRANCH_NAME=$(echo "${GITHUB_REF#refs/heads/}" | tr '/' '-')
git checkout ${{ github.head_ref }}
yarn changeset version --snapshot ${BRANCH_NAME}
yarn changeset publish --tag ${BRANCH_NAME}
gh issue comment ${{ github.event.issue.number }} \
--body "Release workflow ${{ job.status == 'success' && 'succeeded ✅' || 'failed ❌' }}\nSee details: [Workflow Run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
env:
GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15 changes: 8 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,13 @@ Canary releases are useful to test early changes that should not be released yet

### Branch-specific preview release

To release a preview release for a specific branch other than the `main` branch, follow these steps:

1. Create a PR in github with a branch name that starts with the prefix `preview/`  example: `preview/my-branch`
2. Make sure that the branch includes a changeset for the packages you want to publish.
3. Add a comment to the github PR that includes the string `[preview_deployment]`.
4. The preview release action will add a comment to the PR on success.
5. The release will be available on npm under an npm tag that is the branch name without `preview/`. If you are releasing `@commercetools-uikit/utils` from the `preview/my-branch`, the preview can be installed as `@commercetools-uikit/utils@my-branch`.
To release a preview npm package for a specific branch other than the `main` branch, follow these steps:

1. Create a branch whose name starts with the prefix `preview/`  example: `preview/my-branch`
2. Create a PR for the branch in github.
3. Make sure that the branch includes a changeset for the packages you want to publish.
4. Add a comment to the github PR that starts with the string `[preview_deployment]`.
5. The preview release action will add a comment to the PR on success.
6. The release will be available on npm under an npm tag that is the branch name without `preview/`. e.g. if you are releasing `@commercetools-uikit/utils` from `preview/my-branch`, the preview can be installed as `@commercetools-uikit/utils@my-branch`.

Note that canary releases **will not create git tags and version bump commits**.

0 comments on commit 49c85a8

Please sign in to comment.