Skip to content

Merge branch 'master' of github.com:CLSFramework/soccer-simulation-proxy #10

Merge branch 'master' of github.com:CLSFramework/soccer-simulation-proxy

Merge branch 'master' of github.com:CLSFramework/soccer-simulation-proxy #10

Workflow file for this run

name: Generate Protobuf Documentation
# Define a manual trigger with input for version
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository code
- name: Checkout code
uses: actions/checkout@v3
# Step 1.1: Check Version Number
- name: Check Version Number
run: |
PROTO_VERSION=$(grep -oP '(?<=version\s)[0-9]+\.[0-9]+' ./idl/grpc/service.proto)
THRIFT_VERSION=$(grep -oP '(?<=version\s)[0-9]+\.[0-9]+' ./idl/thrift/soccer-service.thrift)
if [ "$PROTO_VERSION" != "$THRIFT_VERSION" ]; then
echo "Version mismatch: Protobuf version is $PROTO_VERSION, Thrift version is $THRIFT_VERSION"
exit 1
fi
# Step 2: Install dependencies for protoc
- name: Install protoc dependencies
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler wget
# Step 3: Download precompiled protoc-gen-doc binary
- name: Download protoc-gen-doc binary
run: |
# Download the appropriate precompiled binary for Linux
wget https://github.com/pseudomuto/protoc-gen-doc/releases/download/v1.5.1/protoc-gen-doc_1.5.1_linux_amd64.tar.gz -O protoc-gen-doc.tar.gz
# Extract the binary from the tarball
tar -xvf protoc-gen-doc.tar.gz
# Ensure it's an executable binary
file protoc-gen-doc
# Make it executable
chmod +x protoc-gen-doc
# Move the binary to /usr/local/bin
sudo mv protoc-gen-doc /usr/local/bin/
# Step 4: Generate Markdown from the Protobuf file
- name: Generate Protobuf Documentation
run: |
# Generate markdown from .proto file
protoc --doc_out=./idl --doc_opt=markdown,readme.md ./idl/grpc/service.proto
# Step 5: Extract version from the first line of the .proto file
- name: Extract version from .proto file
id: extract_version
run: |
VERSION=$(grep -oP '(?<=version\s)[0-9]+\.[0-9]+' ./idl/grpc/service.proto)
echo "VERSION=$VERSION" >> $GITHUB_ENV
# Step 6: Insert version into the generated Markdown file
- name: Insert version into markdown
run: |
sed -i '3a\\n## Version: '"${{ env.VERSION }}"'\n' ./idl/readme.md
# Step 7: Replace &gt; and &lt; in Mermaid diagrams with > and <
- name: Fix Mermaid symbols in readme.md
run: |
sed -i 's/&gt;/>/g' ./idl/readme.md
sed -i 's/&lt;/</g' ./idl/readme.md
# Step 8: Configure Git and commit the updated readme.md
- name: Configure Git
run: |
git config --global user.name "GitHub Action"
git config --global user.email "[email protected]"
# Step 9: Commit and push the changes
- name: Commit and Push Changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git add ./idl/readme.md
git commit -m "Update protobuf documentation with version and fixed Mermaid symbols"
git push