Skip to content

Commit

Permalink
building for arm64 and amd64
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikN committed Jul 25, 2024
1 parent 3236e41 commit 715ef92
Show file tree
Hide file tree
Showing 5 changed files with 572 additions and 61 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Build snap
on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
include:
- ros_distro: humble
# - ros_distro: jazzy

# outputs:
# snap-file: ${{ steps.build-snap.outputs.snap }}

steps:

- name: Checkout
uses: actions/checkout@v4
with:
fetch-tags: true

- name: Render snapcraft.yaml
run: |
pip install jinja2
export ROS_DISTRO=${{ matrix.ros_distro }}
./render_template.py ./snapcraft_template.yaml.jinja2 snap/snapcraft.yaml
- name: Build snap
uses: snapcore/action-build@v1
with:
snapcraft-channel: latest/edge
id: build-snap
env:
SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS: 1

- name: Make sure the snap is installable
run: |
sudo snap install --dangerous ${{ steps.build-snap.outputs.snap }}
# # Save snap for subsequent job(s)
# - uses: actions/upload-artifact@v3
# with:
# name: husarion-camera-snap
# path: ${{ steps.build-snap.outputs.snap }}

# publish:
# if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
# needs: build
# runs-on: ubuntu-latest

# steps:

# # Retrieve the snap
# - uses: actions/download-artifact@v3
# with:
# name: husarion-camera-snap
# path: .

# # Publish the snap on the store
# # by default on 'edge' but on 'candidate' for tags
# - uses: snapcore/action-publish@v1
# env:
# SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }}
# with:
# snap: ${{needs.build.outputs.snap-file}}
# release: ${{ startsWith(github.ref, 'refs/tags/') && '${{ matrix.ros_distro }}/candidate' || '${{ matrix.ros_distro }}/edge'}}
61 changes: 61 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Build and publish snap
on:
push:
tags:
- '*'
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ${{ matrix.runner }}

strategy:
fail-fast: false
matrix:
include:
- ros_distro: humble
runner: ubuntu-latest
# - ros_distro: jazzy
# runner: ubuntu-latest
- ros_distro: humble
runner: ubuntu-24.04-arm64
# - ros_distro: jazzy
# runner: ubuntu-24.04-arm64

steps:

- name: Checkout
uses: actions/checkout@v4
with:
fetch-tags: true

- name: Render snapcraft.yaml
run: |
sudo apt update
sudo apt install python3-jinja2
export ROS_DISTRO=${{ matrix.ros_distro }}
./render_template.py ./snapcraft_template.yaml.jinja2 snap/snapcraft.yaml
- name: Build snap
uses: snapcore/action-build@v1
with:
snapcraft-channel: latest/edge
id: build-snap
env:
SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS: 1

- name: Make sure the snap is installable
run: |
sudo snap install --dangerous ${{ steps.build-snap.outputs.snap }}
# Publish the snap on the store
# by default on 'edge' but on 'candidate' for tags
- name: Publish snap
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }}
with:
snap: ${{ steps.build-snap.outputs.snap }}
release: ${{ matrix.ros_distro }}/${{ startsWith(github.ref, 'refs/tags/') && 'candidate' || 'edge' }}
61 changes: 0 additions & 61 deletions .github/workflows/snap.yaml

This file was deleted.

22 changes: 22 additions & 0 deletions render_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python3

import sys
import os
from jinja2 import Environment, FileSystemLoader

def render_template(template_path, output_path, context):
env = Environment(loader=FileSystemLoader(os.path.dirname(template_path)))
template = env.get_template(os.path.basename(template_path))

with open(output_path, 'w') as f:
f.write(template.render(context))

if __name__ == "__main__":
template_path = sys.argv[1]
output_path = sys.argv[2]
context = {
'ros_distro': os.getenv('ROS_DISTRO'),
# 'core_version': os.getenv('CORE_VERSION')
}

render_template(template_path, output_path, context)
Loading

0 comments on commit 715ef92

Please sign in to comment.