GitHub Actions构建core24 Snap预编译Chromium浏览器(动态源)失败
问题描述
尝试使用core24将预编译Chromium系浏览器Helium打包为Snap包,通过GitHub Actions动态获取最新发布标签并注入下载URL到snapcraft.yaml后执行构建。因使用预编译二进制文件(.tar.xz),采用dump插件。
snapcraft.yaml配置
name: helium-browser base: core24 version: '0.0.1' summary: Private, fast, and honest web browser based on Chromium description: | Helium is a bullshit-free web browser based on Chromium. It is designed to be fast, private, and honest. grade: stable confinement: strict license: GPL-3.0-only AND BSD-3-Clause title: Helium Browser website: https://helium.computer source-code: https://github.com/imputnet/helium-linux issues: https://github.com/imputnet/helium-linux/issues contact: https://x.com/heliumbrowser donation: https://helium.computer/sponsor platforms: amd64: arm64: apps: helium: command: usr/bin/helium extensions: [gnome] desktop: usr/share/applications/helium.desktop common-id: helium.desktop plugs: - network - network-bind - audio-playback - audio-record - camera - opengl - x11 - wayland - browser-support - removable-media - home - desktop - desktop-legacy - unity7 - screen-inhibit-control - cups-control - joystick - password-manager-service - u2f-devices - raw-usb - upower-observe parts: helium: plugin: dump source: https://github.com/imputnet/helium-linux/releases/latest source-type: tar build-packages: - wget override-build: | craftctl default mkdir -p $SNAPCRAFT_PART_INSTALL/usr/bin mkdir -p $SNAPCRAFT_PART_INSTALL/usr/share/applications mkdir -p $SNAPCRAFT_PART_INSTALL/usr/share/pixmaps wget https://raw.githubusercontent.com/imputnet/helium/main/resources/branding/app_icon/raw.png -O $SNAPCRAFT_PART_INSTALL/usr/share/pixmaps/helium.png find $SNAPCRAFT_PART_INSTALL -name "helium.desktop" -exec mv {} $SNAPCRAFT_PART_INSTALL/usr/share/applications/ \; DESKTOP="$SNAPCRAFT_PART_INSTALL/usr/share/applications/helium.desktop" sed -i 's|^Icon=.*|Icon=helium|g' "$DESKTOP" sed -i 's|^Exec=.*|Exec=helium %U|g' "$DESKTOP" cat <<EOF > $SNAPCRAFT_PART_INSTALL/usr/bin/helium #!/bin/sh exec "\$SNAP/chrome" --no-sandbox --disable-dev-shm-usage "\$@" EOF chmod +x $SNAPCRAFT_PART_INSTALL/usr/bin/helium chmod +x $SNAPCRAFT_PART_INSTALL/chrome stage-packages: - libnss3 - libnspr4 - libasound2t64 - libcups2t64 - libpci3 - libu2f-udev - libva2 - libva-drm2 - libva-x11-2 - mesa-va-drivers - libvulkan1 - mesa-vulkan-drivers - fonts-liberation - fonts-noto - fonts-noto-color-emoji - fontconfig - libfontconfig1
GitHub Workflow(main.yml)
name: Multi-Arch Build on: schedule: - cron: '0 3 * * *' workflow_dispatch: jobs: build-publish: name: Build for ${{ matrix.snap_arch }} runs-on: ubuntu-latest strategy: matrix: include: - snap_arch: amd64 file_arch: x86_64 - snap_arch: arm64 file_arch: arm64 steps: - uses: actions/checkout@v4 - name: Check Latest Version id: check run: | LATEST_TAG=$(curl -s https://api.github.com/repos/imputnet/helium-linux/releases/latest | jq -r .tag_name) VERSION=${LATEST_TAG#v} echo "Latest version: $VERSION" echo "version=$VERSION" >> $GITHUB_OUTPUT - name: Configure snapcraft.yaml run: | VER="${{ steps.check.outputs.version }}" ARCH="${{ matrix.snap_arch }}" FILE="${{ matrix.file_arch }}" sed -i "s/version: .*/version: '$VER'/" snap/snapcraft.yaml sed -i "/confinement: strict/a platforms:\n $ARCH:\n build-on: [amd64]\n build-for: [$ARCH]" snap/snapcraft.yaml LINK="https://github.com/imputnet/helium-linux/releases/download/$VER/helium-$VER-${FILE}_linux.tar.xz" sed -i "s|source: .*|source: $LINK|" snap/snapcraft.yaml cat snap/snapcraft.yaml - name: Build Snap uses: snapcore/action-build@v1 id: build with: snapcraft-args: pack - name: Publish to Snap Store uses: snapcore/action-publish@v1 env: SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }} with: snap: ${{ steps.build.outputs.snap }} release: stable
报错信息
2026-01-08T03:59:06.8640353Z [command]/usr/bin/sudo -u runner -E snapcraft pack 2026-01-08T03:59:08.7114739Z error parsing 'snapcraft.yaml': found duplicate key 'platforms' 2026-01-08T03:59:08.7116755Z Detailed information: 2026-01-08T03:59:08.7117199Z while constructing a mapping 2026-01-08T03:59:08.7117669Z found duplicate key 'platforms' 2026-01-08T03:59:08.7118144Z in "snap/snapcraft.yaml", line 1, column 1 2026-01-08T03:59:08.7150421Z Recommended resolution: Ensure snapcraft.yaml contains valid YAML 2026-01-08T03:59:08.7164368Z Full execution log: '/home/runner/.local/state/snapcraft/log/snapcraft-20260108-035908.689863.log' 2026-01-08T03:59:08.8711145Z ##[error]The process '/usr/bin/sudo' failed with exit code 1 2026-01-08T03:59:08.8861934Z Post job cleanup. 2026-01-08T03:59:08.9802280Z [command]/usr/bin/git version 2026-01-08T03:59:08.9839473Z git version 2.52.0 2026-01-08T03:59:08.9883588Z Temporarily overriding HOME='/home/runner/work/_temp/68100c82-92ec-4c57-beaa-520689c2e1a0' before making global git config changes 2026-01-08T03:59:08.9884961Z Adding repository directory to the temporary git global config as a safe directory 2026-01-08T03:59:08.9890123Z [command]/usr/bin/git config --global --add safe.directory /home/runner/work/helium-browser-snap/helium-browser-snap 2026-01-08T03:59:08.9927039Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand 2026-01-08T03:59:08.9959569Z [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :" 2026-01-08T03:59:09.0189606Z [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader 2026-01-08T03:59:09.0210307Z http.https://github.com/.extraheader 2026-01-08T03:59:09.0223308Z [command]/usr/bin/git config --local --unset-all http.https://github.com/.extraheader 2026-01-08T03:59:09.0253320Z [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :" 2026-01-08T03:59:09.0475057Z [command]/usr/bin/git config --local --name-only --get-regexp ^includeIf\.gitdir: 2026-01-08T03:59:09.0506337Z [command]/usr/bin/git submodule foreach --recursive git config --local --show-origin --name-only --get-regexp remote.origin.url 2026-01-08T03:59:09.0836426Z Cleaning up orphan processes
解决方法
1. 删除snapcraft.yaml中原有platforms字段
原配置里已经定义了platforms块,而Workflow的Configure snapcraft.yaml步骤会在confinement: strict后追加新的platforms字段,导致YAML出现重复键,触发解析错误。直接删除原配置中的以下内容即可:
platforms: amd64: arm64:
2. (可选)优化Workflow的platforms注入逻辑
如果需要保留原配置的灵活性,也可以修改Workflow中的sed命令,先删除原有platforms块再添加新的,避免重复:
sed -i '/^platforms:/,/^[^ ]/{/^platforms:/!{/^[^ ]/!d;};d;}' snap/snapcraft.yaml sed -i "/confinement: strict/a platforms:\n $ARCH:\n build-on: [amd64]\n build-for: [$ARCH]" snap/snapcraft.yaml
内容的提问来源于stack exchange,提问作者obk
相关产品推荐
相关产品推荐

