Skip to content

Commit

Permalink
feat: support building + releasing core24 snaps (#38)
Browse files Browse the repository at this point in the history
* feat: Add support for `platforms` key

core24 uses the `platforms` key for specifying the architecture of the snap
rather than `architectures`. This commit adds a conditional that properly
handles the `platforms` key when determining which arches to build for.

Signed-off-by: Jason C. Nucciarone <[email protected]>

* feat: Add support for `--platform` flag

`core24` supports using the platform flag with the Launchpad
remote-builders. This commit adds a conditional that checks if the
base is core24. If the base is core24, it uses the `--platfrom` flag
rather than the build-for flag.

Signed-off-by: Jason C. Nucciarone <[email protected]>

---------

Signed-off-by: Jason C. Nucciarone <[email protected]>
  • Loading branch information
NucciTheBoss authored May 23, 2024
1 parent cf75669 commit c31bf20
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
22 changes: 14 additions & 8 deletions get-architectures/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,22 @@ runs:
env:
yaml_path: ${{ steps.snapcraft-yaml.outputs.yaml-path }}
run: |
# Get the list as a json array. E.g. ["amd64", "arm64"]
architectures_list="$(yq -r -I=0 -o=json '[.architectures[]]' "$yaml_path")"
# Get the list as a space-separated string. E.g. "amd64" "arm64"
architectures="$(yq -r -I=0 -o=csv '[.architectures[]]' "$yaml_path" | tr ',' ' ')"
# Handle the case where architectures is a list of objects
if echo "$architectures" | grep -q "build-on"; then
# core24 uses a different syntax for specifying platforms.
if [[ "$(yq -r '.base' "$yaml_path")" == "core24" ]]; then
architectures_list="$(yq -r -I=0 -o=json '[.platforms | to_entries | .[] | .key]' "$yaml_path")"
architectures="$(yq -r -I=0 -o=csv '[.platforms | to_entries | .[] | .key]' "$yaml_path" | tr ',' ' ')"
else
# Get the list as a json array. E.g. ["amd64", "arm64"]
architectures_list="$(yq -r -I=0 -o=json '[.architectures[]]' "$yaml_path")"
# Get the list as a space-separated string. E.g. "amd64" "arm64"
architectures="$(yq -r -I=0 -o=csv '[.architectures[]]' "$yaml_path" | tr ',' ' ')"
# Handle the case where architectures is a list of objects
if echo "$architectures" | grep -q "build-on"; then
architectures_list="$(yq -r -I=0 -o=json '[.architectures[]."build-on"]' "$yaml_path")"
architectures="$(yq -r -I=0 -o=csv '[.architectures[]."build-on"]' "$yaml_path" | tr ',' ' ')"
fi
fi
echo "architectures_list=$architectures_list" >> "$GITHUB_OUTPUT"
Expand Down
6 changes: 5 additions & 1 deletion release-to-candidate/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ runs:
snapcraft_args=("--launchpad-accept-public-upload")
# shellcheck disable=SC2193
if [[ "${{ steps.setup.outputs.new-remote-build }}" == "false" || "$SNAPCRAFT_REMOTE_BUILD_STRATEGY" == "force-fallback" ]]; then
if [[ "$(yq -r '.base' "$yaml_path")" == "core24" ]]; then
# `core24` uses platforms syntax rather than `architectures`:
# https://snapcraft.io/docs/architectures
snapcraft_args+=("--platform $arch")
elif [[ "${{ steps.setup.outputs.new-remote-build }}" == "false" || "$SNAPCRAFT_REMOTE_BUILD_STRATEGY" == "force-fallback" ]]; then
# Restrict arch definition to one only in snapcraft.yaml due to:
# https://bugs.launchpad.net/snapcraft/+bug/1885150
yq -i '.architectures |= [{"build-on": env(arch)}]' "$yaml_path"
Expand Down

0 comments on commit c31bf20

Please sign in to comment.