Giter Site home page Giter Site logo

snapcraft-multiarch-action's Introduction

snapcraft-multiarch-build-action status

Snapcraft Multiarch Build Action

This is a Github Action that can be used to build a Snapcraft project. For most projects, the following workflow should be sufficient:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - uses: diddlesnaps/snapcraft-multiarch-action@v1

This will run snapcraft using the snapcraft-container

On success, the action will set the snap output parameter to the path of the built snap. This can be used to save it as an artifact of the workflow:

...
    - uses: diddlesnaps/snapcraft-multiarch-action@v1
      id: snapcraft
    - uses: actions/upload-artifact@v2
      with:
        name: snap
        path: ${{ steps.snapcraft.outputs.snap }}

Alternatively, it could be used to perform further testing on the built snap:

    - run: |
        sudo snap install --dangerous ${{ steps.snapcraft.outputs.snap }}
        # do something with the snap

The action can also be chained with snapcore/action-publish@v1 to automatically publish builds to the Snap Store.

Multiple architectures support

This action supports building for multiple architectures using the GitHub Actions matrix feature.

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        platform:
        - i386
        - amd64
        - armhf
        - arm64
        - ppc64el
        - s390x
    steps:
    - uses: actions/checkout@v3
    - uses: docker/setup-qemu-action@v1
    - uses: diddlesnaps/snapcraft-multiarch-action@v1
      with:
        architecture: ${{ matrix.platform }}

notes

  • s390x is broken at the moment.
  • Builds for core20, and later, do not support i386 architecture because Ubuntu has dropped support for i386 in Ubuntu 20.04 and later.
  • core builds do not support s390x architecture because Ubuntu does not have support for s390x before Ubuntu 18.04.

Action inputs

path

If your Snapcraft project is not located in the root of the workspace, you can specify an alternative location via the path input parameter:

...
    - uses: diddlesnaps/snapcraft-multiarch-action@v1
      with:
        path: path-to-snapcraft-project

use-podman

By default, this action will use Docker. If you are running a self-hosted GitHub Actions Runner then you might prefer to use Podman instead. This switch allows you to request experimental support for Podman to be used.

Note that when using Podman your build cannot target a CPU architecture that is different to the host your runner is based upon. This is a limitation of Podman. For example, you will need an ARM64 host to build an ARM64 Snap Package, when using Podman builds. Multiarch builds, where you build an i386 Snap on an AMD64 host or an ARMHF Snap on an ARM64 host, might be possible but are untested - your mileage might vary.

Set use-podman to true to use Podman instead of Docker.

build-info

By default, the action will tell Snapcraft to include information about the build in the resulting snap, in the form of the snap/snapcraft.yaml and snap/manifest.yaml files. Among other things, these are used by the Snap Store's automatic security vulnerability scanner to check whether your snap includes files from vulnerable versions of Ubuntu packages.

This can be turned off by setting the build-info parameter to false.

snapcraft-channel

By default, the action will install Snapcraft from the stable channel. If your project relies on a feature not found in the stable version of Snapcraft, then the snapcraft-channel parameter can be used to select a different channel.

snapcraft-args

The snapcraft-args parameter can be used to pass additional arguments to Snapcraft. This is primarily intended to allow the use of experimental features by passing --enable-experimental-* arguments to Snapcraft.

architecture

By default, the action will build for AMD64. You may use this parameter to indicate an alternative architecture from any of those supported by the snapcraft utility. At the time of writing the supported architectures are amd64, i386, arm64, armhf, ppc64el and s390x. This is most-useful when used with GitHub Actions' matrix feature.

### environment

Add environment variables to the Snapcraft build context. Each variable needs to be specified on a separate line. For example:

with:
  environment: |
    FOO=bar
    BAZ=qux

store-auth

Set the SNAPCRAFT_STORE_CREDENTIALS environment variable. This is useful when using the snapcraft push command.

You should not save the token into the yaml file directly, but use the GitHub Actions secrets feature:

with:
  store-auth: ${{ secrets.STORE_AUTH }}

snapcraft-multiarch-action's People

Contributors

edlerd avatar lucyllewy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

snapcraft-multiarch-action's Issues

