Skip to content

Commit c8e4a0b

Browse files
author
Ben Siggery
committed
reintroduce logic
1 parent b0e8260 commit c8e4a0b

File tree

2 files changed

+466
-466
lines changed

2 files changed

+466
-466
lines changed

.github/workflows/changeset-release.yml

+180-180
Original file line numberDiff line numberDiff line change
@@ -21,191 +21,191 @@ env:
2121
GITHUB_TOKEN: ${{ secrets.CHANGESETS_TOKEN }}
2222

2323
jobs:
24-
# changesets:
25-
# outputs:
26-
# published: ${{ steps.changesets-main.outputs.published }}
27-
# publishedPackages: ${{ steps.changesets-main.outputs.publishedPackages }}
28-
# runs-on: ${{ inputs.os }}
29-
# if: github.repository == 'justeattakeaway/pie' && ${{ github.event_name != 'pull_request' }} &&
30-
# (contains(github.ref_name, 'main') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'feature'))
31-
# steps:
32-
# # Checkout the Repo
33-
# - name: Checkout
34-
# uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
35-
# with:
36-
# fetch-depth: 0
37-
# persist-credentials: false
38-
# # Setup Repo
39-
# - name: Setup Repo
40-
# uses: ./.github/actions/setup-repo
41-
# with:
42-
# node-version: ${{ inputs.node-version }}
43-
# os: ${{ inputs.os }}
44-
# - name: Append NPM token to .npmrc
45-
# run: |
46-
# cat << EOF > "$HOME/.npmrc"
47-
# //registry.npmjs.org/:_authToken=$NPM_TOKEN
48-
# EOF
49-
# # Build Packages
50-
# - name: Build
51-
# if: ${{ github.event_name != 'pull_request' }} &&
52-
# (contains(github.ref_name, 'main') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'feature'))
53-
# uses: ./.github/actions/run-script
54-
# with:
55-
# script-name: "build"
56-
# - name: Check for pre.json file existence
57-
# id: check_files
58-
# uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0
59-
# with:
60-
# files: ".changeset/pre.json"
61-
# - name: exit prerelease mode
62-
# # If .changeset/pre.json does not exist and we did not recently exit
63-
# # prerelease mode.
64-
# if: steps.check_files.outputs.files_exists == 'true' && contains(github.ref_name, 'main')
65-
# run: npx changeset pre exit
66-
# - name: Create latest release PR
67-
# id: changesets-main
68-
# if: contains(github.ref_name, 'main')
69-
# uses: changesets/action@c8bada60c408975afd1a20b3db81d6eee6789308 # v1.4.9
70-
# with:
71-
# version: yarn changeset:version
72-
# publish: yarn changeset:publish
73-
# commit: "release: release packages with 'latest' tag"
74-
# # If .changeset/pre.json does not exist and we did not recently exit
75-
# # prerelease mode, enter prerelease mode with tag beta
76-
# - name: Enter beta prerelease mode
77-
# id: changesets-beta
78-
# if: steps.check_files.outputs.files_exists == 'false' && contains(github.ref_name, 'beta')
79-
# # If .changeset/pre.json does not exist and we did not recently exit
80-
# # prerelease mode, enter prerelease mode with tag beta
81-
# run: npx changeset pre enter beta
82-
# - name: Create beta release PR
83-
# if: contains(github.ref_name, 'beta')
84-
# uses: changesets/action@c8bada60c408975afd1a20b3db81d6eee6789308 # v1.4.9
85-
# with:
86-
# version: yarn changeset:version
87-
# publish: yarn changeset:publish
88-
# commit: "release: release packages with 'beta' tag"
89-
# - name: Enter feature prerelease mode
90-
# id: changesets-feature
91-
# if: steps.check_files.outputs.files_exists == 'false' && contains(github.ref_name, 'feature')
92-
# # If .changeset/pre.json does not exist and we did not recently exit
93-
# # prerelease mode, enter prerelease mode with tag next
94-
# run: npx changeset pre enter next
95-
# - name: Create feature release PR
96-
# if: contains(github.ref_name, 'feature')
97-
# uses: changesets/action@c8bada60c408975afd1a20b3db81d6eee6789308 # v1.4.9
98-
# with:
99-
# version: yarn changeset:version
100-
# publish: yarn changeset:publish
101-
# commit: "release: release packages with 'next' tag"
24+
changesets:
25+
outputs:
26+
published: ${{ steps.changesets-main.outputs.published }}
27+
publishedPackages: ${{ steps.changesets-main.outputs.publishedPackages }}
28+
runs-on: ${{ inputs.os }}
29+
if: github.repository == 'justeattakeaway/pie' && ${{ github.event_name != 'pull_request' }} &&
30+
(contains(github.ref_name, 'main') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'feature'))
31+
steps:
32+
# Checkout the Repo
33+
- name: Checkout
34+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
35+
with:
36+
fetch-depth: 0
37+
persist-credentials: false
38+
# Setup Repo
39+
- name: Setup Repo
40+
uses: ./.github/actions/setup-repo
41+
with:
42+
node-version: ${{ inputs.node-version }}
43+
os: ${{ inputs.os }}
44+
- name: Append NPM token to .npmrc
45+
run: |
46+
cat << EOF > "$HOME/.npmrc"
47+
//registry.npmjs.org/:_authToken=$NPM_TOKEN
48+
EOF
49+
# Build Packages
50+
- name: Build
51+
if: ${{ github.event_name != 'pull_request' }} &&
52+
(contains(github.ref_name, 'main') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'feature'))
53+
uses: ./.github/actions/run-script
54+
with:
55+
script-name: "build"
56+
- name: Check for pre.json file existence
57+
id: check_files
58+
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0
59+
with:
60+
files: ".changeset/pre.json"
61+
- name: exit prerelease mode
62+
# If .changeset/pre.json does not exist and we did not recently exit
63+
# prerelease mode.
64+
if: steps.check_files.outputs.files_exists == 'true' && contains(github.ref_name, 'main')
65+
run: npx changeset pre exit
66+
- name: Create latest release PR
67+
id: changesets-main
68+
if: contains(github.ref_name, 'main')
69+
uses: changesets/action@c8bada60c408975afd1a20b3db81d6eee6789308 # v1.4.9
70+
with:
71+
version: yarn changeset:version
72+
publish: yarn changeset:publish
73+
commit: "release: release packages with 'latest' tag"
74+
# If .changeset/pre.json does not exist and we did not recently exit
75+
# prerelease mode, enter prerelease mode with tag beta
76+
- name: Enter beta prerelease mode
77+
id: changesets-beta
78+
if: steps.check_files.outputs.files_exists == 'false' && contains(github.ref_name, 'beta')
79+
# If .changeset/pre.json does not exist and we did not recently exit
80+
# prerelease mode, enter prerelease mode with tag beta
81+
run: npx changeset pre enter beta
82+
- name: Create beta release PR
83+
if: contains(github.ref_name, 'beta')
84+
uses: changesets/action@c8bada60c408975afd1a20b3db81d6eee6789308 # v1.4.9
85+
with:
86+
version: yarn changeset:version
87+
publish: yarn changeset:publish
88+
commit: "release: release packages with 'beta' tag"
89+
- name: Enter feature prerelease mode
90+
id: changesets-feature
91+
if: steps.check_files.outputs.files_exists == 'false' && contains(github.ref_name, 'feature')
92+
# If .changeset/pre.json does not exist and we did not recently exit
93+
# prerelease mode, enter prerelease mode with tag next
94+
run: npx changeset pre enter next
95+
- name: Create feature release PR
96+
if: contains(github.ref_name, 'feature')
97+
uses: changesets/action@c8bada60c408975afd1a20b3db81d6eee6789308 # v1.4.9
98+
with:
99+
version: yarn changeset:version
100+
publish: yarn changeset:publish
101+
commit: "release: release packages with 'next' tag"
102102

