-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use
--build-for
on later snapcraft versions
- Loading branch information
Showing
1 changed file
with
29 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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" | ||
|