-
Notifications
You must be signed in to change notification settings - Fork 60
126 lines (109 loc) · 5.31 KB
/
create-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
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
name: Create Release
on:
workflow_dispatch:
push:
branches:
- main
- tmp_hotfix_branch
env:
IS_HOTFIX: ${{ github.ref == 'refs/heads/tmp_hotfix_branch' }}
IS_PRERELEASE: ${{ github.event_name == 'push' && github.ref != 'refs/heads/tmp_hotfix_branch' }}
IS_MANUAL: ${{ contains(github.event.head_commit.message, 'chore(release)') }}
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_AUTH_TOKEN }}
NX_CLOUD_AUTH_TOKEN: ${{ secrets.NX_CLOUD_AUTH_TOKEN }}
jobs:
create_release:
name: Run release
runs-on: ubuntu-latest
outputs:
npmTag: ${{ steps.releaseTags.outputs.npm }}
ghTag: ${{ steps.releaseTags.outputs.gh }}
steps:
- name: Fetch from origin repo
uses: actions/checkout@v4.1.7
with:
ref: ${{ fromJSON('["tmp_hotfix_branch", "main"]')[env.IS_HOTFIX] }}
fetch-depth: 0
token: ${{ secrets.GHACTIONS }}
- uses: ./.github/actions/set-up-git
name: Set up git user
with:
name: ${{ secrets.GH_NAME }}
email: ${{ secrets.GH_EMAIL }}
- name: Setup Node.js and Cache
uses: ./.github/actions/nodejs
- name: Bump Version
id: bumpVersion
uses: ./.github/actions/bump-version
with:
isPrerelease: ${{ env.IS_PRERELEASE }}
isHotfix: ${{ env.IS_HOTFIX }}
- name: Get Release Tags
uses: ./.github/actions/release-tags
id: releaseTags
with:
bumpTag: ${{ steps.bumpVersion.outputs.releaseTag }}
bumpedVersion: ${{ steps.bumpVersion.outputs.newVersion }}
- name: Update using lerna # Skipping push, in case something goes wrong later during build/prepare
if: env.IS_MANUAL == 'false'
run: |
npx lerna version ${{ steps.bumpVersion.outputs.newVersion }} --yes --force-publish --message="chore(release): publish %v [ci skip]" --no-push
- run: yarn run lint
- run: yarn run build:prod
- name: Publish packages to NPM
uses: ./.github/actions/npm-publish
with:
packagePaths: 'dist/packages/styles,dist/packages/common-css,dist/packages/theming-preview,dist/packages/cx'
isPrerelease: ${{ steps.bumpVersion.outputs.isPrerelease }}
token: ${{ secrets.NPM_TOKEN }}
# This step is for pushing into the main repo if version has been updated by the CI.
# Commit is created by the lerna version command
# This Will NOT trigger this workflow again, so it is okay
- name: Push changes
if: env.IS_MANUAL == 'false'
run: git push --follow-tags
- name: Generate Release Body
id: generate_body
uses: ./.github/actions/generate-conventional-release-notes
- name: Create Release
uses: ncipollo/release-action@v1.14.0
with:
prerelease: ${{ steps.bumpVersion.outputs.isPrerelease }}
tag: v${{ steps.bumpVersion.outputs.newVersion }}
body: ${{ steps.generate_body.outputs.generatedReleaseNotes }}
# This step is for pushing into the main only the version change, without anything else.
# This is useful when user created a Hotfix, and we need to sync the version on main
# if hotfix version is higher than latest stable and RC versions.
- name: Update version on main
if: env.IS_HOTFIX == 'true' && steps.releaseTags.outputs.mainNeedsSync == 'true'
run: |
git checkout -f main
npx lerna version ${{ steps.bumpVersion.outputs.newVersion }} --yes --force-publish --no-push --no-changelog --no-git-tag-version --no-changelog
git add .
git commit -m "chore(release): sync version after hotfix v${{ steps.bumpVersion.outputs.newVersion }} [ci skip]"
git push origin main
# This step is responsible for cleaning up the temporary hotfix branch
- name: Delete Temporary hotfix branch
if: env.IS_HOTFIX == 'true'
run: git push origin --delete tmp_hotfix_branch
gh_pages:
name: Github Pages deploy
runs-on: ubuntu-latest
needs: create_release
if: ${{ needs.create_release.outputs.npmTag == 'latest' }}
steps:
- name: Checkout
uses: actions/checkout@v4.1.7
with:
ref: main # always fetch from main branch
token: ${{ secrets.GHACTIONS }}
- name: Setup Node.js and Cache
uses: ./.github/actions/nodejs
- name: Run storybook:static build
run: npx cross-env STORYBOOK_BASE_HREF=fundamental-styles yarn run storybook:static
- name: Publish to gh-pages
uses: JamesIves/github-pages-deploy-action@v4.6.3
with:
folder: storybook-static
token: ${{ secrets.GHACTIONS }}
repository-name: ${{ github.repository }}