diff --git a/.github/workflows/changeset-release.yml b/.github/workflows/changeset-release.yml index 15ee943c60..d59ec6d952 100644 --- a/.github/workflows/changeset-release.yml +++ b/.github/workflows/changeset-release.yml @@ -111,30 +111,42 @@ jobs: # - For 'pie-storybook', a distinct message is generated pointing to 'webc.pie.design'. # - For all other packages, a generic message is generated, including links to the GitHub release and npm. - name: Generate Slack payload blocks - id: generate_payload - run: | - PACKAGES='[{"name": "wc-nuxt3", "version": "0.30.0"}, {"name": "pie-monorepo", "version": "0.30.0"}, {"name": "@justeattakeaway/pie-button", "version": "0.30.0"}, {"name": "@justeattakeaway/pie-modal", "version": "0.25.0"}, {"name": "pie-storybook", "version": "0.30.0"}, {"name": "pie-docs", "version": "0.30.0"}]' - PRIORITIZED_PACKAGES=$(echo $PACKAGES | jq -c '[.[] | select(.name == "pie-docs" or .name == "pie-storybook")]') - REST_PACKAGES=$(echo $PACKAGES | jq -c '[.[] | select((.name != "pie-docs" and .name != "pie-storybook") and (.name | startswith("wc-") | not) and .name != "pie-monorepo")]') - COMBINED_PACKAGES=$(echo "[${PRIORITIZED_PACKAGES},${REST_PACKAGES}]" | jq -c 'add') - BLOCKS=$(echo $COMBINED_PACKAGES | jq -c ' - [ - (.[] | - if .name == "pie-docs" then - {"type": "section", "text": {"type": "mrkdwn", "text": "A new version of the PIE Docs was released! - " }} - elif .name == "pie-storybook" then - {"type": "section", "text": {"type": "mrkdwn", "text": "PIE Storybook was released - " }} - else empty - end - ), - {"type": "section", "text": {"type": "mrkdwn", "text": "New versions are available for the following components:"}}, - (.[] | - select(.name != "pie-docs" and .name != "pie-storybook") | - {"type": "section", "text": {"type": "mrkdwn", "text": "- *\(.name | sub("@justeattakeaway/pie-"; "") | (.[0:1] | ascii_upcase) + .[1:])* was updated to `\(.version)` | | " }} - ) - ] - ') - echo "BLOCKS=$BLOCKS" >> $GITHUB_ENV + id: generate_payload + run: | + PACKAGES='[...]' # Your package list here + + PRIORITIZED_PACKAGES=$(echo $PACKAGES | jq -c '[.[] | select(.name == "pie-docs" or .name == "pie-storybook")]') + REST_PACKAGES=$(echo $PACKAGES | jq -c '[.[] | select((.name != "pie-docs" and .name != "pie-storybook") and (.name | startswith("wc-") | not) and .name != "pie-monorepo")]') + + PRIORITIZED_BLOCKS=$(echo $PRIORITIZED_PACKAGES | jq -c ' + if length > 0 then + [.[] | + if .name == "pie-docs" then + {"type": "section", "text": {"type": "mrkdwn", "text": "A new version of the PIE Docs was released! - " }} + elif .name == "pie-storybook" then + {"type": "section", "text": {"type": "mrkdwn", "text": "PIE Storybook was released - " }} + else empty + end + ] + else + [] + end + ') + + REST_COMPONENT_BLOCKS=$(echo $REST_PACKAGES | jq -c ' + if length > 0 then + [{"type": "section", "text": {"type": "mrkdwn", "text": "New versions are available for the following components:"}}] + + map( + {"type": "section", "text": {"type": "mrkdwn", "text": "- *\(.name | sub("@justeattakeaway/pie-"; "") | (.[0:1] | ascii_upcase) + .[1:])* was updated to `\(.version)` | | " }} + ) + else + [] + end + ') + + BLOCKS=$(echo "[${PRIORITIZED_BLOCKS},${REST_COMPONENT_BLOCKS}]" | jq -c 'add') + + echo "BLOCKS=$BLOCKS" >> $GITHUB_ENV - name: Send a Slack notification on publish # if: steps.changesets-main.outcome == 'success'