-
Notifications
You must be signed in to change notification settings - Fork 8
254 lines (249 loc) · 8.94 KB
/
crucible-release.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
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
---
name: crucible-release
on: # yamllint disable-line rule:truthy
workflow_dispatch:
inputs:
dry_run:
required: false
type: boolean
description: Do NOT push/delete branch to/from the repositories
default: false
custom_release:
required: false
type: string
description: Custom release (branch) to push/delete
default: ''
action:
required: true
type: choice
options:
- push
- delete
description: Action to perform with the custom_release (push or delete)
default: 'push'
force_push:
required: false
type: boolean
description: FORCE push (override branch)
default: false
workflow_call:
inputs:
dry_run:
required: false
type: boolean
description: Do NOT push/delete branch to/from the repositories
custom_release:
required: false
type: string
description: Custom release (branch) to push/delete
default: ''
action:
required: true
type: string
description: Action to perform (push or delete)
force_push:
required: false
type: boolean
description: FORCE push (override branch)
secrets:
PRIVATE_KEY__TAG_CRUCIBLE_RELEASE:
required: true
concurrency:
group: crucible-release
cancel-in-progress: false
jobs:
release-branch:
runs-on: [ self-hosted, workflow-overhead ]
timeout-minutes: 10
outputs:
branch: ${{ steps.gen-release-branch.outputs.release }}
repos: ${{ steps.get-repos.outputs.repos }}
steps:
- name: Generate release branch
id: gen-release-branch
run: |
if [ "${{ inputs.custom_release }}" == "" ]; then
year="$(date -u +%Y)"
month="$(date -u +%m)"
month=${month#0}
quarter="$(((month-1)/3+1))"
echo "release=$year.$quarter" >> $GITHUB_OUTPUT
else
echo "release=${{ inputs.custom_release }}" >> $GITHUB_OUTPUT
fi
- name: Display params
id: get-params
env:
BRANCH: ${{ steps.gen-release-branch.outputs.release }}
DRY_RUN: ${{ inputs.dry_run }}
CUSTOM_RELEASE: ${{ inputs.custom_release }}
ACTION: ${{ inputs.action }}
GITHUB_EVENT: ${{ github.event_name }}
FORCE_PUSH: ${{ inputs.force_push }}
run: |
echo "branch=$BRANCH"
echo "dry_run=$DRY_RUN"
echo "custom_release=$CUSTOM_RELEASE"
echo "action=$ACTION"
echo "github_event=$GITHUB_EVENT"
echo "force_push=$FORCE_PUSH"
- name: Generate token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.APP_ID__TAG_CRUCIBLE_RELEASE }}
private-key: ${{ secrets.PRIVATE_KEY__TAG_CRUCIBLE_RELEASE }}
owner: ${{ github.repository_owner }}
- name: checkout crucible default
uses: actions/checkout@v4
with:
repository: perftool-incubator/crucible
ref: ${{ github.ref }}
path: crucible
set-safe-directory: false
token: ${{ steps.generate-token.outputs.token }}
- name: push/delete branch to/from the crucible repo
if: ${{ inputs.dry_run == false }}
env:
BRANCH: ${{ steps.gen-release-branch.outputs.release }}
run: |
cd $GITHUB_WORKSPACE
cd crucible
echo "Branches:"
git ls-remote --heads origin
echo "Local Branches:"
git branch
echo "Current commit's object name:"
git rev-parse --verify HEAD
echo "Current object name for branch $BRANCH (if it exists):"
git rev-parse --verify remotes/origin/$BRANCH || true
if [ "${{ inputs.action }}" == "push" ]; then
ARGS=""
if [ "${{ inputs.force_push }}" == "true" ]; then
ARGS="--force"
fi
git checkout -B $BRANCH
git push origin heads/$BRANCH $ARGS
elif [ "${{ inputs.action }}" == "delete" ]; then
if [ "${{ inputs.force_push }}" == "true" ]; then
git push --delete origin heads/$BRANCH || true
else
git push --delete origin heads/$BRANCH
fi
fi
echo "Current object name for branch $branch (if it exists):"
git rev-parse --verify remotes/origin/$BRANCH || true
- name: Get the list of sub-projects
id: get-repos
run: |
cd $GITHUB_WORKSPACE
cd crucible/config
# get 3rd column (repo URL) without the starting '/' (remove first char),
# so repo urls /a /b /c are extracted to a b c
# and add to a bash array ( a b c )
projects=( $(jq -r '.official[] | select(.name != "crucible") | .repository | sub(".*\/"; "")' repos.json) )
# builtin implict join array "a","b","c" (double quotes for a valid json)
printf -v list '"%s",' "${projects[@]}"
# convert to a comma separated list ["a","b","c"]
echo "repos=[${list%,}]" >> $GITHUB_OUTPUT
- name: Display sub-projects repos list
id: display-repos
env:
REPOS: ${{ steps.get-repos.outputs.repos }}
run: echo "$REPOS"
projects-branch:
runs-on: [ self-hosted, workflow-overhead ]
timeout-minutes: 10
needs:
- release-branch
strategy:
matrix:
repository: ${{ fromJSON(needs.release-branch.outputs.repos) }}
steps:
- name: Display sub-project repository name
run: |
echo "repository=${{ matrix.repository }}"
- name: Generate token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.APP_ID__TAG_CRUCIBLE_RELEASE }}
private-key: ${{ secrets.PRIVATE_KEY__TAG_CRUCIBLE_RELEASE }}
owner: ${{ github.repository_owner }}
- name: checkout sub-project repository
uses: actions/checkout@v4
with:
repository: perftool-incubator/${{ matrix.repository }}
path: ${{ matrix.repository }}
set-safe-directory: false
token: ${{ steps.generate-token.outputs.token }}
- name: push/delete release branch
if: ${{ inputs.dry_run == false }}
env:
BRANCH: ${{ needs.release-branch.outputs.branch }}
run: |
cd $GITHUB_WORKSPACE
cd ${{ matrix.repository }}
echo "Branches:"
git ls-remote --heads origin
echo "Local Branches:"
git branch
echo "Current commit's object name:"
git rev-parse --verify HEAD
echo "Current object name for branch $BRANCH (if it exists):"
git rev-parse --verify remotes/origin/$BRANCH || true
if [ "${{ inputs.action }}" == "push" ]; then
ARGS=""
if [ "${{ inputs.force_push }}" == "true" ]; then
ARGS="--force"
fi
git checkout -B $BRANCH
git push origin heads/$BRANCH $ARGS
elif [ "${{ inputs.action }}" == "delete" ]; then
if [ "${{ inputs.force_push }}" == "true" ]; then
git push --delete origin heads/$BRANCH || true #branch
else
git push --delete origin heads/$BRANCH #branch
fi
fi
echo "Current object name for branch $BRANCH (if it exists):"
git rev-parse --verify remotes/origin/$BRANCH || true
crucible-release-verification:
if: ${{ inputs.action == 'push' }}
runs-on: ubuntu-latest
timeout-minutes: 10
needs:
- release-branch
- projects-branch
steps:
- name: checkout crucible
uses: actions/checkout@v4
with:
repository: perftool-incubator/crucible
ref: ${{ github.ref }}
path: crucible
- name: prepare installation resources
run: |
touch /tmp/auth-file.json
cfgfile=$(grep SYSCONFIG= crucible/crucible-install.sh | cut -d '=' -f2 | sed 's/"//g')
sudo mkdir -p $(dirname $cfgfile)
- name: test release install
env:
BRANCH: ${{ needs.release-branch.outputs.branch }}
run: |
sudo ./crucible/crucible-install.sh \
--release $BRANCH \
--engine-registry myregistry.io/crucible \
--engine-auth-file /tmp/auth-file.json \
--name "Nobody" \
--email "[email protected]" \
--verbose
crucible-release-complete:
runs-on: [ self-hosted, workflow-overhead ]
timeout-minutes: 10
needs:
- crucible-release-verification
steps:
- name:
run: |
echo "crucible-release-complete"