How to promote snaps from edge in github actions

Hey there, I have another question for my app FluffyChat which I have migrated to Github recently: https://github.com/krille-chan/fluffychat

I am now just building and pushing to edge on every commit by using the Github integration of snapcraft.io but I also would like to automatically release to the candidate and to the release channel on Github releases from Github actions. I have written this job for it:

  promote_snapcraft:
    runs-on: ubuntu-latest
    env:
      SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
    steps:
      - name: Check out Git repository
        uses: actions/checkout@v3
      - name: Install Snapcraft
        uses: samuelmeuli/action-snapcraft@v2
      - run: snapcraft
      - name: Promote Snap
        run: |
          RELEASE_TYPE=$(echo "${{ github.ref }}" | awk -F"/" '{print $3}')
          if [ "$RELEASE_TYPE" = "rc" ]; then
              snapcraft promote fluffychat --from-channel edge --to-channel candidate --yes
          else
              snapcraft promote fluffychat --from-channel edge --to-channel stable --yes
          fi

But in the CI I now get the error message: Error: 'edge' is not a valid set value for --from-channel when using --yes.

Now how am I supposed to promote my builds from the CI? I don’t want to build in github actions and want to leave this up to snapcraft.io. I only want to move the builds from one channel to another on a release in Github.

I tried and got same error.

Looks like it’s a snapcraft cli bug.

I open a issue at: https://github.com/snapcore/snapcraft/issues/4312

The problem is still not solved for me. The issue just got closed but I still cannot promote snaps in Github Actions from edge to candidate or stable…

I would also like to know the official response here. Edge can’t be promoted to anything last I checked so how can we automate promotion of the latest build (edge) to something else? This is hands down the strangest part of working with snaps as a maintainer.

Any idea on how to get snaps promoted, in an automated fashion, from edge to XXX that were built by Canonical’s CI/CD system?

According to Snapcraft promote - #8 by sergiusens, that’s a job for snap release which works great IF that snap was built locally and the file is readily available.

So there is a workaround mentioned in the issue now:

  1. Set the environment variable SNAPCRAFT_HAS_TTY=“true”
  2. use yes | snapcraft promote <snap-name> --from-channel edge --to-channel <channel-name> instead of using --yes

My full Github actions job is therefore now:

  promote_snapcraft:
    runs-on: ubuntu-latest
    env:
      SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
    steps:
      - name: Check out Git repository
        uses: actions/checkout@v3
      - name: Install Snapcraft
        uses: samuelmeuli/action-snapcraft@v2
      - run: snapcraft
      - name: Promote Snap
        env: # Workaround for https://github.com/snapcore/snapcraft/issues/4439
          SNAPCRAFT_HAS_TTY: "true"
        run: |
          RELEASE_TYPE=$(echo "${{ github.ref }}" | awk -F"/" '{print $3}')
          if [ "$RELEASE_TYPE" = "rc" ]; then
              yes | snapcraft promote fluffychat --from-channel edge --to-channel candidate
          else
              yes | snapcraft promote fluffychat --from-channel edge --to-channel stable
          fi
1 Like