If you, like me, release your projects to the Snap Store using GoReleaser, you might need to eventually update the secret.

It seems to me that the secret expires every year, and this is the time of the year I need to renew mine.

To help future me, this is my recipe on how to do it quickly:

snapcraft export-login /tmp/snap.login
gh secret set SNAPCRAFT_STORE_CREDENTIALS </tmp/snap.login

If you used to use snapcraft login --with, it is not needed anymore! You can simply set the SNAPCRAFT_STORE_CREDENTIALS to authenticate, e.g.:

SNAPCRAFT_STORE_CREDENTIALS=$(cat /tmp/snap.login) snapcraft whoami

Or, if you want to use it with a GitHub Action, e.g. GoReleaser:

name: release

on:
  push:
    tags:
      - "*"

jobs:
  goreleaser:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-go@v5
        with:
          go-version: stable
      - name: setup-snapcraft
        run: |
          sudo apt-get update
          sudo apt-get -yq --no-install-suggests --no-install-recommends install snapcraft          
      - uses: goreleaser/goreleaser-action@v6
        with:
          args: release --clean
        env:
          GITHUB_TOKEN: ${{ secrets.GH_PAT }}
          SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_LOGIN }}

Hope this is helpful for you, or future me. 👴