-
Notifications
You must be signed in to change notification settings - Fork 5
133 lines (116 loc) · 4.2 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
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
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.GH_PUSH_PROTECTED_KEY }}
- uses: pnpm/action-setup@v2
- 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
- name: Upload Storybook artifact
uses: actions/upload-artifact@v3
with:
name: storybook-static
path: packages/sit-onyx/storybook-static
- name: Upload documentation artifact
uses: actions/upload-artifact@v3
with:
name: documentation
path: apps/docs/src/.vitepress/dist
- name: 🤖 Configure Git Bot
run: |
git config user.name "Release Bot[bot]"
git config user.email "[email protected]"
- 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
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@v3
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 }}
# we need to define a fallback value here because the default for the input
# is only assigned when the workflow is triggered manually. When triggered e.g. on push
# the input will be unset so a fallback is needed here
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@v3
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 }}
# we need to define a fallback value here because the default for the input
# is only assigned when the workflow is triggered manually. When triggered e.g. on push
# the input will be unset so a fallback is needed here
space: ${{ env.STAGE }}
working-directory: apps/docs/.cloud-foundry