Skip to content

Merge pull request #35 from ubuntu-robotics/feat/rob-cos-model-name #42

Merge pull request #35 from ubuntu-robotics/feat/rob-cos-model-name

Merge pull request #35 from ubuntu-robotics/feat/rob-cos-model-name #42

# The workflow canonical/observability/.github/workflows/rock-release-dev.yaml@main
# https://github.com/canonical/observability/blob/34b7edb56094e8e3f01200ce49e01bf9dd6688ac/.github/workflows/rock-release-dev.yaml
# does not allow setting a GHCR repo where to publish at the moment.
# We thus copy it below and adapt it.
name: Build ROCK and release dev or branch tag to GHCR
on:
workflow_dispatch:
push:
branches:
- main
jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Find the *latest* rockcraft.yaml
id: find-latest
run: |
latest_rockcraft_file=$(find $GITHUB_WORKSPACE -name "rockcraft.yaml" | sort -V | tail -n1)
rockcraft_dir=$(dirname ${latest_rockcraft_file#\./})
echo "latest-dir=$rockcraft_dir" >> $GITHUB_OUTPUT
- name: Build ROCK
uses: canonical/craft-actions/rockcraft-pack@main
with:
path: "${{ steps.find-latest.outputs.latest-dir }}"
verbosity: verbose
id: rockcraft
- name: Upload locally built ROCK artifact
uses: actions/upload-artifact@v4
with:
name: cos-registration-agent-rock
path: ${{ steps.rockcraft.outputs.rock }}
retention-days: 7
- name: Upload ROCK to ghcr.io
run: |
if [[ ${{ github.ref }} == 'refs/heads/main' ]]
then
TAG=dev
else
TAG=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
TAG=$(echo $TAG | sed "s|\/|\_|")
fi
sudo skopeo --insecure-policy copy oci-archive:$(realpath ${{ steps.rockcraft.outputs.rock }}) docker://ghcr.io/ubuntu-robotics/cos-registration-server:$TAG --dest-creds "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}"
- name: Generate digest
run: |
digest=$(skopeo inspect oci-archive:$(realpath ${{ steps.rockcraft.outputs.rock }}) --format '{{.Digest}}')
echo "digest=${digest#*:}" >> "$GITHUB_OUTPUT"
- name: Install Syft
run: |
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
- name: Create SBOM
run: syft $(realpath ${{ steps.rockcraft.outputs.rock }}) -o spdx-json=cos-registration-server.sbom.json
- name: Upload SBOM
uses: actions/upload-artifact@v4
with:
name: cos-registration-server-sbom
path: "cos-registration-server.sbom.json"