Skip to content

Commit

Permalink
fix: use --build-for on later snapcraft versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsgruk committed May 1, 2024
1 parent 99c88b6 commit 27d3f41
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions release-to-candidate/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,28 @@ runs:
chmod +x /usr/bin/semver
- name: Setup snapcraft
id: setup
shell: bash
run: |
sudo snap install snapcraft --channel "${{inputs.snapcraft-channel}}" --classic
installed_version="$(snapcraft version | cut -d" " -f2)"
# Setup Launchpad credentials.
# For versions of snapcraft after 8.2.0, the path is different for the launchpad
# credentials.
if [[ "$(semver compare "8.2.0" "$installed_version")" == "1" ]]; then
# If the installed version is *lower* than 8.2.0
echo "new-remote-build=false" >> "$GITHUB_OUTPUT"
else
echo "new-remote-build=true" >> "$GITHUB_OUTPUT"
fi
git config --global user.email "[email protected]"
git config --global user.name "Github Actions"
- name: Setup Launchpad credentials
shell: bash
run: |
# For versions of snapcraft after 8.2.0, the path is different
# shellcheck disable=SC2193
if [[ "${{ steps.setup.outputs.new-remote-build }}" == "false" ]]; then
mkdir -p ~/.local/share/snapcraft/provider/launchpad
echo "${{ inputs.launchpad-token }}" > ~/.local/share/snapcraft/provider/launchpad/credentials
else
Expand All @@ -94,17 +105,26 @@ runs:
version: ${{ steps.snapcraft-yaml.outputs.version }}
project_root: ${{ steps.snapcraft-yaml.outputs.project-root }}
run: |
# 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"
snapcraft_args=("--launchpad-accept-public-upload")
# shellcheck disable=SC2193
if [[ "${{ steps.setup.outputs.new-remote-build }}" == "false" ]]; 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"
else
snapcraft_args+=("--build-for $arch")
fi
pushd "$project_root" && git init || exit
if ! snapcraft remote-build --launchpad-accept-public-upload; then
# shellcheck disable=SC2068
if ! snapcraft remote-build ${snapcraft_args[@]}; then
cat "${name}_${arch}.txt"
fi
cat "${name}_${arch}.txt"
# shellcheck disable=SC2086
cat ${name}_${arch}*.txt
if [[ ! -e "${name}_${version}_${arch}.snap" ]]; then
echo "Could not find ${name}_${version}_${arch}.snap"
Expand Down

0 comments on commit 27d3f41

Please sign in to comment.