-
Notifications
You must be signed in to change notification settings - Fork 124
192 lines (183 loc) · 7.74 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
name: GitHub Release Pipeline
on:
release:
types: [published]
jobs:
## Pepararation job for setting up relevant variables
setup:
name: Setup variables
runs-on: ubuntu-latest
# Declare output variables to be usable in other jobs
outputs:
output1: ${{steps.var_step.outputs.version}}
output2: ${{steps.date_step.outputs.docdate}}
output3: ${{steps.var_step.outputs.suffix}}
steps:
# Check out the GitHub repository
- name: Checkout interface
uses: actions/checkout@v4
with:
path: dist/open-simulation-interface
# Set the version variable based on the latest tag (could be replaced with github-internal predefined variable?)
- name: Set version
id: var_step
working-directory: dist/open-simulation-interface
run: |
echo "version=$(git describe --tags --always | sed 's/^v//')" >> $GITHUB_OUTPUT
echo "suffix=$(git describe --tags --always | sed -r 's/^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+//')" >> $GITHUB_OUTPUT
# Set the release date (current date)
- name: Set date
id: date_step
run: echo "docdate=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
## Tag and update related repositories before checking them out for Antora and the deliverables
tagging_update:
name: Update OSMP & Documentation
runs-on: ubuntu-22.04
needs: [setup]
steps:
- name: Update OSMP
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.MACHINE_USER_PAT }}
event-type: update-tag
repository: OpenSimulationInterface/osi-sensor-model-packaging
client-payload: '{"tag": "v${{needs.setup.outputs.output1}}", "suffix": "${{needs.setup.outputs.output3}}", "source_repo": "${{ github.repository }}"}'
- name: Update Documentation
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.MACHINE_USER_PAT }}
event-type: update-tag
repository: OpenSimulationInterface/osi-documentation
client-payload: '{"tag": "v${{needs.setup.outputs.output1}}"}'
- name: Provide downstream repos some time
uses: whatnick/wait-action@v0.1.2
with:
time: '1m'
## Antora job, responsible for creating the Antora output of the release
antora:
name: Generate Antora content
runs-on: ubuntu-22.04
needs: [tagging_update]
steps:
# Check out the Antora generator
- name: Checkout Antora generator
uses: actions/checkout@v4
with:
repository: OpenSimulationInterface/osi-antora-generator
path: antora
submodules: true
# Remove building branches for the main repositories. This will lead to Antora only using the tagged versions to build its content.
- name: Manipulate site.yml
working-directory: antora
run: |
sed -i -E 's/branches: (.*) \# (open-.*|osi-.*)/branches: ~/g' site.yml
cat site.yml
# Create custom build instructions for GitHub compatibility
- name: Create run instructions
run: |
echo "#!/bin/bash
cd antora
cat site.yml
export NODE_OPTIONS="--max-old-space-size=8192"
exec antora --stacktrace --fetch --clean site.yml" > antora.sh
cat antora.sh
# Run Antora to generate the document
- name: Run Antora
uses: docker://ghcr.io/asam-ev/project-guide-docker:4
with:
entrypoint: sh
args: antora.sh
# Upload the created artifact for later jobs to use
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: antora
path: antora/site
## Step for creating the zip file with all deliverables
deliverables:
name: Create deliverables package
runs-on: ubuntu-latest
needs: [setup,antora]
steps:
# Check out the repository (again)
- name: Checkout interface
uses: actions/checkout@v4
with:
path: dist/open-simulation-interface_${{needs.setup.outputs.output1}}
# Check out the sensor model packaging repo
- name: Checkout sensor model packaging
uses: actions/checkout@v4
with:
repository: OpenSimulationInterface/osi-sensor-model-packaging
path: dist/osi-sensor-model-packaging
fetch-depth: 0
# Retrieve the Antora artifact from the previous job
- name: Retrieve Antora artifact
uses: actions/download-artifact@v4
with:
name: antora
path: dist/ASAM_OSI_Standard_${{needs.setup.outputs.output1}}/
# Create the mandatory README.txt file for the deliverables package. The functions and variables declared below will create a readme file with a defined header, surrounded by a box made of "*".
- name: Get OSMP version
working-directory: dist/osi-sensor-model-packaging
run: |
OSMP_VERSION="$(git describe --tags --exclude 'v*.*.*-antora' --exclude 'x-antora-v*.*.*'| sed 's/^v//')"
echo "OSMP_VERSION=$OSMP_VERSION" >> $GITHUB_ENV
- name: Create README
working-directory: dist
run: |
declare -i char_count=84
declare -i char_count_header=$char_count-1
repeat(){ for i in $(eval echo {1..$1}); do echo -n "$2"; done; echo ""; }
fill(){ declare -i length=$1-${#2}-9; spaces=$(repeat $length ".");echo "***" "$2" "${spaces//./ }" "***"; }
name="ASAM OSI"
version="Version: ${{needs.setup.outputs.output1}}"
date="Date: ${{needs.setup.outputs.output2}}"
echo "/$(repeat $char_count_header "*")" > README.txt
fill $char_count "$name" >> README.txt
fill $char_count "$version" >> README.txt
fill $char_count "$date" >> README.txt
echo "$(repeat $char_count_header "*")/" >> README.txt
echo "The deliverables of ASAM OSI v${{needs.setup.outputs.output1}} include:
- ASAM_OSI_Standard_${{needs.setup.outputs.output1}}
- open_simulation_interface_${{needs.setup.outputs.output1}}
- osi-sensor-model-packaging_${{ env.OSMP_VERSION }}" >> "README.txt"
cat README.txt
mv osi-sensor-model-packaging osi-sensor-model-packaging_${{ env.OSMP_VERSION }}
# Package all collected deliverables
- name: Zip Release
uses: TheDoctor0/zip-release@0.7.6
with:
filename: ASAM_OSI_${{needs.setup.outputs.output1}}.zip
directory: dist
# Upload the created artifact for the publish job
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: deliverables
path: dist/ASAM_OSI_${{needs.setup.outputs.output1}}.zip
## Publishing step, where the created zip file is uploaded to the triggering release publication
publish:
name: Add deliverables to release
runs-on: ubuntu-latest
needs: [deliverables, setup]
steps:
# Retrieve the previously uploaded deliverables artifact
- name: Retrieve previous artifacts
uses: actions/download-artifact@v4
with:
name: deliverables
# Add the new zip file with the deliverables to the respective release
- name: Add deliverables to release
uses: svenstaro/upload-release-action@v2
with:
file: ASAM_OSI_${{needs.setup.outputs.output1}}.zip
tag: ${{ github.ref }}
- name: Trigger generator
if: ${{ env.MUP_KEY != '' }}
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.MACHINE_USER_PAT }}
event-type: antora-build-trigger
repository: OpenSimulationInterface/osi-antora-generator
client-payload: '{"src": "${{ github.repository }}", "ref": "master"}'