test extended fixes #243
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Generate and Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| generate-dbc: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.9' | |
| - name: Install cantools | |
| run: python -m pip install cantools==40.2.2 | |
| - name: Convert SYM to DBC | |
| run: | | |
| cantools convert ${{ github.workspace }}/PCAN_project/hytech.sym hytech.dbc | |
| - name: Upload dbc artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dbcfile | |
| path: hytech.dbc | |
| generate-proto: | |
| needs: generate-dbc | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.9' | |
| - name: Install cantools | |
| run: python -m pip install cantools==40.2.2 | |
| - name: Download artifact | |
| uses: actions/[email protected] | |
| with: | |
| name: dbcfile | |
| path: ./dbc | |
| - name: Convert DBC to PROTO | |
| run: | | |
| python dbc_to_proto/dbc_to_proto.py dbc/ hytech.proto | |
| - name: Set up Protobuf tools and generate HTML file | |
| run: | | |
| mkdir -p docs | |
| mkdir -p proto/nanopb/google/protobuf | |
| sudo apt-get install -y --no-install-recommends protobuf-compiler | |
| go install github.com/pseudomuto/protoc-gen-doc/cmd/[email protected] | |
| export PATH=$PATH:$HOME/go/bin | |
| curl -o proto/nanopb/google/protobuf/descriptor.proto https://raw.githubusercontent.com/nanopb/nanopb/nanopb-0.4.9.1/generator/proto/google/protobuf/descriptor.proto | |
| curl -o proto/nanopb/nanopb.proto https://raw.githubusercontent.com/nanopb/nanopb/nanopb-0.4.9.1/generator/proto/nanopb.proto | |
| protoc -I=./. -I=proto/nanopb --doc_out=./docs --doc_opt=html,Release-${{github.run_number}}.html hytech.proto | |
| - name: Upload html artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: htmlfile | |
| path: ./docs/Release-${{github.run_number}}.html | |
| - name: Upload proto artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: protofile | |
| path: hytech.proto | |
| generate-and-release: | |
| needs: [generate-dbc, generate-proto] | |
| runs-on: ubuntu-latest | |
| container: | |
| image: ghcr.io/rcmast3r/ccoderdbc:main | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download dbc artifact | |
| uses: actions/[email protected] | |
| with: | |
| name: dbcfile | |
| path: /dbc | |
| - name: Download proto artifact | |
| uses: actions/[email protected] | |
| with: | |
| name: protofile | |
| path: . | |
| - name: generate code | |
| run: | | |
| mkdir -p /hytech_can_lib | |
| cd /app | |
| ./build/coderdbc -rw -dbc /dbc/hytech.dbc -out /hytech_can_lib -drvname hytech | |
| mkdir -p /output | |
| echo "{\n\"name\": \"can_lib\",\n\"version\": \"1.0.0\",\n\"build\": {\n\t\"flags\": [\n\t\t\"-Iinc\",\n\t\t\"-Ilib\",\n\t\t\"-Iconf\"\n\t]\n}\n}" >> /hytech_can_lib/library.json | |
| tar -czvf /output/can_lib.tar.gz /hytech_can_lib | |
| - name: generate drivebrain lib release | |
| run: | | |
| mkdir -p /hytech_drivebrain_lib/proto | |
| mkdir -p /output | |
| cp hytech.proto /hytech_drivebrain_lib/proto | |
| cp CMakeLists.txt /hytech_drivebrain_lib | |
| tar -czvf /output/drivebrain_can_lib.tar.gz /hytech_drivebrain_lib | |
| - name: Create Release | |
| id: create_release | |
| uses: actions/[email protected] | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ github.run_number }} | |
| release_name: Release-${{ github.run_number }} | |
| draft: false | |
| prerelease: false | |
| - name: Create Version Header | |
| run: | | |
| mkdir -p /hytech_can_lib/inc | |
| cat << EOF > /hytech_can_lib/inc/ht_can_version.h | |
| /** | |
| * @file ht_can_version.h | |
| * @brief Auto-generated version header for HyTech CAN Library | |
| * @details Generated by GitHub Actions (CI/CD) - Do not modify manually | |
| */ | |
| #ifndef HT_CAN_VERSION_H | |
| #define HT_CAN_VERSION_H | |
| /** | |
| * @brief Version number of the HyTech CAN Library | |
| * @details This is automatically updated with each GitHub Actions run | |
| */ | |
| #define HT_CAN_LIB_VERSION ${{ github.run_number }} | |
| #endif /* HT_CAN_VERSION_H */ | |
| EOF | |
| # Also update the tar archive to include the new file | |
| tar -czvf /output/can_lib.tar.gz /hytech_can_lib | |
| - name: Upload release asset | |
| uses: actions/[email protected] | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: /output/can_lib.tar.gz | |
| asset_name: can_lib.tar.gz | |
| asset_content_type: application/zip | |
| - name: Upload drivebrain release asset | |
| uses: actions/[email protected] | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: /output/drivebrain_can_lib.tar.gz | |
| asset_name: drivebrain_can_lib.tar.gz | |
| asset_content_type: application/zip | |
| - name: Upload hytech.dbc | |
| uses: actions/[email protected] | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: /dbc/hytech.dbc | |
| asset_name: hytech.dbc | |
| asset_content_type: text/plain | |
| - name: Upload hytech.proto | |
| uses: actions/[email protected] | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: hytech.proto | |
| asset_name: hytech.proto | |
| asset_content_type: text/plain | |
| - name: Download html artifact | |
| uses: actions/[email protected] | |
| with: | |
| name: htmlfile | |
| path: /docs | |
| - name: Upload html | |
| uses: actions/[email protected] | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: /docs/Release-${{ github.run_number }}.html | |
| asset_name: Release-${{ github.run_number }}.html | |
| asset_content_type: text/plain |