name: snapcraft

on:
  schedule:
    - cron: '44 3 * * *'
  push:
    branches:
      - main
    tags:
      - "v*"
    paths-ignore:
      - "README.md"
      - "LICENSE"
  pull_request:
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-24.04
    steps:
    - uses: actions/checkout@v4
    - run: sudo apt install -y just
    - run: sudo apt install -y sd
    - if: github.ref_type != 'tag'
      run: just create-snapcraft dev
    - if: github.ref_type == 'tag'
      run: just create-snapcraft stable
    - uses: snapcore/action-build@3bdaa03e1ba6bf59a65f84a751d943d549a54e79 # v1.3.0
      id: build
    - run: snapcraft upload ${{ steps.build.outputs.snap }}
      if: github.event_name != 'pull_request'
      env:
        SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}