103103

104-
# # This script performs the following logic:
105-
# # 1. Defines a list of packages with their versions.
106-
# # 2. Separates the 'pie-docs' and 'pie-storybook' packages, which have a higher priority, into a distinct list called `PRIORITIZED_PACKAGES`.
107-
# # 3. Filters out and creates a separate list (`REST_PACKAGES`) excluding:
108-
# # - The aforementioned 'pie-docs' and 'pie-storybook' packages.
109-
# # - Any package whose name starts with "wc-" (Example apps).
110-
# # - The 'pie-monorepo' package.
111-
# # 4. Combines the prioritized and the rest of the packages into one list (`COMBINED_PACKAGES`).
112-
# # 5. For each package in `COMBINED_PACKAGES`, creates a Slack message block:
113-
# # - For 'pie-docs', a specific message is generated pointing to 'pie.design'.
114-
# # - For 'pie-storybook', a distinct message is generated pointing to 'webc.pie.design'.
115-
# # - For all other packages, a generic message is generated, including links to the GitHub release and npm.
116-
# - name: Generate Slack payload blocks
117-
# if: steps.changesets-main.outputs.published == 'true'
118-
# id: generate_payload
119-
# run: |
120-
# PACKAGES='${{ steps.changesets-main.outputs.publishedPackages}}'
121-
# PRIORITIZED_PACKAGES=$(echo $PACKAGES | jq -c '[.[] | select(.name == "pie-docs" or .name == "pie-storybook")]')
122-
# REST_PACKAGES=$(echo $PACKAGES | jq -c '[.[] | select((.name != "pie-docs" and .name != "pie-storybook") and (.name | startswith("wc-") | not) and .name != "pie-monorepo")]')
104+
# This script performs the following logic:
105+
# 1. Defines a list of packages with their versions.
106+
# 2. Separates the 'pie-docs' and 'pie-storybook' packages, which have a higher priority, into a distinct list called `PRIORITIZED_PACKAGES`.
107+
# 3. Filters out and creates a separate list (`REST_PACKAGES`) excluding:
108+
# - The aforementioned 'pie-docs' and 'pie-storybook' packages.
109+
# - Any package whose name starts with "wc-" (Example apps).
110+
# - The 'pie-monorepo' package.
111+
# 4. Combines the prioritized and the rest of the packages into one list (`COMBINED_PACKAGES`).
112+
# 5. For each package in `COMBINED_PACKAGES`, creates a Slack message block:
113+
# - For 'pie-docs', a specific message is generated pointing to 'pie.design'.
114+
# - For 'pie-storybook', a distinct message is generated pointing to 'webc.pie.design'.
115+
# - For all other packages, a generic message is generated, including links to the GitHub release and npm.
116+
- name: Generate Slack payload blocks
117+
if: steps.changesets-main.outputs.published == 'true'
118+
id: generate_payload
119+
run: |
120+
PACKAGES='${{ steps.changesets-main.outputs.publishedPackages}}'
121+
PRIORITIZED_PACKAGES=$(echo $PACKAGES | jq -c '[.[] | select(.name == "pie-docs" or .name == "pie-storybook")]')
122+
REST_PACKAGES=$(echo $PACKAGES | jq -c '[.[] | select((.name != "pie-docs" and .name != "pie-storybook") and (.name | startswith("wc-") | not) and .name != "pie-monorepo")]')
123123
124-
# PRIORITIZED_BLOCKS=$(echo $PACKAGES | jq -c '
125-
# map(select(.name == "pie-docs" or .name == "pie-storybook")) |
124+
PRIORITIZED_BLOCKS=$(echo $PACKAGES | jq -c '
125+
map(select(.name == "pie-docs" or .name == "pie-storybook")) |
126126

127-
# if length > 0 then
128-
# [{"type": "divider"}, {"type": "header", "text": {"type": "plain_text", "text": ":rocket: Deployment Summary"}}] +
129-
# (map(
130-
# if .name == "pie-docs" then
131-
# {
132-
# "type": "section",
133-
# "block_id": "sectionBlockWithButton",
134-
# "text": {
135-
# "type": "mrkdwn",
136-
# "text": "*PIE Docs*"
137-
# },
138-
# "accessory": {
139-
# "type": "button",
140-
# "text": {
141-
# "type": "plain_text",
142-
# "text": "Visit :book:",
143-
# "emoji": true
144-
# },
145-
# "url": "https://pie.design"
146-
# }
147-
# }
148-
# elif .name == "pie-storybook" then
149-
# {
150-
# "type": "section",
151-
# "text": {
152-
# "type": "mrkdwn",
153-
# "text": "*PIE Storybook*"
154-
# },
155-
# "accessory": {
156-
# "type": "button",
157-
# "text": {
158-
# "type": "plain_text",
159-
# "text": "Visit :pie_team_logo:",
160-
# "emoji": true
161-
# },
162-
# "url": "https://webc.pie.design"
163-
# }
164-
# }
165-
# else
166-
# empty
167-
# end
168-
# ))
169-
# else
170-
# .
171-
# end
172-
# ')
127+
if length > 0 then
128+
[{"type": "divider"}, {"type": "header", "text": {"type": "plain_text", "text": ":rocket: Deployment Summary"}}] +
129+
(map(
130+
if .name == "pie-docs" then
131+
{
132+
"type": "section",
133+
"block_id": "sectionBlockWithButton",
134+
"text": {
135+
"type": "mrkdwn",
136+
"text": "*PIE Docs*"
137+
},
138+
"accessory": {
139+
"type": "button",
140+
"text": {
141+
"type": "plain_text",
142+
"text": "Visit :book:",
143+
"emoji": true
144+
},
145+
"url": "https://pie.design"
146+
}
147+
}
148+
elif .name == "pie-storybook" then
149+
{
150+
"type": "section",
151+
"text": {
152+
"type": "mrkdwn",
153+
"text": "*PIE Storybook*"
154+
},
155+
"accessory": {
156+
"type": "button",
157+
"text": {
158+
"type": "plain_text",
159+
"text": "Visit :pie_team_logo:",
160+
"emoji": true
161+
},
162+
"url": "https://webc.pie.design"
163+
}
164+
}
165+
else
166+
empty
167+
end
168+
))
169+
else
170+
.
171+
end
172+
')
173173
174174
175-
# REST_COMPONENT_BLOCKS=$(echo $REST_PACKAGES | jq -c '
176-
# if length > 0 then
177-
# [{"type": "divider"}] +
178-
# [{"type": "header", "text": {"type": "plain_text", "text": ":parcel: Package Update Summary"}}] +
179-
# map(
180-
# {"type": "section", "text": {"type": "mrkdwn", "text": "- *\(.name | sub("@justeattakeaway/pie-"; "") | (.[0:1] | ascii_upcase) + .[1:])* was updated to `\(.version)` | <https://github.com/justeattakeaway/pie/releases/tag/\(.name)@\(.version)|Changelog> | <https://www.npmjs.com/package/\(.name)|npm>" }}
181-
# )
182-
# else
183-
# []
184-
# end
185-
# ')
175+
REST_COMPONENT_BLOCKS=$(echo $REST_PACKAGES | jq -c '
176+
if length > 0 then
177+
[{"type": "divider"}] +
178+
[{"type": "header", "text": {"type": "plain_text", "text": ":parcel: Package Update Summary"}}] +
179+
map(
180+
{"type": "section", "text": {"type": "mrkdwn", "text": "- *\(.name | sub("@justeattakeaway/pie-"; "") | (.[0:1] | ascii_upcase) + .[1:])* was updated to `\(.version)` | <https://github.com/justeattakeaway/pie/releases/tag/\(.name)@\(.version)|Changelog> | <https://www.npmjs.com/package/\(.name)|npm>" }}
181+
)
182+
else
183+
[]
184+
end
185+
')
186186
187-
# BLOCKS=$(echo "[${PRIORITIZED_BLOCKS},${REST_COMPONENT_BLOCKS}]" | jq -c 'add')
187+
BLOCKS=$(echo "[${PRIORITIZED_BLOCKS},${REST_COMPONENT_BLOCKS}]" | jq -c 'add')
188188

189-
# echo "BLOCKS=$BLOCKS" >> $GITHUB_ENV
189+
echo "BLOCKS=$BLOCKS" >> $GITHUB_ENV
190190

191-
# - name: Send a Slack notification on publish
192-
# if: steps.changesets-main.outputs.published == 'true'
193-
# uses: slackapi/slack-github-action@fcfb566f8b0aab22203f066d80ca1d7e4b5d05b3 # v1.27.1
194-
# with:
195-
# channel-id: ${{ secrets.RELEASE_SLACK_CHANNEL_ID }}
196-
# payload: |
197-
# {
198-
# "blocks": ${{ env.BLOCKS }},
199-
# "unfurl_links": false,
200-
# "unfurl_media": false
201-
# }
202-
# env:
203-
# SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
191+
- name: Send a Slack notification on publish
192+
if: steps.changesets-main.outputs.published == 'true'
193+
uses: slackapi/slack-github-action@fcfb566f8b0aab22203f066d80ca1d7e4b5d05b3 # v1.27.1
194+
with:
195+
channel-id: ${{ secrets.RELEASE_SLACK_CHANNEL_ID }}
196+
payload: |
197+
{
198+
"blocks": ${{ env.BLOCKS }},
199+
"unfurl_links": false,
200+
"unfurl_media": false
201+
}
202+
env:
203+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
204204

205205
publish-cookie-banner-cdn:
206-
# needs: changesets
206+
needs: changesets
207207
runs-on: ${{ inputs.os }}
208-
# if: needs.changesets.outputs.published == 'true' && contains(fromJson(needs.changesets.outputs.publishedPackages).*.name, '@justeattakeaway/pie-cookie-banner')
208+
if: needs.changesets.outputs.published == 'true' && contains(fromJson(needs.changesets.outputs.publishedPackages).*.name, '@justeattakeaway/pie-cookie-banner')
209209
steps:
210210
# Checkout the Repo
211211
- name: Checkout
@@ -224,16 +224,16 @@ jobs:
224224
with:
225225
script-name: "build --filter=pie-cookie-banner"
226226

227-
# - name: Extract cookie banner version
228-
# id: extract-version
229-
# run: |
230-
# PACKAGES='${{ needs.changesets.outputs.publishedPackages }}'
231-
# cookie_banner_version=$(echo $PACKAGES | jq -r '.[] | select(.name == "@justeattakeaway/pie-cookie-banner") | .version')
232-
# echo "COOKIE_BANNER_VERSION=$cookie_banner_version" >> $GITHUB_ENV
227+
- name: Extract cookie banner version
228+
id: extract-version
229+
run: |
230+
PACKAGES='${{ needs.changesets.outputs.publishedPackages }}'
231+
cookie_banner_version=$(echo $PACKAGES | jq -r '.[] | select(.name == "@justeattakeaway/pie-cookie-banner") | .version')
232+
echo "COOKIE_BANNER_VERSION=$cookie_banner_version" >> $GITHUB_ENV
233233
234234
- name: Upload to S3
235235
run: |
236-
aws s3 sync $GITHUB_WORKSPACE/packages/components/pie-cookie-banner/cdn_dist/ s3://$PIE_CDN_BUCKET_NAME/pie-cookie-banner/v1.2.14/ --region $AWS_REGION --content-type "text/javascript"
236+
aws s3 sync $GITHUB_WORKSPACE/packages/components/pie-cookie-banner/cdn_dist/ s3://$PIE_CDN_BUCKET_NAME/pie-cookie-banner/$COOKIE_BANNER_VERSION/ --region $AWS_REGION --content-type "text/javascript"
237237
env:
238238
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
239239
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

0 commit comments

Comments
 (0)