Snapcraft #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Snapcraft" | |
| on: | |
| workflow_call: | |
| inputs: &inputs | |
| version: | |
| description: "Build Version" | |
| type: string | |
| required: true | |
| version-file: | |
| description: "Version File" | |
| type: string | |
| default: "src/*/_version.py" | |
| snap-file: | |
| description: "Snap File" | |
| type: string | |
| default: "snap/snapcraft.yaml" | |
| workflow_dispatch: | |
| inputs: *inputs | |
| jobs: | |
| snapcraft: | |
| name: "Build" | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: "Checkout" | |
| uses: actions/checkout@v6 | |
| - name: "Debug event.json" | |
| continue-on-error: true | |
| run: cat "${GITHUB_EVENT_PATH}" | |
| - name: "Debug CTX github" | |
| continue-on-error: true | |
| env: | |
| GITHUB_CTX: ${{ toJSON(github) }} | |
| run: echo "$GITHUB_CTX" | |
| - name: "Debug Environment" | |
| continue-on-error: true | |
| run: env | |
| - name: "Update Version" | |
| uses: justalemon/VersionPatcher@master | |
| with: | |
| version: ${{ inputs.version }} | |
| initpy-files: ${{ inputs.version-file }} | |
| - name: "Debug Version" | |
| continue-on-error: true | |
| run: | | |
| cat ${{ inputs.version-file }} | |
| # https://documentation.ubuntu.com/snapcraft/stable/how-to/crafting/configure-package-information/#configure-package-information | |
| - name: "Update Snap Version" | |
| uses: mikefarah/yq@master | |
| with: | |
| cmd: yq -i '.version = "${{ inputs.version }}"' '${{ inputs.snap-file }}' | |
| - name: "Debug Snap Version" | |
| continue-on-error: true | |
| run: | | |
| cat "${{ inputs.snap-file }}" | |
| - name: "Snap Build" | |
| id: build | |
| uses: snapcore/action-build@v1 | |
| - name: "Stat Snap" | |
| continue-on-error: true | |
| run: | | |
| results="$(stat ${{ steps.build.outputs.snap }})" | |
| echo "::group::results" | |
| echo "${results}" | |
| echo "::endgroup::" | |
| md="Snap: \`${{ steps.build.outputs.snap }}\`\n\`\`\`text\n${results}\n\`\`\`" | |
| echo -e "${md}" >> "$GITHUB_STEP_SUMMARY" | |
| - name: "Upload to Actions" | |
| if: ${{ github.event_name != 'release' }} | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: snap | |
| path: ${{ steps.build.outputs.snap }} | |
| - name: "Upload Release" | |
| if: ${{ github.event_name == 'release' }} | |
| uses: cssnr/upload-release-action@latest | |
| with: | |
| files: ${{ steps.build.outputs.snap }} | |
| - name: "Snap Publish" | |
| uses: snapcore/action-publish@v1 | |
| env: | |
| SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }} | |
| with: | |
| snap: ${{ steps.build.outputs.snap }} | |
| release: stable | |
| - name: "Send Failure Notification" | |
| if: ${{ failure() }} | |
| uses: sarisia/actions-status-discord@b8381b25576cb341b2af39926ab42c5056cc44ed # v1.15.5 | |
| with: | |
| webhook: ${{ secrets.DISCORD_WEBHOOK }} | |
| description: ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }} |