-
Notifications
You must be signed in to change notification settings - Fork 8
180 lines (153 loc) · 6.3 KB
/
release-publish.yaml
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
175
176
177
178
name: "Publish Release Workflow"
# When merging release commit on master
# - Build & publish NPM libs
# - Create & push git tag
# - Build & publish demo site docker image
# - Deploy chromatic
# - Create GH release notes
on:
push:
branches:
- master
concurrency:
group: "${{ github.workflow }}-${{ github.ref_name }}"
cancel-in-progress: true
jobs:
is_release_commit:
name: "Check is release commit"
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || env.GITHUB_SHA }}
- name: "Check is release commit"
id: check
run: |
set -x # verbose
message=$(git show -s --format=%s)
version=$(echo $message | egrep -o '[0-9]+\.[0-9]+\.[0-9]+' || true)
# Check is release commit has version
if [[ "$message" == 'chore(release): release v'* ]] && [ -n "$version" ]; then
echo "version=$version" >> "$GITHUB_OUTPUT"
fi
outputs:
version: ${{ steps.check.outputs.version }}
build_publish_NPM:
name: "Build & publish NPM libs"
needs: [is_release_commit]
if: ${{ needs.is_release_commit.outputs.version }}
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
uses: actions/checkout@v3
with:
token: '${{ secrets.GITBOT_TOKEN }}'
fetch-depth: 0
- name: "Setup"
uses: ./.github/actions/setup
- name: "Build libs"
run: yarn build:libs
- name: "Publish version to NPM"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
for package in $(echo packages/lumx-*);
do
(echo "Publishing $package"; cd $package/dist; npm publish --tag latest)
done
- name: "Git tag"
id: git
run: |
set -x
# Create tag
tag="v${{ needs.is_release_commit.outputs.version }}"
echo "tag=$tag" >> $GITHUB_OUTPUT
git tag "$tag"
# Push tag
git push origin "$tag"
outputs:
tag: ${{ steps.git.outputs.tag }}
deploy_chromatic:
name: "Deploy chromatic"
needs: [build_publish_NPM]
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
uses: actions/checkout@v3
with:
fetch-depth: 0 # retrieve all the repo history (required by chromatic)
- name: "Setup"
uses: ./.github/actions/setup
- name: "Deploy chromatic"
uses: chromaui/action@3f82bf5d065290658af8add6dce946809ee0f923 #v6.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
projectToken: ${{ secrets.CHROMATIC_TOKEN }}
buildScriptName: build:storybook
deploy_demo_site:
name: "Deploy demo site"
needs: [build_publish_NPM]
timeout-minutes: 30
runs-on: ubuntu-latest
env:
GCP_PROD_REGISTRY: gcr.io/lumapps-registry
steps:
- name: "Checkout repository"
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: "Login to GCR"
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
registry: gcr.io
username: _json_key
password: ${{ secrets.GCR_PROD_RW_CREDS }}
- name: "Setup buildx"
id: buildx_setup
uses: docker/setup-buildx-action@8c0edbc76e98fa90f69d9a2c020dcb50019dc325
with:
install: true
- run: |
echo "git_commit=$(git rev-parse HEAD)" >> $GITHUB_ENV
echo "build_date=$(date --rfc-3339=seconds)" >> $GITHUB_ENV
echo "version=${{ needs.build_publish_NPM.outputs.tag }}" >> $GITHUB_ENV
- name: "Docker metadata"
id: meta
uses: docker/metadata-action@f206c36955d3cc6213c38fb3747d9ba4113e686a
with:
tags: |
type=raw,value=${{ env.version }}
type=raw,value=${{ env.git_commit }}
images: |
${{ env.GCP_PROD_REGISTRY }}/design-system
labels: |
com.lumapps.image.created=${{ env.build_date }}
com.lumapps.image.sha1=${{ env.git_commit }}
com.lumapps.image.authors=frontend@lumapps.com
com.lumapps.image.version=${{ env.version }}
- name: "Build image"
uses: docker/build-push-action@c56af957549030174b10d6867f20e78cfd7debc5
with:
context: ./
file: ${{ matrix.dockerfile }}
builder: ${{ steps.buildx_setup.outputs.name }}
build-args: version=${{ env.version }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha, scope=${{ github.workflow }}
cache-to: type=gha, scope=${{ github.workflow }}, mode=max
- name: "Deploy site"
env:
GH_TOKEN: ${{ secrets.GITBOT_TOKEN }}
run: gh workflow run -R lumapps/design-system-deployment update-lumx-version.yml
create_gh_release:
name: "Create release note"
needs: [build_publish_NPM]
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
uses: actions/checkout@v3
- name: "Create release note"
uses: ./.github/actions/release-note