Skip to content

align storybook-blocks versions #2758

align storybook-blocks versions

align storybook-blocks versions #2758

Workflow file for this run

name: Prerelease
on:
push:
branches-ignore:
- "master"
jobs:
prerelease:
if: "contains(github.event.head_commit.message, '[prerelease]')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run Setup
uses: ./.github/actions/setup
with:
npm_token: ${{ secrets.npm_token }}
- uses: ./.github/actions/git-creds
- name: Check if there are changed packages
run: |
changed_packages=$(yarn -s lerna ls --since=origin/master --json --loglevel=error)
[[ $changed_packages = "[]" ]] && echo "Skipping prerelease. Nothing to prerelease as Lerna didn't detect any changes." && exit 1 || echo "Changed detected. Continuing to prerelease" && echo "$changed_packages"
- name: Build all affected packages
run: yarn lerna run build --since=origin/master --include-dependencies
- name: Generate new versions
id: generate-versions
run: |
preid=${{ github.ref_name }}
normalized_pre_id=$(echo "$preid" | tr -dc '[:alnum:]\n\r' | tr '[:upper:]' '[:lower:]')
full_output=$(yarn lerna version --exact --conventional-commits --conventional-prerelease --json --no-changelog --no-push --preid "$normalized_pre_id" -y)
# extract only the JSON portion from the full output, excluding yarn logs
json_output=$(echo "$full_output" | awk '/^\[/{p=1} p; /\]/{p=0}' )
echo 'new_versions<<EOF' >> $GITHUB_OUTPUT
echo "$json_output" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- run: yarn config set registry https://registry.npmjs.org/
- name: Setup .npmrc for publish
run: npm set "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN"
env:
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
- name: Publish new versions
run: yarn lerna publish from-package --dist-tag prerelease -y
- name: Get current PR id
uses: 8BitJonny/[email protected]
id: PR
- name: Prepare PR comment
id: prepare-comment
env:
json_data: ${{ steps.generate-versions.outputs.new_versions }}
run: |
echo 'comment_body<<EOF' >> $GITHUB_OUTPUT
echo "A new prerelease version of this PR has been published! 🎉" >> $GITHUB_OUTPUT
echo "To install this prerelease version, run the following command in your terminal with any one of the packages changed in this PR:" >> $GITHUB_OUTPUT
echo "$json_data" | jq -r '.[] | "\nTo update `\(.name)`:\n```\nyarn add \(.name)@\(.newVersion)\n```\nOr with npm:\n```\nnpm i \(.name)@\(.newVersion)\n```\n"' >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Create comment with prerelease version details
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ steps.PR.outputs.number }}
body: ${{ steps.prepare-comment.outputs.comment_body }}