-
Notifications
You must be signed in to change notification settings - Fork 6
169 lines (147 loc) · 5.22 KB
/
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
name: Release
on:
push:
branches:
- "main"
workflow_dispatch:
env:
# The release + deployment will be done on "prod" stage if on main branch, on "dev" stage otherwise
STAGE: ${{ github.ref_name == 'main' && 'prod' || 'dev' }}
jobs:
release:
name: Release
runs-on: ubuntu-latest
environment: ${{ github.ref_name == 'main' && 'prod' || 'dev' }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.GH_PUSH_PROTECTED_KEY }}
# needed when building VitePress docs so timestamps can be calculated correctly
fetch-depth: 0
- uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: pnpm
registry-url: "https://registry.npmjs.org/"
scope: sit-onyx
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: 📦 Install dependencies
run: pnpm install
- name: 🛠️ Build packages
run: pnpm build:all --filter=!docs
- name: Upload Storybook artifact
uses: actions/upload-artifact@v4
with:
name: storybook-static
path: packages/sit-onyx/storybook-static
- name: Upload playground artifact
uses: actions/upload-artifact@v4
with:
name: playground
path: apps/playground/dist
- name: 🤖 Configure Git Bot
run: |
git config user.name "Release Bot[bot]"
git config user.email "bot@example.com"
- name: ⛴️ Version and Publish
if: ${{ env.STAGE == 'prod' }}
run: |
npx changeset version
npx changeset publish
git add --all
if [[ `git status --porcelain` ]]; then
git commit --amend --no-edit
git push --follow-tags
else
echo "No new version. Nothing to commit."
fi
- name: 📸 Snapshot and Publish
if: ${{ env.STAGE != 'prod' }}
run: |
# [Snapshot release fails if repository is in pre-release mode](https://github.com/changesets/changesets/issues/1195)
rm -f .changeset/pre.json
# Add empty changeset so we always have a new snapshot release for each new run
npx changeset add --empty
npx changeset version --snapshot
npx changeset publish --tag snapshot
# the docs need to be build AFTER the release because there the changelogs are generated which need to be included in the
# documentation build
- name: 🛠️ Build docs
run: pnpm build:all --filter=docs
env:
# needed for increase rate limit for the GitHub API that is used when building
# the VitePress documentation
VITEPRESS_GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload documentation artifact
uses: actions/upload-artifact@v4
with:
name: documentation
path: apps/docs/src/.vitepress/dist
deploy_storybook:
name: Deploy Storybook
runs-on: ubuntu-latest
needs: release
environment: ${{ github.ref_name == 'main' && 'prod' || 'dev' }}
steps:
- uses: actions/checkout@v4
- name: Download Storybook artifact
uses: actions/download-artifact@v4
with:
name: storybook-static
path: packages/sit-onyx/.cloud-foundry/storybook-static
- name: Deploy to Cloud Foundry
uses: ./.github/templates/cf-push
with:
endpoint: ${{ vars.CF_ENDPOINT }}
org: ${{ vars.CF_ORG }}
username: ${{ vars.CF_USERNAME }}
password: ${{ secrets.CF_PASSWORD }}
space: ${{ env.STAGE }}
working-directory: packages/sit-onyx/.cloud-foundry
deploy_documentation:
name: Deploy documentation
runs-on: ubuntu-latest
needs: release
environment: ${{ github.ref_name == 'main' && 'prod' || 'dev' }}
steps:
- uses: actions/checkout@v4
- name: Download Storybook artifact
uses: actions/download-artifact@v4
with:
name: documentation
path: apps/docs/.cloud-foundry/dist
- name: Deploy to Cloud Foundry
uses: ./.github/templates/cf-push
with:
endpoint: ${{ vars.CF_ENDPOINT }}
org: ${{ vars.CF_ORG }}
username: ${{ vars.CF_USERNAME }}
password: ${{ secrets.CF_PASSWORD }}
space: ${{ env.STAGE }}
working-directory: apps/docs/.cloud-foundry
deploy_playground:
name: Deploy Playground
runs-on: ubuntu-latest
needs: release
environment: ${{ github.ref_name == 'main' && 'prod' || 'dev' }}
steps:
- uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: playground
path: apps/playground/.cloud-foundry/dist
- name: Deploy to Cloud Foundry
uses: ./.github/templates/cf-push
with:
endpoint: ${{ vars.CF_ENDPOINT }}
org: ${{ vars.CF_ORG }}
username: ${{ vars.CF_USERNAME }}
password: ${{ secrets.CF_PASSWORD }}
space: ${{ env.STAGE }}
working-directory: apps/playground/.cloud-foundry