-
Notifications
You must be signed in to change notification settings - Fork 4
193 lines (163 loc) Β· 6.16 KB
/
checks.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: Pipeline
on:
pull_request:
paths-ignore:
- "**.md"
- "!.changeset/**"
push:
branches:
# latest release
- main
# maintenance releases
- v[0-9]+.x.x
- v[0-9]+.[0-9]+.x
env:
CI: true
HELM_CHART_BRANCH: gh-pages
jobs:
checks:
name: Checks
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
# changesets status requires deeper history
fetch-depth: 0
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Check for Uncommitted Changes
run: |
git diff --name-only --exit-code --relative || (echo "\nUncommitted changes found π" && exit 1)
- name: Read Changeset Status
id: changeset-status
if: github.event_name == 'pull_request'
uses: ./.github/actions/changeset-status
with:
args: --since origin/${{ github.base_ref }}
- name: Check Version Changes
if: steps.changeset-status.outputs.type
run: |
BASE_BRANCH="${{ steps.changeset-status.outputs.base_branch }}"
VERSION_TYPE="${{ steps.changeset-status.outputs.type }}"
# Check for invalid version bumps based on the branch type
if [[ "$BASE_BRANCH" =~ ^v[0-9]+\.[0-9]+\.x$ && "$VERSION_TYPE" != "patch" ]]; then
echo "π¨ Detected '$VERSION_TYPE' bump."
echo "π¨ Only 'patch' versions are allowed for the maintenance branch $BASE_BRANCH."
exit 1
fi
if [[ "$BASE_BRANCH" =~ ^v[0-9]+\.x\.x$ && "$VERSION_TYPE" == "major" ]]; then
echo "π¨ Detected '$VERSION_TYPE' bump."
echo "π¨ Only 'patch' or 'minor' versions are allowed for the maintenance branch $BASE_BRANCH."
exit 1
fi
echo "β
Detected '$VERSION_TYPE' bump."
- name: Run typecheck
run: yarn typecheck
- name: Run lint
run: yarn lint .
- name: Build Observability Package
run: yarn build-pkg observability
build:
name: Build and Version
runs-on: ubuntu-latest
# runs only on pushes so it does not run on PRs
if: github.event_name == 'push'
outputs:
tagged_release: ${{ steps.release-info.outputs.tag }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
# changesets status requires deeper history
fetch-depth: 0
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Read Changeset Status
id: changeset-status
uses: ./.github/actions/changeset-status
- name: Check if Version Already Exists
if: steps.changeset-status.outputs.new_version
run: |
NAME="${{ steps.changeset-status.outputs.name }}"
NEW_VERSION="${{ steps.changeset-status.outputs.new_version }}"
# Check that a tag for the new version does not already exist
if [[ ! -z $(git tag -l "$NAME@$NEW_VERSION") ]]; then
echo "π¨ The version '$NAME@$NEW_VERSION' already exists."
echo "π¨ Please ensure that the version bump and the base branch is correct."
exit 1
fi
# creates a PR if there are changesets or assign the new tag if the PR is merged
- name: Create Release Pull Request or Publish
id: changesets
# runs only when the changeset's base_branch is the target branch
if: steps.changeset-status.outputs.base_branch == '${{ github.ref_name }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MESSAGE: "π Release `${{ steps.changeset-status.outputs.name }}@${{ steps.changeset-status.outputs.old_version }} β ${{ steps.changeset-status.outputs.new_version }}`"
uses: changesets/action@v1
with:
title: ${{ env.MESSAGE }}
commit: ${{ env.MESSAGE }}
# define the publish command, so changeset creates a release in GitHub
publish: yarn release-tag
- name: Extract Release Info
id: release-info
if: steps.changesets.outputs.published == 'true'
# extract the first package name and version and format as `name-version`
# the publish-pkgs script expects `name-version` but not `name@version`
# so `release-tag` creates both but outputs only the default changeset format
run: |
TAG=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -r '.[0] | "\(.name)-\(.version)"')
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Preare Build Artifact
id: prepare-artifact
if: steps.release-info.outputs.tag
run: |
yarn publish-pkgs \
-s "${{ github.repository }}" \
-b "${{ env.HELM_CHART_BRANCH }}" \
-t "${{ steps.release-info.outputs.tag }}"
- name: Upload Charts Artifact
if: steps.prepare-artifact.conclusion == 'success'
uses: actions/upload-artifact@v4
with:
name: charts
path: tmp
if-no-files-found: error
release:
name: Helm Release
needs:
- build
- checks
if: needs.build.outputs.tagged_release
runs-on: ubuntu-latest
steps:
- name: Checkout Target Branch
uses: actions/checkout@v4
with:
ref: "${{ env.HELM_CHART_BRANCH }}"
- name: Configure Git User
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
- name: Set Up Helm CLI
uses: azure/setup-helm@v3
with:
version: v3.8.0
- name: Download Build Artifact
uses: actions/download-artifact@v4
with:
name: charts
- name: Commit and Push Changes
run: |
git add ./{assets,charts,extensions,index.yaml}
git commit -m "CI: Publish Helm charts for ${{ needs.build.outputs.tagged_release }}"
git push
- name: Run Helm Chart Releaser
uses: helm/[email protected]
with:
charts_dir: ./charts/*
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_SKIP_EXISTING: true