-
Notifications
You must be signed in to change notification settings - Fork 1
223 lines (194 loc) · 6.79 KB
/
release.yaml
File metadata and controls
223 lines (194 loc) · 6.79 KB
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
name: 🚀 Release
on:
workflow_dispatch:
permissions:
id-token: write
contents: read
concurrency:
group: ${{ github.workflow }}
env:
PACKAGE_ARTIFACT: packages
UPDATED_MATRIX_ARTIFACT: updated-matrix
UPDATED_MATRIX_JSON_FOLDER: ${{ github.workspace }}/__updated_packages
IS_PRE_RELEASE: ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }}
jobs:
identify-packages:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.details.outputs.details }}
name: 🗂️ Identify Publishable Packages
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
sparse-checkout: |
**/package.json
.github/**
sparse-checkout-cone-mode: false
- name: Get details of packages
id: details
uses: ./.github/actions/get-public-packages
version:
needs: identify-packages
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package: ${{ fromJson(needs.identify-packages.outputs.matrix) }}
name: ${{ format('🏷️ Version "{0}" Package', matrix.package.shortName) }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
sparse-checkout: |
${{ matrix.package.location }}
peripheral/**
package.json
package-lock.json
.nvmrc
.github/**
sparse-checkout-cone-mode: false
- id: update-check
name: Check that updated packages have new version from current production release
uses: ./.github/actions/check-for-update
with:
name: ${{ matrix.package.name }}
version: ${{ matrix.package.version }}
- id: pre-release-version
name: Version beta packages
if: ${{ fromJSON(env.IS_PRE_RELEASE) && fromJson(steps.update-check.outputs.changed) }}
uses: ./.github/actions/version-pre-release-packages
with:
name: ${{ matrix.package.name }}
version: ${{ matrix.package.version }}
- name: Workaround actions/upload-artifact#176
if: fromJson(steps.update-check.outputs.changed)
run: mktemp ./tmp.XXXXXXXX
- name: Upload updated package.json to artifact
if: steps.pre-release-version.outcome == 'success'
uses: actions/upload-artifact@v5
with:
name: ${{ format('{0}-{1}', env.PACKAGE_ARTIFACT, matrix.package.shortName) }}
path: |
${{ matrix.package.location }}
./tmp.*
retention-days: 1
- id: artifact-json
if: fromJson(steps.update-check.outputs.changed)
run: |
mkdir -p ${{ env.UPDATED_MATRIX_JSON_FOLDER }}
filePath="${{ env.UPDATED_MATRIX_JSON_FOLDER }}/${{ matrix.package.shortName }}.json"
echo filePath="$filePath" >> $GITHUB_OUTPUT
echo '${{ toJson(matrix.package) }}' > "$filePath"
shell: bash
- name: Upload to publish matrix
if: steps.artifact-json.outcome == 'success'
uses: actions/upload-artifact@v5
with:
name: ${{ format('{0}-{1}', env.UPDATED_MATRIX_ARTIFACT, matrix.package.shortName) }}
path: |
${{ steps.artifact-json.outputs.filePath }}
./tmp.*
retention-days: 1
prepare-publish:
runs-on: ubuntu-latest
needs: version
outputs:
matrix: ${{ steps.updatedPackages.outputs.packageArray }}
name: 👨🍳 Prepare Publishing Matrix
steps:
- uses: actions/download-artifact@v5
with:
pattern: ${{ env.UPDATED_MATRIX_ARTIFACT }}-*
merge-multiple: true
- name: Check for at least one package update
id: check-for-an-update
run: |
if [ -z "$(ls -A ${{ env.UPDATED_MATRIX_JSON_FOLDER }})" ]; then
exit 1
fi
continue-on-error: true
shell: bash
- name: Set failure output
if: steps.check-for-an-update.outcome == 'failure'
uses: actions/github-script@v7
with:
script: core.setFailed('No packages to publish')
- id: updatedPackages
name: Prepare array of packages to publish to drive matrix
run: echo packageArray=$(jq --slurp '.' ${{ env.UPDATED_MATRIX_JSON_FOLDER }}/*) >> $GITHUB_OUTPUT
shell: bash
reify-workspace:
runs-on: ubuntu-latest
needs: prepare-publish
name: 🏗️ Reify Package Versions
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
sparse-checkout: |
**/package.json
package-lock.json
.nvmrc
.github/**
sparse-checkout-cone-mode: false
- uses: actions/download-artifact@v5
with:
pattern: ${{ env.PACKAGE_ARTIFACT }}-*
merge-multiple: true
- id: reify
name: Reify package.json files
uses: ./.github/actions/reify-workspace
- name: Workaround actions/upload-artifact#176
run: mktemp ./tmp.XXXXXXXX
- id: createPathArray
name: Create path array for upload to artifact
run: |
{
echo 'pathArray<<EOF'
echo ./tmp.*
jq --raw-output '.[] | .location' <<< '${{ needs.prepare-publish.outputs.matrix }}'
echo EOF
} >> $GITHUB_OUTPUT
shell: bash
- name: Upload (potentially reified) package.jsons to artifact
uses: actions/upload-artifact@v5
with:
name: ${{ env.PACKAGE_ARTIFACT }}
path: ${{ steps.createPathArray.outputs.pathArray }}
retention-days: 1
publish:
runs-on: ubuntu-latest
needs: [reify-workspace, prepare-publish]
strategy:
fail-fast: false
matrix:
package: ${{ fromJson(needs.prepare-publish.outputs.matrix) }}
name: ${{ format('📤 Publish "{0}" Package', matrix.package.shortName) }}
steps:
- name: Checkout git folder
uses: actions/checkout@v4
with:
sparse-checkout: |
.git/**
sparse-checkout-cone-mode: false
- name: Workaround actions/checkout#1475
run: git config core.sparseCheckout false
shell: bash
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/download-artifact@v5
with:
name: ${{ env.PACKAGE_ARTIFACT }}
- id: newVersion
name: Get new version from package.json
run: echo version=$(jq --raw-output '.version' ${{ matrix.package.location }}) >> $GITHUB_OUTPUT
shell: bash
- name: Publish package
uses: ./.github/actions/publish
with:
name: ${{ matrix.package.name }}
version: ${{ steps.newVersion.outputs.version }}
is-pre-release: ${{ env.IS_PRE_RELEASE }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}