1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
name: Build snaps
on:
workflow_call:
inputs:
runs-on:
description: 'A json list of tags to indicate which runner to use'
required: true
type: string
toolchain:
description: 'The go toolchain to use {default, FIPS}'
required: true
type: string
variant:
description: 'The type of snapd build {pristine, test}'
required: true
type: string
jobs:
snap-builds:
runs-on: ${{ fromJSON(inputs.runs-on) }}
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set artifact name
id: set_artifact_name
run: |
postfix="${{ inputs.toolchain }}-${{ inputs.variant }}"
if grep -iq "arm" <<<"${{ inputs.runs-on }}"; then
echo "artifact_name=snap-files-arm64-${postfix}" >> $GITHUB_OUTPUT
else
echo "artifact_name=snap-files-amd64-${postfix}" >> $GITHUB_OUTPUT
fi
- name: Set PR label as environment variables
if: ${{ github.event.pull_request.number }}
run: |
labels=$(gh pr view ${{ github.event.pull_request.number }} --repo github.com/canonical/snapd --json labels | jq -r '.labels[].name')
if grep -q '^Skip spread$' <<<$labels; then
echo "SKIP_SPREAD_LABEL=true" >> $GITHUB_ENV
fi
- name: Select Go toolchain
run: |
case "${{ inputs.toolchain }}" in
default)
rm -f fips-build
;;
FIPS)
touch fips-build
;;
*)
echo "unknown toolchain ${{ inputs.toolchain }}"
exit 1
;;
esac
case "${{ inputs.variant }}" in
pristine)
rm -f test-build
;;
test)
touch test-build
;;
esac
- name: Build snapd snap
if: ${{ env.SKIP_SPREAD_LABEL != 'true' }}
uses: snapcore/action-build@v1.3.0
with:
snapcraft-channel: 8.x/stable
snapcraft-args: --verbose
- name: Check built artifact
if: ${{ env.SKIP_SPREAD_LABEL != 'true' }}
run: |
unsquashfs -no-xattrs snapd*.snap snap/manifest.yaml meta/snap.yaml usr/lib/snapd/
if cat squashfs-root/meta/snap.yaml | grep -q "version:.*dirty.*"; then
echo "PR produces dirty snapd snap version"
cat squashfs-root/usr/lib/snapd/dirty-git-tree-info.txt
exit 1
elif cat squashfs-root/usr/lib/snapd/info | grep -q "VERSION=.*dirty.*"; then
echo "PR produces dirty internal snapd info version"
cat squashfs-root/usr/lib/snapd/info
cat squashfs-root/usr/lib/snapd/dirty-git-tree-info.txt
exit 1
fi
if yq '.primed-stage-packages' squashfs-root/snap/manifest.yaml | grep -q '^- libseccomp2=.*'; then
true
else
echo "primed-stage-packages missing in manifest" 1>&2
exit 1
fi
- name: Uploading snapd snap artifact
if: ${{ env.SKIP_SPREAD_LABEL != 'true' }}
uses: actions/upload-artifact@v4
with:
name: ${{ steps.set_artifact_name.outputs.artifact_name }}
path: "*.snap"
|