diff --git a/.github/workflows/preview-release.yml b/.github/workflows/preview-release.yml index f87ff5f59e..079872a6cd 100644 --- a/.github/workflows/preview-release.yml +++ b/.github/workflows/preview-release.yml @@ -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 }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0d5a19fcb5..e107de25ce 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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**.