Skip to content

Commit b0cc838

Browse files
authored
Add Snapcraft (#3)
- Add snap/snapcraft.yaml - Add .github/workflows/snapcraft.yaml
1 parent c95ed52 commit b0cc838

File tree

11 files changed

+228
-64
lines changed

11 files changed

+228
-64
lines changed

.github/workflows/lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
paths-ignore:
88
- ".gitattributes"
99
- ".gitignore"
10-
- "*.ps1"
10+
- ".prettierignore"
1111
pull_request:
1212

1313
concurrency:

.github/workflows/preview.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
jobs:
17-
preview:
18-
name: "Preview"
17+
build:
18+
name: "Build"
1919
runs-on: ubuntu-latest
2020
timeout-minutes: 5
2121
steps:
@@ -28,7 +28,7 @@ jobs:
2828
deploy:
2929
name: "Deploy"
3030
uses: cssnr/workflows/.github/workflows/deploy-static.yaml@master
31-
needs: [preview]
31+
needs: [build]
3232
with:
3333
name: "preview"
3434
url: "https://dev-static.cssnr.com/toml-run"

.github/workflows/release.yaml

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@ on:
66

77
env:
88
name: "toml-run"
9+
download-url: "https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/toml_run-${{ github.ref_name }}.tar.gz"
910

1011
jobs:
11-
#pyinstaller:
12-
# name: "PyInstaller"
13-
# uses: ./.github/workflows/pyinstaller.yaml
14-
# secrets: inherit
15-
# with:
16-
# version: ${{ github.ref_name }}
17-
# permissions:
18-
# contents: write
12+
snapcraft:
13+
name: "Snapcraft"
14+
if: ${{ !github.event.release.prerelease }}
15+
uses: ./.github/workflows/snapcraft.yaml
16+
secrets: inherit
17+
with:
18+
version: ${{ github.ref_name }}
19+
permissions:
20+
contents: write
1921

2022
build:
2123
name: "Build"
@@ -100,37 +102,27 @@ jobs:
100102
runs-on: ubuntu-latest
101103
timeout-minutes: 5
102104
needs: [publish, build]
103-
104-
env:
105-
repo: "cssnr/tap"
106-
path: "homebrew"
107-
branch: "master"
108-
formula: "toml-run.rb"
109-
110105
steps:
111-
- name: "Checkout Homebrew"
112-
uses: actions/checkout@v6
106+
#- name: "Homebrew Action"
107+
# uses: cssnr/homebrew-action@master
108+
# with:
109+
# version: ${{ github.ref_name }}
110+
# repo: cssnr/homebrew-tap
111+
# token: ${{ secrets.HOMEBREW_PAT }}
112+
113+
- name: "Homebrew Formula Action"
114+
uses: mislav/bump-homebrew-formula-action@v3
115+
env:
116+
COMMITTER_TOKEN: ${{ secrets.HOMEBREW_PAT }}
113117
with:
114-
repository: ${{ env.repo }}
115-
ref: ${{ env.branch }}
116-
path: ${{ env.path }}
117-
persist-credentials: false
118-
119-
- name: "Update Formula"
120-
shell: bash
121-
run: |
122-
line=$(grep -n -m1 version "${{ env.path }}/Formula/${{ env.formula }}" | cut -f1 -d:)
123-
sed -i "${line}"'s/.*/ version "${{ github.ref_name }}"/' "${{ env.path }}/Formula/${{ env.formula }}"
124-
cat "${{ env.path }}/Formula/${{ env.formula }}"
125-
126-
- name: "Commit and Push"
127-
working-directory: ${{ env.path }}
128-
run: |
129-
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
130-
git config --local user.name "github-actions[bot]"
131-
git commit -a -m "Bump ${{ env.formula }} to ${{ github.ref_name }}"
132-
git remote set-url origin "https://${{ secrets.HOMEBREW_PAT }}@github.com/${{ env.repo }}"
133-
git push -u origin ${{ env.branch }}
118+
formula-name: toml-run.rb
119+
tag-name: ${{ github.ref_name }}
120+
download-url: ${{ env.download-url }}
121+
#download-sha256: 64be704a875d2a59753d80ee8a533c3fe183e3f06807ff7dc2232938ccb01549
122+
homebrew-tap: "smashedr/homebrew-test"
123+
create-pullrequest: false
124+
create-branch: false
125+
commit-message: "Bump {{formulaName}} to {{version}}"
134126

135127
release:
136128
name: "Release"

.github/workflows/snapcraft.yaml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: "Snapcraft"
2+
3+
on:
4+
workflow_call:
5+
inputs: &inputs
6+
version:
7+
description: "Build Version"
8+
type: string
9+
required: true
10+
version-file:
11+
description: "Version File"
12+
type: string
13+
default: "src/*/_version.py"
14+
snap-file:
15+
description: "Snap File"
16+
type: string
17+
default: "snap/snapcraft.yaml"
18+
workflow_dispatch:
19+
inputs: *inputs
20+
21+
jobs:
22+
snapcraft:
23+
name: "Snapcraft - ${{ matrix.os }}"
24+
runs-on: ${{ matrix.os }}
25+
timeout-minutes: 10
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
os: [ubuntu-latest, ubuntu-24.04-arm]
30+
31+
permissions:
32+
contents: read
33+
34+
env:
35+
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
36+
37+
steps:
38+
- name: "Checkout"
39+
uses: actions/checkout@v6
40+
41+
- name: "Debug event.json"
42+
continue-on-error: true
43+
run: cat "${GITHUB_EVENT_PATH}"
44+
- name: "Debug CTX github"
45+
continue-on-error: true
46+
env:
47+
GITHUB_CTX: ${{ toJSON(github) }}
48+
run: echo "$GITHUB_CTX"
49+
- name: "Debug Environment"
50+
continue-on-error: true
51+
run: env
52+
53+
- name: "Update Version"
54+
uses: justalemon/VersionPatcher@master
55+
with:
56+
version: ${{ inputs.version }}
57+
initpy-files: ${{ inputs.version-file }}
58+
59+
- name: "Debug Version"
60+
continue-on-error: true
61+
run: |
62+
cat ${{ inputs.version-file }}
63+
64+
# https://documentation.ubuntu.com/snapcraft/stable/how-to/crafting/configure-package-information/#configure-package-information
65+
- name: "Update Snap Version"
66+
uses: mikefarah/yq@master
67+
with:
68+
cmd: yq -i '.version = "${{ inputs.version }}"' '${{ inputs.snap-file }}'
69+
70+
- name: "Debug Snap Version"
71+
continue-on-error: true
72+
run: |
73+
cat "${{ inputs.snap-file }}"
74+
75+
- name: "Snap Build"
76+
id: build
77+
uses: snapcore/action-build@v1
78+
with:
79+
snapcraft-args: "--verbosity verbose"
80+
81+
- name: "Stat Snap"
82+
continue-on-error: true
83+
run: |
84+
results="$(stat ${{ steps.build.outputs.snap }})"
85+
echo "::group::results"
86+
echo "${results}"
87+
echo "::endgroup::"
88+
md="Snap: \`${{ steps.build.outputs.snap }}\`\n\`\`\`text\n${results}\n\`\`\`"
89+
echo -e "${md}" >> "$GITHUB_STEP_SUMMARY"
90+
91+
- name: "Upload to Actions"
92+
if: ${{ github.event_name != 'release' }}
93+
uses: actions/upload-artifact@v5
94+
with:
95+
name: snap
96+
path: ${{ steps.build.outputs.snap }}
97+
98+
- name: "Upload Release"
99+
if: ${{ github.event_name == 'release' }}
100+
uses: cssnr/upload-release-action@latest
101+
with:
102+
files: ${{ steps.build.outputs.snap }}
103+
104+
- name: "Snap Publish"
105+
uses: snapcore/action-publish@v1
106+
with:
107+
snap: ${{ steps.build.outputs.snap }}
108+
release: stable
109+
110+
- name: "Send Failure Notification"
111+
if: ${{ failure() }}
112+
uses: sarisia/actions-status-discord@b8381b25576cb341b2af39926ab42c5056cc44ed # v1.15.5
113+
with:
114+
webhook: ${{ secrets.DISCORD_WEBHOOK }}
115+
description: ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}

