-
Notifications
You must be signed in to change notification settings - Fork 133
174 lines (153 loc) · 7.27 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
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_DISTRIBUTED_EXECUTION: true
NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT: 5
NX_BRANCH: ${{ github.event.number || github.ref_name }}
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_AUTH_TOKEN }}
NX_CLOUD_AUTH_TOKEN: ${{ secrets.NX_CLOUD_AUTH_TOKEN }}
jobs:
nx_agents:
name: Nx Cloud Agent ${{ matrix.agent }}
runs-on: ubuntu-latest
strategy:
matrix:
agent: [1, 2, 3, 4, 5]
steps:
- uses: actions/[email protected]
- uses: ./.github/actions/nodejs
- name: Start Nx Cloud Agent
run: npx nx-cloud start-agent
env:
NX_AGENT_NAME: ${{matrix.agent}}
create_release:
name: Create release
runs-on: ubuntu-latest
outputs:
npmTag: ${{ steps.releaseTags.outputs.npm }}
ghTag: ${{ steps.releaseTags.outputs.gh }}
steps:
- name: Fetch from origin repo
uses: actions/[email protected]
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: Initialize the Nx Cloud distributed CI run
run: npx nx-cloud start-ci-run
# Does conventional version bump and creates a tag
- name: Get next version
id: bumpVersion
uses: ./.github/actions/bump-version
with:
isManual: ${{ env.IS_MANUAL }}
isPrerelease: ${{ env.IS_PRERELEASE }}
isHotfix: ${{ env.IS_HOTFIX }}
# Takes bump tag and creates the release tags for both gh and npm.
# See implementation for more details
- 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
- name: Lint and build
uses: ./.github/actions/parallel-commands
with:
parallel-commands: |
npx nx run-many --target=lint --projects=i18n,cdk,core,platform,moment-adapter,datetime-adapter,cx,btp --parallel=2
npx nx run-many --target=build --all --parallel=1
- name: Pack libraries
run: npx nx run-many --target=prepare --projects=i18n,cdk,core,platform,moment-adapter,datetime-adapter,cx,btp --parallel=3
env:
NX_CLOUD_DISTRIBUTED_EXECUTION: false
FD_ENV_VERSION_PLACEHOLDER: ${{ steps.bumpVersion.outputs.newVersion }}
- name: Publish packages
uses: ./.github/actions/npm-publish
with:
projects: '["cdk", "core", "i18n", "platform", "moment-adapter", "datetime-adapter", "cx", "btp"]'
token: ${{ secrets.NPM_TOKEN }}
releaseTag: ${{ steps.releaseTags.outputs.npm }}
# 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
# This will delete locally some tags to properly generate the release notes, so it should go after the push to upstream
- name: Generate Release Body
id: generate_body
uses: ./.github/actions/generate-conventional-release-notes
- name: Create Release
uses: ncipollo/[email protected]
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/[email protected]
with:
ref: main # always fetch from main branch
token: ${{ secrets.GHACTIONS }}
- name: Setup Node.js and Cache
uses: ./.github/actions/nodejs
- name: Run build prod
run: npx nx run docs:compile:production --skip-nx-cache
- name: Publish to gh-pages
uses: JamesIves/[email protected]
with:
folder: dist/apps/docs
token: ${{ secrets.GHACTIONS }}
repository-name: ${{ github.repository }}
stop_agents:
if: ${{ always() }}
needs:
- create_release
- gh_pages
name: Nx Cloud - Stop Agents
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: ./.github/actions/nodejs
- name: Stop all running agents for this CI run
run: npx nx-cloud stop-all-agents