[Bug]: aa_is_enabled() failed unexpectedly

What happened?

Hello,

We are using your GH action for publishing VSCodium but, today, we are experiencing an error that we didn't have before...

Here the action' setup:

uses: diddlesnaps/snapcraft-multiarch-action@v1
with:
  path: stores/snapcraft
  architecture: ${{ matrix.platform }}
id: build

Here the error:

Executing: 'snap run snapcraft '
aa_is_enabled() failed unexpectedly (No such file or directory): No such file or directory
Error: No snap files produced by build

What should have happened?

The logs should look like:

Executing: 'snap run snapcraft '

0% [Working]
            
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]

Output of snap info $snap_name

name:      codium
summary:   Free/Libre Open Source Software Binaries of VSCode
publisher: VSCodium
store-url: https://snapcraft.io/codium
contact:   https://github.com/VSCodium/vscodium/issues
license:   MIT
description: |
  Binary releases of Code without branding/telemetry/licensing.
snap-id: lIZWXTqmo6LFSts5Cgk2VPlNwtysZAeH
channels:
  latest/stable:    1.64.2 2022-02-11 (247) 173MB classic
  latest/candidate: ^                             
  latest/beta:      ^                             
  latest/edge:      ^                             

Output of snap connections $snap_name

error: snap "codium" not found

Output of snap version

snap    2.54.3+20.04.1ubuntu0.2
snapd   2.54.3+20.04.1ubuntu0.2
series  16
ubuntu  20.04
kernel  5.11.0-1028-azure

Relevant log output

No response

Teminal output of app

No response

[Bug]: Environment variable inside the docker container.

What happened?

I want able to insert list of environment variable inside the docker container for build the snapcraft.

What should have happened?

I should have an option to have a environment variable inside the docker container.

Output of snap info $snap_name

Not relevant for this bug.

Output of snap connections $snap_name

not relevant for this bug.

Output of snap version

not relevant for this bug.

Relevant log output

No response

Teminal output of app

No response

[Bug]: `:: fatal: detected dubious ownership in repository at '/data'`

What happened?

Using git inside override-*: scriptlets tends to result in:

:: fatal: detected dubious ownership in repository at '/data'

E.g. https://github.com/MirServer/confined-shell-wip/actions/runs/4425288703/jobs/7760152845

What should have happened?

The project needs to be fed into the container in a way that git is happy with it.

Output of snap info $snap_name

N/A

Output of snap connections $snap_name

N/A

Output of snap version

N/A

Relevant log output

:: ++ git -C /data rev-list --count HEAD
:: fatal: detected dubious ownership in repository at '/data'
:: To add an exception for this directory, call:
::
:: 	git config --global --add safe.directory /data


### Teminal output of app

_No response_

arm64 Builds failing - cannot pack “/data/prime”: mksquashfs call failed: signal: segmentation fault (core dumped) Edit

Builds of arm64 have been failing with the error below. Builds of amd64 and armhf seem unaffected with the same snapcraft.yaml file. This effects 2 projects that I work with.

The snapcraft build files can be found here:
https://github.com/sct/overseerr/blob/develop/snap/snapcraft.yaml
https://github.com/Tautulli/Tautulli/blob/master/snap/snapcraft.yaml

Sorry, an error occurred in Snapcraft:
Failed to create snap, snap command failed:
stdout:

stderr:
error: cannot pack "/data/prime": mksquashfs call failed: signal: segmentation fault (core dumped)

We would appreciate it if you anonymously reported this issue.
No other data than the traceback and the version of snapcraft in use will be sent.
Would you like to send this error data? (Yes/No/Always/View) [no]:

Could it be something with the build process?

Flutter build broken. error: unknown command "channel"

I previously used snapcore/action-build to build and it builds Flutter projects successfully. I migrated to snapcraft-multiarch-action as I need arm64 builds, but Flutter build seems to be broken:

...
 Run health check of "gtk-common-themes" snap                                   -
25hgtk-common-themes 0.1-52-gb92ac40 from Canonical✓ installed
Pulling flutter-extension 
+ flutter channel stable
error: unknown command "channel", see 'snap help'.
Failed to run 'override-pull': Exit code was 64.
Error: No snap files produced by build

