Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for building + releasing core24 based snaps #38

Merged
merged 2 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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