Skip to content

Build: Create a release pipeline that replaces the manual creation of a deliverable package #678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 56 commits into from
Mar 31, 2023
Merged
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
9e6de77
First set of release pipeline steps
philipwindecker Oct 21, 2022
d797b4f
fix step w/ sed
philipwindecker Oct 21, 2022
be946b3
Update release.yml
philipwindecker Oct 21, 2022
8de8646
Update release.yml
philipwindecker Oct 21, 2022
19bb885
Update release.yml
philipwindecker Oct 21, 2022
1ab5cc8
Update release.yml
philipwindecker Oct 21, 2022
78c7781
Update release.yml
philipwindecker Oct 21, 2022
a2be812
Update release.yml
philipwindecker Oct 21, 2022
82be0ee
Update release.yml
philipwindecker Oct 21, 2022
6204694
Update release.yml
philipwindecker Oct 21, 2022
bc805ea
Update release.yml
philipwindecker Oct 21, 2022
ab78f04
Update release.yml
philipwindecker Oct 21, 2022
70e2a80
Update release.yml
philipwindecker Oct 21, 2022
822acf7
Update release.yml
philipwindecker Oct 21, 2022
ec0813e
Update release.yml
philipwindecker Oct 21, 2022
4f16d57
Update release.yml
philipwindecker Oct 21, 2022
bdfc588
Update release.yml
philipwindecker Oct 21, 2022
e94a4b4
Update release.yml
philipwindecker Oct 21, 2022
233dd56
Update release.yml
philipwindecker Oct 21, 2022
c088af7
Update release.yml
philipwindecker Oct 21, 2022
1f8cbc3
Update release.yml
philipwindecker Oct 21, 2022
38c0fe7
Update release.yml
philipwindecker Oct 24, 2022
2f67d7b
Update release.yml
philipwindecker Oct 24, 2022
6fb7176
Update release.yml
philipwindecker Oct 24, 2022
bf5c78b
Update release.yml
philipwindecker Oct 24, 2022
1c68d1b
Update release.yml
philipwindecker Oct 24, 2022
11f9c54
Update release.yml
philipwindecker Oct 24, 2022
1efda9b
Update release.yml
philipwindecker Oct 24, 2022
6219146
Update release.yml
philipwindecker Oct 24, 2022
8529d40
Update release.yml
philipwindecker Oct 24, 2022
cadd87e
Update release.yml
philipwindecker Oct 24, 2022
ac2372b
Update release.yml
philipwindecker Oct 24, 2022
e509e15
Update release.yml
philipwindecker Oct 25, 2022
cce4964
Update release.yml
philipwindecker Oct 25, 2022
9afc3c0
Update release.yml
philipwindecker Jan 9, 2023
7d79e66
Update release.yml
philipwindecker Jan 9, 2023
877cd01
Update release.yml
philipwindecker Jan 9, 2023
934c33c
Update release.yml
philipwindecker Jan 9, 2023
a222c47
Update release.yml
philipwindecker Jan 10, 2023
0ece28a
Update release.yml
philipwindecker Jan 10, 2023
4c18492
Update release.yml
philipwindecker Jan 13, 2023
477d94e
Update release.yml
philipwindecker Jan 13, 2023
0998897
Update release.yml
philipwindecker Jan 13, 2023
bac426b
Update release.yml
philipwindecker Jan 13, 2023
f354c41
Update release.yml
philipwindecker Jan 13, 2023
b5ad78b
Update release.yml
philipwindecker Jan 13, 2023
481d85c
Update release.yml
philipwindecker Jan 13, 2023
d1120e8
Update release.yml
philipwindecker Jan 13, 2023
7331534
Update release.yml
philipwindecker Jan 13, 2023
940ac3f
Update release.yml
philipwindecker Jan 13, 2023
a5597e2
Update release.yml
philipwindecker Jan 16, 2023
5015db9
Update release.yml
philipwindecker Jan 16, 2023
d70ded9
Update release.yml
philipwindecker Jan 16, 2023
a6ad70e
Update release.yml
philipwindecker Mar 2, 2023
1e9ef79
Reverted to original namespace
philipwindecker Mar 27, 2023
5fdb39f
Merge branch 'OpenSimulationInterface:master' into rebased_master
philipwindecker Mar 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 188 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
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@v3
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@v3
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@v3
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@v3
with:
path: dist/open-simulation-interface
# Check out the sensor model packaging repo
- name: Checkout sensor model packaging
uses: actions/checkout@v3
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@v3
with:
name: antora
path: dist/ASAM_OSI_Standard_${{needs.setup.outputs.output1}}/
# # Move downloaded Antora artifact to the correct location
# - name: Move and rename Antora artifact (ASAM_OSI_Standard)
# run: |
# ls
# mv antora/site/ 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
# Package all collected deliverables
- name: Zip Release
uses: TheDoctor0/zip-release@0.6.2
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@v3
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@v3
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 }}