-
Notifications
You must be signed in to change notification settings - Fork 276
78 lines (67 loc) · 2.57 KB
/
next-release.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
name: ⏭️ Next Release
on:
push:
branches:
- main
jobs:
next-release:
name: ⏭️ Next Release
runs-on: ubuntu-latest
# don't run if a commit message with [ci] release is present. The release workflow will do the release
if: github.repository_owner == 'shopify' && !startsWith(github.event.head_commit.message, '[ci] release')
outputs:
NEXT_VERSION: ${{ steps.version.outputs.NEXT_VERSION }}
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- name: Install the packages
run: npm ci
- name: Format release with Prettier
run: npm run format
- name: 🕵️ Check for changes
id: version
run: |
# get latest commit sha
SHA=$(git rev-parse HEAD)
# get first 7 characters of sha
SHORT_SHA=${SHA::7}
NEXT_VERSION=next-${SHORT_SHA}
# set output so it can be used in other jobs
echo "NEXT_VERSION=${NEXT_VERSION}" >> $GITHUB_OUTPUT
- name: 🏗 Build CLI
if: steps.version.outputs.NEXT_VERSION
run: npm run build
- name: ⤴️ Update version
if: steps.version.outputs.NEXT_VERSION
run: |
git config user.email "[email protected]"
git config user.name "Hydrogen Bot"
git checkout -B next/${{ steps.version.outputs.NEXT_VERSION }}
# using changeset snapshot releases, this sets the version to 0.0.0-{tag}-DATETIMESTAMP where tag=next-SHORT_SHA
# as an example this results in a next release as following 0.0.0-next-1686a75-20230313113149 with a next tag
npm run version:next
npm run changeset -- version --snapshot ${{steps.version.outputs.NEXT_VERSION}}
npm run version:post
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 🏗 Build
if: steps.version.outputs.NEXT_VERSION
run: npm run build
- name: 🔐 Setup npm auth
if: steps.version.outputs.NEXT_VERSION
run: |
echo "registry=https://registry.npmjs.org" >> ~/.npmrc
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: 🚀 Publish
if: steps.version.outputs.NEXT_VERSION
run: npm run changeset -- publish --tag next