Skip to content

fix(build): fix snap release#37602

Closed
lunny wants to merge 3 commits into
go-gitea:mainfrom
lunny:lunny/revert_snap
Closed

fix(build): fix snap release#37602
lunny wants to merge 3 commits into
go-gitea:mainfrom
lunny:lunny/revert_snap

Conversation

@lunny
Copy link
Copy Markdown
Member

@lunny lunny commented May 8, 2026

Fix #37593
The stable version release of snap will read the main branch's snap file. So that we cannot remove the sqlite tags at the moment.

@lunny lunny added topic/build PR changes how Gitea is built, i.e. regarding Docker or the Makefile skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. labels May 8, 2026
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 8, 2026
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 8, 2026
@lunny lunny changed the title Fix snap release fix(build): fix snap release May 8, 2026
@lunny lunny requested a review from techknowlogick May 8, 2026 06:13
Copy link
Copy Markdown
Contributor

@wxiaoguang wxiaoguang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can't be a right fix.

  1. Why snap build can't read 1.26 branch?
  2. If you do so, the build will break again if main branch changes in the future

Update: for the os.Getuid problem, not in this PR's scope: fix: "run as root" check #37622 , so I marked other comments as "resolved" to make the discussion more focused here.

@GiteaBot GiteaBot added lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 8, 2026
@wxiaoguang

This comment was marked as resolved.

@mcphail

This comment was marked as resolved.

@wxiaoguang

This comment was marked as resolved.

@bircni bircni added this to the 1.26.2 milestone May 8, 2026
@lunny

This comment was marked as off-topic.

@wxiaoguang

This comment was marked as off-topic.

@lunny lunny removed this from the 1.26.2 milestone May 8, 2026
@wxiaoguang wxiaoguang added this to the 1.26.2 milestone May 8, 2026
@lunny

This comment was marked as resolved.

@wxiaoguang

This comment was marked as resolved.

@wxiaoguang wxiaoguang removed this from the 1.26.2 milestone May 8, 2026
@wxiaoguang

This comment was marked as resolved.

@silverwind
Copy link
Copy Markdown
Member

Suggestion to address the "will break again on main" concern without waiting for an infra fix: detect the checked-out source's needs in override-build and pick tags accordingly. models/db/driver_sqlite_modernc.go was added by #37562 and is a clean marker:

override-build: |
  set -x
  npm install -g pnpm
  # 1.26.x sources need explicit sqlite tags; 1.27+ defaults to modernc
  if [ -f models/db/driver_sqlite_modernc.go ]; then
    TAGS="bindata pam cert"
  else
    TAGS="bindata sqlite sqlite_unlock_notify pam cert"
  fi
  TAGS="\$TAGS" make build
  install -D gitea "\${SNAPCRAFT_PART_INSTALL}/gitea"
  cp -r options "\${SNAPCRAFT_PART_INSTALL}/"

Auto-adapts per tag, no follow-up needed when 1.26 is EOL'd.

The structurally correct fix is at the snap infra level — have the Store build read snapcraft.yaml from the release tag, not from main — but that's out of repo scope.


Comment written by Claude Opus 4.7

@wxiaoguang
Copy link
Copy Markdown
Contributor

wxiaoguang commented May 10, 2026

Suggestion to address the "will break again on main" concern without waiting for an infra fix: detect the checked-out source's needs in override-build and pick tags accordingly. models/db/driver_sqlite_modernc.go was added by #37562 and is a clean marker:

AI slop. It would only add one more dirty hack to the already buggy snap build steps. There are far more problems in the snap build than it looks, if you would spend some time to investigate. I have proposed some fixes, but I am just curious whether there are people able to maintain such legacy code correctly.

@silverwind
Copy link
Copy Markdown
Member

silverwind commented May 10, 2026

For @techknowlogick / @lunny: The structural fix lives on Canonical's side. The Snap Store "Builds" tab only ever builds from the GitHub default branch — no per-branch or per-tag trigger (open feature requests for branch and tag since 2017) — so the snapcraft.io integration alone can't be configured to read snapcraft.yaml from a release tag.

The supported workaround is Launchpad snap recipes (one recipe per long-lived ref, each reads its own snapcraft.yaml):

  1. Sign in to Launchpad with the Ubuntu One account that owns the gitea snap.
  2. Import this repo via https://launchpad.net/+code-imports/+new (Launchpad auto-syncs every few hours).
  3. For each ref to publish, open its page on Launchpad (+ref/main, +ref/release/v1.26, …) and click Create snap package:
    • Snap name: gitea
    • Auto build: yes
    • Store channels: e.g. latest/edge for main, 1.26/stable for release/v1.26
  4. Disconnect the GitHub build integration on snapcraft.io so the two systems don't fight over channels.
  5. Cleanup: override-pull's last_committed_tag / git checkout dance becomes unnecessary — each recipe is pinned to its ref, so the yaml on release/v1.26 can keep legacy sqlite tags and main's yaml can drop them.

Lighter alternative — snapcraft remote-build invoked from a release CI workflow that has already checked out the tag. Moves the problem into CI, no Launchpad-recipe admin needed.

Either of these makes #37593-class breakages structurally impossible; the in-tree workaround in this PR (or my earlier file-marker suggestion) is only needed until one of them is set up.


Comment written by Claude Opus 4.7

@silverwind
Copy link
Copy Markdown
Member

AI slop. It would only add one more dirty hack to the already buggy snap build steps

Yes, it's a workaround, the proper fix options are described in comment above.

@wxiaoguang
Copy link
Copy Markdown
Contributor

wxiaoguang commented May 10, 2026

AI slop. It would only add one more dirty hack to the already buggy snap build steps

Yes, it's a workaround, the proper fix options are described in comment above.

Even if nobody would like to touch snapcraft.io and keep adding new branches to launchpad, the "almost" complete fix can be like this: wxiaoguang@aeaf3ab

@silverwind
Copy link
Copy Markdown
Member

silverwind commented May 10, 2026

Even if nobody would like to touch snapcraft.io and keeping adding new branches to launchpad, the "almost" complete fix can be like this: wxiaoguang@aeaf3ab

I had Claude look at that and it likes it. One remark:

this needs ordered deployment. After main switches to ./snap/part-gitea-build.sh, snapcraft will try to run that script from whatever ref it checks out. If release/v1.26 doesn't yet contain snap/part-gitea-build.sh, the next 1.26.x stable build breaks. Order: backport the two scripts to release/v1.26, then merge the yaml switch on main.

@wxiaoguang
Copy link
Copy Markdown
Contributor

I had Claude look at that and it likes it. One remark:

this needs ordered deployment.

Yes, that's my proposal. 1.26 fix, then main

@lunny lunny closed this May 10, 2026
@lunny lunny deleted the lunny/revert_snap branch May 10, 2026 18:28
@silverwind
Copy link
Copy Markdown
Member

So how do we continue here? Branch https://github.com/wxiaoguang/gitea/tree/fix-snap does not have a PR up yet?

@bircni
Copy link
Copy Markdown
Member

bircni commented May 11, 2026

So how do we continue here? Branch https://github.com/wxiaoguang/gitea/tree/fix-snap does not have a PR up yet?

@wxiaoguang ping

@wxiaoguang
Copy link
Copy Markdown
Contributor

wxiaoguang commented May 11, 2026

Let the owner decide what they would like to do. Fix the snapcraft.io, or fix the build script ( #37602 (comment) )

@lunny
Copy link
Copy Markdown
Member Author

lunny commented May 11, 2026

Let the owner decide what they would like to do. Fix the snapcraft.io, or fix the build script ( (earlier comment) )

I prefer your commits.

@silverwind
Copy link
Copy Markdown
Member

silverwind commented May 11, 2026

There's a third option too with snapcraft remote-build which moves that build into CI, also a viable option. Or maybe that is what the script already does, have not checked in detail.

@wxiaoguang
Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. topic/build PR changes how Gitea is built, i.e. regarding Docker or the Makefile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Both stable and edge snaps are broken in different ways

6 participants