gimp
gimp copied to clipboard
[Enhancement]: fix/rewrite/rework the build-pr action
What changes would you like?
The build-prs GitHub action fails to build sometimes, when the snap builds fine in Launchpad.
A quick and dirty workaround could be to disable arm64
in the action yaml (the same way armhf
is disabled)
A better solution might be to use snapcraft remote-build
which actually builds in Launchpad which is a way more consistent way to build, given that's how we actually publish builds from.
Any extra information?
No response
I really dislike touching Launchpad, but remote-build
seems like a reasonable UX.
Though the docs aren't clear about how to use remote-build in a headless manner. How do we get a token and supply it to remote-build?
You can snapcraft export-login creds
on your workstation, do get a credentials file, which is your secret for the snap store.
This can be put in a GitHub Action as a 'secret'. When snapcraft
runs, it uses an environment variable called SNAPCRAFT_STORE_CREDENTIALS
, which contains the contents of the secret you generated above.
This gets store access, but I does not give Launchpad access to do the remote-build
. Ideally, it would need a dummy launchpad account called "snapcrafters-build", for example, that someone had the credentials for. The first time you run snapcraft remote-build
on a workstation, it asks you to oath with launchpad, asking you to click a URL like this:
/temp# snapcraft remote-build
snapcraft remote-build is experimental and is subject to change - use with caution.
All data sent to remote builders will be publicly available. Are you sure you want to continue? [y/N]: y
Using build ID snapcraft-my-snap-name-ee290312019f620c78fc612ecdc41945
The authorization page:
(https://launchpad.net/+authorize-token?oauth_token=mQ2DHwv2LZghs6sthNPG&allow_permission=DESKTOP_INTEGRATION)
should be opening in your browser. Use your browser to authorize
this program to access Launchpad on your behalf.
Waiting to hear from Launchpad about your decision...
Click the URL and you can then authorise this in launchpad:
Once authorised, you can run snapcraft remote-build
from that machine, and launchpad will build under that account on the launchpad build farm.
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Sending build data to Launchpad... (https://popey:<token>@git.launchpad.net/~popey/+git/snapcraft-my-snap-name-ee290312019f620c78fc612ecdc41945/)
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 549 bytes | 549.00 KiB/s, done.
Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
To https://git.launchpad.net/~popey/+git/snapcraft-my-snap-name-ee290312019f620c78fc612ecdc41945/
* [new branch] HEAD -> master
If interrupted, resume with: 'snapcraft remote-build --recover --build-id snapcraft-my-snap-name-ee290312019f620c78fc612ecdc41945'
Building snap package for amd64. This may take some time to finish.
Build status as of 2023-10-14 09:16:41.340915:
arch=amd64 state=Needs building
Build status as of 2023-10-14 09:17:11.706574:
arch=amd64 state=Currently building
You can see the code has been pushed to launchpad:
The build runs on launchpad for whichever architectures are specified, which you can see at https://launchpad.net/builders
The machine running snapcraft remote-build
will keep posting updates every 30 seconds until it finishes, receiving the snap and a log file, or just the log file if it fails.
Build status as of 2023-10-14 09:18:12.355951:
arch=amd64 state=Currently building
Build status as of 2023-10-14 09:18:42.777392:
arch=amd64 state=Currently building
Build status as of 2023-10-14 09:19:13.139419:
arch=amd64 state=Successfully built
Snapped my-snap-name_0.1_amd64.snap
Build log available at 'my-snap-name_amd64.txt'
Build complete.
The access token and access secret for snapcraft to talk to launchpad will be in ~/.local/share/snapcraft/provider/launchpad/credentials
on the workstation doing the remote build.
These credentials could also be put in github, to enable a headless call from a github action to do a remote-build.