-
Notifications
You must be signed in to change notification settings - Fork 15
143 lines (116 loc) · 4.04 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
###############################################################
# Copyright (c) 2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
###############################################################
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: release
on:
push:
branches:
- main
paths:
- src/**
- package.json
- yarn.lock
- CHANGELOG.md
workflow_dispatch:
permissions:
contents: write
pages: write
id-token: write
pull-requests: write
concurrency:
group: pages
cancel-in-progress: false
jobs:
check-version:
runs-on: ubuntu-latest
outputs:
version-bumped: ${{ steps.version-check.outputs.bumped }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get latest git tag
id: git-tag-latest
uses: actions-ecosystem/action-get-latest-tag@v1
- name: Remove tag 'v' prefix
run: echo "GIT_VERSION=$(echo ${{ steps.git-tag-latest.outputs.tag }} | cut -c2-)" >> $GITHUB_ENV
- name: Get npm version
id: npm-version
uses: martinbeentjes/npm-get-version-action@3cf273023a0dda27efcd3164bdfb51908dd46a5b # v1.3.1
- name: Output versions
run: |
echo git ${{ env.GIT_VERSION }}
echo npm ${{ steps.npm-version.outputs.current-version }}
- name: Check if version is bumped
id: version-check
run: |
if [[ "${{ env.GIT_VERSION }}" == "${{ steps.npm-version.outputs.current-version }}" ]]; then
echo "Versions match. Skipping publish."
echo "bumped=false" >> $GITHUB_OUTPUT
else
echo "Versions do not match. Proceeding with publish."
echo "bumped=true" >> $GITHUB_OUTPUT
fi
build-and-publish:
runs-on: ubuntu-latest
needs: check-version
if: needs.check-version.outputs.version-bumped == 'true'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup Node
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- name: Get npm version
id: npm-tag
uses: martinbeentjes/npm-get-version-action@3cf273023a0dda27efcd3164bdfb51908dd46a5b # v1.3.1
- name: Install Dependencies
run: yarn
- name: Linter Checks
run: yarn lint
- name: Unit Tests
run: CI=true yarn test
- name: Build Library
run: yarn build
- name: Build Storybook
run: yarn build:storybook
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'storybook'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- name: Release Please GitHub Action
uses: googleapis/release-please-action@v4
id: release
with:
release-type: node
token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish Shared Components to npm
if: ${{ steps.release.outputs.release_created }}
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH }}