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

feat(preview releases): release the branch to be previewed instead of… #3040

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
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**.
Loading