forked from eclipse-velocitas/vehicle-app-cpp-template
-
Notifications
You must be signed in to change notification settings - Fork 0
244 lines (204 loc) · 10.7 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
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
# This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json
# Copyright (c) 2022-2024 Contributors to the Eclipse Foundation
#
# 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
name: Release workflow
on:
release:
types: [published, edited]
# Needed if GITHUB_TOKEN by default do not have right to create release
permissions:
contents: write
packages: write
jobs:
get-app-name:
runs-on: ubuntu-22.04
name: Get App-Name
outputs:
app_name: ${{ steps.export-app-name.outputs.app_name }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get app-name
id: export-app-name
run: |
NAME=$(cat ./app/AppManifest.json | jq -r '.name')
echo "app_name=$NAME" >> $GITHUB_OUTPUT
gen-desired-state:
uses: ./.github/workflows/gen-desired-state.yml
needs: [get-app-name]
with:
app_name: ${{ needs.get-app-name.outputs.app_name }}
upload-images:
name: "Upload image (${{ needs.get-app-name.outputs.app_name }})"
runs-on: ubuntu-22.04
needs: get-app-name
env:
APP_NAME: ${{ needs.get-app-name.outputs.app_name }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract version from tag
id: get_version
run: |
VERSION=${GITHUB_REF_NAME#v}
echo Version: $VERSION
echo "version-without-v=$VERSION" >> $GITHUB_OUTPUT
- run: echo "Using VehicleApp version ${{ steps.get_version.outputs.version-without-v }} from tag"
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: github-repository-name-case-adjusted
name: Prepare repository name in lower case for docker upload.
uses: ASzc/change-string-case-action@v6
with:
string: ${{ github.repository }}
- name: Wait for Multi-Arch build to succeed
uses: fountainhead/[email protected]
with:
checkName: Merge Trivy results
token: ${{ secrets.GITHUB_TOKEN }}
# This workflow does not trigger a build, instead it relies on that a successful build
# exists for this commit. If triggering this workflow just after a new commit has been
# uploaded we will need to wait for the "Merge Trivy results" to finish
# Building the default C++ App on Github may take long time, 70 minutes observed
# Setting limit to 100 minutes to have some margin
timeoutSeconds: 6000
intervalSeconds: 20
- name: Download builds from Build multiarch image workflow artifacts
uses: dawidd6/action-download-artifact@v3
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: build-multiarch-image.yml
workflow_conclusion: success
commit: ${{ github.sha }}
path: ${{github.workspace}}
- name: "${{ env.APP_NAME }} -- Publish release image to GHCR"
working-directory: ${{github.workspace}}
env:
VAPP_IMAGE: ${{ env.APP_NAME }}-multiarch-oci-archive/${{ env.APP_NAME }}-oci-multiarch.tar
VAPP_NAME: ${{ env.APP_NAME }}
VAPP_VERSION: ${{ steps.get_version.outputs.version-without-v }}
REGISTRY: "ghcr.io/${{steps.github-repository-name-case-adjusted.outputs.lowercase}}"
run: |
tag=$(echo docker://$REGISTRY/$VAPP_NAME:$VAPP_VERSION | tr '[:upper:]' '[:lower:]')
echo "Copy vApp image $VAPP_IMAGE to '$tag'"
skopeo copy --all oci-archive:$VAPP_IMAGE "$tag"
- name: ${{ env.APP_NAME }} -- Upload assets
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
${{github.workspace}}/AppManifest/AppManifest.json
${{github.workspace}}/binaries/*
${{github.workspace}}/${{ env.APP_NAME }}-multiarch-docker-archive/*
release-documentation:
name: Generate release documentation
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "18"
check-latest: true
- name: Conditional input event value
uses: haya14busa/action-cond@v1
id: condval
with:
cond: ${{ !github.event.inputs.name }}
if_true: ${{ github.event.inputs.name }}
if_false: ${{ github.sha }}
- name: Wait for CI workflow to succeed
uses: fountainhead/[email protected]
with:
checkName: Build, Test and Lint
token: ${{ secrets.GITHUB_TOKEN }}
timeoutSeconds: 1200
intervalSeconds: 30
- name: Download artifact from CI workflow
uses: dawidd6/action-download-artifact@v3
with:
workflow: ci.yml
workflow_conclusion: success
commit: ${{ steps.condval.outputs.value }}
path: generated_md
- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: "0.89.4"
extended: true
- name: Set tags output
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Check output
env:
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
run: |
echo $RELEASE_VERSION
echo ${{ steps.vars.outputs.tag }}
- name: Create and Add reports to hugo static html site
run: |
hugo new site hugo
cp ./README.md ./hugo/content/_index.md
mkdir ./hugo/content/documentation
mkdir ./hugo/content/reports
cp ./README.md ./hugo/content/documentation/_index.md
sed -i '1d' hugo/content/documentation/_index.md
sed -i '1s/^/---\ntitle: "VehicleApp using cpp"\ndraft: false\n---\n/' hugo/content/documentation/_index.md
cp generated_md/test-results/* ./hugo/content/reports
sed -i '1s/^/---\ntitle: "Code Coverage Test"\ndraft: false\n---\n/' hugo/content/reports/code-coverage-results.md
sed -i '1s/^/---\ntitle: "Unit Test Results"\ndraft: false\n---\n/' hugo/content/reports/test-results.md
mkdir ./hugo/config
mkdir ./hugo/config/_default
mkdir ./hugo/config/pages
echo $'languageCode = "en-us"\ntitle = "Release Documentation - @tag"\n\nbaseURL = "http://example.org/"\n\n# Keep uglyURLs for now, as this provides the best out of the box support for rendering markdown images in VSCode preview and Hugo\n# Link: https://gohugo.io/content-management/urls/#ugly-urls\nuglyURLs = "true"\n\nenableGitInfo = true\n\ntheme = "hugo-geekdoc"\n\n# Geekdoc required configuration\npygmentsUseClasses = true\npygmentsCodeFences = true\ndisablePathToLower = true\n\n[markup]\ndefaultMarkdownHandler = "goldmark"\n\n[markup.goldmark.renderer]\nunsafe = true\n\n[markup.tableOfContents]\n ordered= false\n startLevel= 1\n endLevel= 3\n\n[params]\ngeekdocRepo = "https://github.com/eclipse-velocitas/vehicle-app-cpp-template"\ngeekdocEditPath = "edit/main/hugo/content"\ngeekdocCollapseSection = true\n' > ./hugo/config/_default/config.toml
echo $'# Hugo-Geekdoc Theme Config\n\nbaseURL = "https://fantastic-fiesta-da4ab8e5.pages.github.io/"\n\ntheme = "hugo-geekdoc"\n\nenableGitInfo = false\n\npluralizeListTitles = false\npygmentsUseClasses = true\n\n[markup]\n defaultMarkdownHandler = "goldmark"\n\n[markup.highlight]\n anchorLineNos = false\n codeFences = true\n guessSyntax = false\n hl_Lines = ""\n lineAnchors = ""\n lineNoStart = 1\n lineNos = true\n lineNumbersInTable = true\n noClasses = false\n style = "paraiso-dark"\n tabWidth = 4\n\n[markup.tableOfContents]\n endLevel = 3\n ordered = false\n startLevel = 1\n\n[markup.goldmark.extensions]\n typographer = true\n\n[markup.goldmark.renderer]\n unsafe = true\n\n# Disable geekdoc default theme settings\n[params]\ngeekdocRepo = ""\ngeekdocEditPath = ""\n# disable non-working search when serving from local file system\ngeekdocSearch = false\n' > ./hugo/config/pages/config.toml
mkdir hugo/data/menu
echo "---" > ./hugo/data/menu/extra.yaml
printf "header:\n - name: GitHub\n ref: https://github.com/eclipse-velocitas/vehicle-app-cpp-template\n icon: gdoc_github\n external: true\n" >> ./hugo/data/menu/extra.yaml
echo "---" > ./hugo/data/menu/more.yaml
printf 'more:\n - name: Releases\n ref: "https://github.com/eclipse-velocitas/vehicle-app-cpp-template/releases"\n external: true\n icon: "gdoc_download"\n - name: "View Source"\n ref: "https://github.com/eclipse-velocitas/vehicle-app-cpp-template/tree/@tag"\n external: true\n icon: "gdoc_github"\n' >> ./hugo/data/menu/more.yaml
sed -i -e 's/@tag/${{ steps.vars.outputs.tag }}/g' ./hugo/config/_default/config.toml
sed -i -e 's/@tag/${{ steps.vars.outputs.tag }}/g' ./hugo/data/menu/more.yaml
- name: Build
working-directory: ${{github.workspace}}/hugo
env:
GEEKDOC_THEME_VERSION: 0.21.1
# hugo --minify not fully supported by hugo-geekdoc theme
run: |
echo "Download theme hugo-geekdoc v${GEEKDOC_THEME_VERSION}"
mkdir -p themes/hugo-geekdoc/
curl -L https://github.com/thegeeklab/hugo-geekdoc/releases/download/v${GEEKDOC_THEME_VERSION}/hugo-geekdoc.tar.gz | tar -xz -C themes/hugo-geekdoc/ --strip-components=1
echo "Build release documentation for GitHub Pages"
hugo -d ./public --environment=pages
- name: zip
run: |
cd ${{github.workspace}}/hugo/public
zip -r ${{github.workspace}}/release-documentation.zip .
- name: Upload assets
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
release-documentation.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to GH Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ${{github.workspace}}/hugo/public
publish_branch: gh_pages