.github/workflows/test.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ on:
99
- "src/**"
1010
- "tests/**"
1111
- "pyproject.toml"
12-
- "uv.lock"
1312
pull_request:
1413
branches: [master]
1514
paths: *paths

.prettierignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# IDE
2+
.idea/
3+
.vscode/
4+
5+
# Build
6+
dist/
7+
node_modules/
8+
9+
# Tools
10+
.*cache*/
11+
package-lock.json
12+
13+
# Files
14+
*.html

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ pip install --group dev toml-run
6565
uv tool install toml-run
6666
uv add --dev toml-run
6767

68-
brew tap cssnr/tap
69-
brew install toml-run
68+
brew install cssnr/tap/toml-run
7069
```
7170

7271
[![View Install Guide](https://img.shields.io/badge/view_install_guide-blue?style=for-the-badge&logo=googledocs&logoColor=white)](https://cssnr.github.io/toml-run/reference/#install)

docs/index.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ To get started see the [Quick Start](#quick-start) section or check out the [Fea
3232
uv tool install toml-run
3333
```
3434

35-
=== "uv + dev"
35+
=== "uv-dev"
3636

3737
```shell
3838
uv add --dev toml-run
@@ -44,7 +44,7 @@ To get started see the [Quick Start](#quick-start) section or check out the [Fea
4444
pip install toml-run
4545
```
4646