Here is the full log: https://github.com/proninyaroslav/libretrack/runs/3414045204?check_suite_focus=true
Workflow file: https://github.com/proninyaroslav/libretrack/blob/master/.github/workflows/flutter_release_build.yml#L92
Snapcraft metadata: https://github.com/proninyaroslav/libretrack/blob/master/snap/snapcraft.yaml

[Bug]: Build broken since recent update (tmp vs extended attributes)

What happened?

The recent update broke the build with this message.

Sorry, an error occurred in Snapcraft:
Unable to write extended attribute.

Recommended resolution:
Check that your filesystem supports extended attributes.

Detailed information:
Failed to write attribute 'user.snapcraft.origin_stage_package' on '/tmp/tmpddrm5kk5deb-extract/usr/share/man/man1/haproxy.1.gz'.

I am using the state-package feature of snapcraft.yaml as:

parts:
  python:
    plugin: python
    source: .
    stage-packages:
      - haproxy

It appears that snapcraft tries to write an extended attribute to a file in /tmp, which is not supported in the most recent diddledani/snapcraft:core20 image.

What should have happened?

The build should have passed as before and extended attributes on /tmp should be supported in the docker image at diddledani/snapcraft:core20.

Output of snap info $snap_name

not relevant for build step

Output of snap connections $snap_name

not relevant for build step

Output of snap version

not relevant for build step

Relevant log output

No response

Teminal output of app

No response

[Enhancement]: better support for `snapcraft push`

What changes would you like?

The only way I've found to push from this action is to run it again, with basename ${{ ...outputs.snap }}.

It would be nice if the action provided better facilities for that - maybe even publish on its own if publish-channel is provided?

Any extra information?

https://github.com/canonical/actions/blob/1d782d2578d57f083ca18a79cc165a313e67674d/build-snap/action.yml#L83-L97

You could also look at the review-tools bits I have in there ☝️, which would remain the last thing I did there above what your action does.

[Bug]: bad handling of quotes in `snapcraft-args`

What happened?

As I was moving from bash to this action, I had quotes around one of the arguments. Snapcraft failed to run, then, because the quotes were escaped:

Run diddlesnaps/snapcraft-multiarch-action@v1
  with:
    store-auth: ***
    snapcraft-channel: stable
    architecture: amd64
    snapcraft-args: push glvnd-core22_0.01_amd64.snap --release 'edge/pr1'
    path: .
    use-podman: false
    build-info: true
# ...
Executing: 'snap run snapcraft push glvnd-core22_0.01_amd64.snap --release \'edge/pr1\' '
Uploading... (--->)
Uploading... (<---)
craft-store error: Store operation failed:
- invalid-field: No valid risk provided: 'edge, pr1'

https://github.com/MirServer/glvnd-core22/actions/runs/4341495156/jobs/7581165120#step:3:1586

What should have happened?

Need a way to quote arguments in snapcraft-args. It may be best if it's actually a list, rather than a string.

Output of snap info $snap_name

N/A

Output of snap connections $snap_name

N/A

Output of snap version

N/A

Relevant log output

No response

Teminal output of app

No response

Empty snapcraft-args leads to Error: No such command ''

Also posted in the forum: https://forum.snapcraft.io/t/snapcraft-github-action/20896/7?u=ppd

I'm experiencing this with v1 in my experiments, e.g. here https://github.com/ppd/solvespace/runs/1433047794?check_suite_focus=true.

If snapcraft-args is empty, entrypoint.sh will call snapcraft like Executing: 'snap run snapcraft '' ', which results in Error: No such command ''.

Maybe this issue rather belongs to https://github.com/diddlesnaps/snapcraft-container, but I'll leave that decision to you ;)

[Enhancement]: Update Action to Node.js v20 to remove GitHub deprecation warning

What changes would you like?

As far as I understand, this GitHub Action still uses Node.js v16, which is deprecated according to GitHub's blog: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/

I suggest updating this GitHub Action to Node.js v20 and releasing a new version (e.g., v2.0.0) to fix the warning.

Any extra information?

The warning can be seen, e.g., here: https://github.com/VSCodium/vscodium/actions/runs/8253791641

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.