forked from Shopify/hydrogen
-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (121 loc) · 4.92 KB
/
changesets.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Changesets
on:
push:
branches:
- '[0-9]+-[0-9]+'
concurrency:
group: changeset-${{ github.head_ref }}
cancel-in-progress: true
jobs:
changelog:
runs-on: ubuntu-latest
if: github.repository_owner == 'shopify'
name: Changelog PR or Release
outputs:
published: ${{ steps.changesets.outputs.published }}
latest: ${{ env.latest }}
steps:
- name: Flags
id: flags
run: |
# IMPORTANT: Update this variable whenever we move to a new major version:
echo "latest=${{ github.ref_name == '2023-04' }}" >> $GITHUB_ENV
- name: Checkout the code
uses: actions/checkout@v3
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
with:
fetch-depth: 0
- name: ⎔ Setup node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- name: Install the packages
run: npm ci --legacy-peer-deps
- name: Format release with Prettier
run: npm run format
- name: Build the dist code
run: npm run build
- name: Create Release Pull Request or Publish (for latest release)
if: env.latest == 'true'
id: changesets
uses: changesets/action@v1
with:
version: npm run version
publish: npm run changeset publish
# we use the commit message in next release workflow file. This avoid a next release when an actual release is happening
commit: '[ci] release ${{ github.ref_name }}'
title: '[ci] release ${{ github.ref_name }}'
env:
GITHUB_TOKEN: ${{ secrets.SHOPIFY_GH_ACCESS_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# - name: Create Release Pull Request or Publish (for legacy patch release)
# if: env.latest != 'true'
# id: changesets_legacy
# uses: changesets/action@v1
# with:
# version: npm run version
# publish: npm run changeset publish --tag legacy
# commit: '[ci] release ${{ github.ref_name }}'
# title: '[ci] release ${{ github.ref_name }}'
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
compile:
needs: changelog
# Only compile templates if a release was published, and we're on the "latest" release branch
if: needs.changelog.outputs.published == 'true' && needs.changelog.outputs.latest == 'true'
runs-on: ubuntu-latest
name: Compile the typescript templates and push them to main
steps:
- name: Checkout the code
uses: actions/checkout@v3
- name: Install the packages
run: npm install --frozen-lockfile --ignore-engines
- name: Build the dist code
run: npm run build
- name: Compile hello-world
run: |
node scripts/compile-template-for-dist.mjs hello-world
- name: Compile demo-store
run: |
node scripts/compile-template-for-dist.mjs demo-store
- name: Update templates in the dist branch
run: |
git add .
git status
git config user.email "[email protected]"
git config user.name "Hydrogen Bot"
git show-ref
git commit -m "Update templates for dist"
git push origin HEAD:dist --force
# discord_announcement:
# needs: changelog
# # Only announce if a release was published, and we're on the "latest" release branch
# if: needs.changelog.outputs.published == 'true' && needs.changelog.outputs.latest == 'true'
# runs-on: ubuntu-latest
# steps:
# - name: Check out the code
# uses: actions/checkout@v3
# - name: Read Hydrogen version from package.json
# id: read_package_json
# working-directory: ./packages/hydrogen
# run: |
# content=`cat ./package.json`
# # the following lines are required for multi line json
# content="${content//'%'/'%25'}"
# content="${content//$'\n'/'%0A'}"
# content="${content//$'\r'/'%0D'}"
# # end of handling multi line json
# echo "::set-output name=packageJson::$content"
# - run: |
# echo "HYDROGEN_VERSION=${{fromJSON(steps.read_package_json.outputs.packageJson).version}}" >> $GITHUB_ENV
# - name: Discord notification
# env:
# DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
# DISCORD_USERNAME: Shopify Devs
# DISCORD_AVATAR: https://cdn.discordapp.com/avatars/905537246990590012/0f6a687b93ef3f81a036c817fb02ccbf.webp
# uses: Ilshidur/action-discord@08d9328877d6954120eef2b07abbc79249bb6210
# with:
# args: "Hydrogen ${{ env.HYDROGEN_VERSION }} has been released.\nhttps://github.com/Shopify/hydrogen/releases/tag/@shopify/hydrogen@${{ env.HYDROGEN_VERSION }}"