47-
=== "pip + dev"
47+
=== "pip-dev"
4848

4949
```shell
5050
pip install --group dev toml-run
@@ -53,8 +53,7 @@ To get started see the [Quick Start](#quick-start) section or check out the [Fea
5353
=== "brew"
5454

5555
```shell
56-
brew tap cssnr/tap
57-
brew install toml-run
56+
brew install cssnr/tap/toml-run
5857
```
5958

6059
```toml title="pyproject.toml"
@@ -95,7 +94,7 @@ or [GitHub :lucide-arrow-up-right:](https://github.com/cssnr/toml-run?tab=readme
9594
uv tool install toml-run
9695
```
9796

98-
=== "uv + dev"
97+
=== "uv-dev"
9998

10099
```shell
101100
uv add --dev toml-run
@@ -107,7 +106,7 @@ or [GitHub :lucide-arrow-up-right:](https://github.com/cssnr/toml-run?tab=readme
107106
pip install toml-run
108107
```
109108

110-
=== "pip + dev"
109+
=== "pip-dev"
111110

112111
```shell
113112
pip install --group dev toml-run
@@ -116,8 +115,7 @@ or [GitHub :lucide-arrow-up-right:](https://github.com/cssnr/toml-run?tab=readme
116115
=== "brew"
117116

118117
```shell
119-
brew tap cssnr/tap
120-
brew install toml-run
118+
brew install cssnr/tap/toml-run
121119
```
122120

123121
Then, add some [scripts](reference.md#scripts) to the `pyproject.toml`.

docs/overrides/main.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<link rel="apple-touch-icon" href="{{ path }}/assets/images/logo.png" />
88

99
<meta property="og:type" content="website" />
10-
<meta property="og:site_name" content="Run Custom pyproject.toml Scripts." />
10+
<meta property="og:site_name" content="Run Custom pyproject.toml Scripts" />
1111
<meta property="og:title" content="TOML Run" />
1212
<meta
1313
property="og:description"

0 commit comments

Comments
 (0)