Skip to content

Commit f6be94a

Browse files
committed
fix: properly configure snap packaging with separate workflow
1 parent 9eebad4 commit f6be94a

File tree

4 files changed

+75
-25
lines changed

4 files changed

+75
-25
lines changed

.github/workflows/release.yml

+1-7
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ jobs:
4343
go-version: '1.23'
4444
cache: true
4545

46-
# Set up Snapcraft
47-
- name: Set up Snapcraft
48-
uses: snapcore/action-build@v1
49-
if: startsWith(github.ref, 'refs/tags/')
50-
5146
# Run GoReleaser
5247
- name: Run GoReleaser
5348
uses: goreleaser/goreleaser-action@v6
@@ -57,5 +52,4 @@ jobs:
5752
args: release --clean
5853
env:
5954
# Used for GitHub token and pushing to other repos
60-
GITHUB_TOKEN: ${{ secrets.GH_PERSONAL_TOKEN }}
61-
SNAPCRAFT_TOKEN: ${{ secrets.SNAPCRAFT_TOKEN }}
55+
GITHUB_TOKEN: ${{ secrets.GH_PERSONAL_TOKEN }}

.github/workflows/snap.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Build and Publish Snap
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build-and-publish:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Install Snapcraft
18+
uses: samuelmeuli/action-snapcraft@v2
19+
with:
20+
use_lxd: true
21+
22+
- name: Extract version from tag
23+
id: get_version
24+
run: |
25+
VERSION=${GITHUB_REF#refs/tags/v}
26+
echo "VERSION=$VERSION" >> $GITHUB_ENV
27+
echo "The version is $VERSION"
28+
29+
- name: Update version in snapcraft.yaml
30+
run: |
31+
sed -i "s/^version: git/version: $VERSION/" snap/snapcraft.yaml
32+
cat snap/snapcraft.yaml
33+
34+
- name: Build snap
35+
run: |
36+
snapcraft
37+
38+
- name: Publish snap
39+
uses: snapcore/action-publish@v1
40+
env:
41+
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
42+
with:
43+
snap: httpprobe_*.snap
44+
release: stable

.goreleaser.yml

+1-18
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,4 @@ brews:
9090
test: |
9191
system "#{bin}/httpprobe", "version"
9292
93-
# Snapcraft package
94-
snapcrafts:
95-
- name: httpprobe
96-
summary: HTTP API testing tool
97-
description: |
98-
A powerful HTTP API testing tool for defining, running,
99-
and validating API tests using YAML or JSON test definitions.
100-
grade: stable
101-
confinement: strict
102-
publish: true
103-
license: MIT
104-
base: core22
105-
apps:
106-
httpprobe:
107-
command: httpprobe
108-
plugs:
109-
- network
110-
- home
93+
# Snapcraft is handled by external snapcraft.yaml in the snap directory

snap/snapcraft.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: httpprobe
2+
version: git
3+
summary: HTTP API testing tool
4+
description: |
5+
A powerful HTTP API testing tool for defining, running,
6+
and validating API tests using YAML or JSON test definitions.
7+
8+
base: core22
9+
grade: stable
10+
confinement: strict
11+
12+
parts:
13+
httpprobe:
14+
plugin: go
15+
source: .
16+
source-type: local
17+
build-snaps:
18+
- go
19+
override-build: |
20+
craftctl default
21+
cd $CRAFT_PART_SRC
22+
go build -o $CRAFT_PART_INSTALL/bin/httpprobe ./cmd/main.go
23+
24+
apps:
25+
httpprobe:
26+
command: bin/httpprobe
27+
plugs:
28+
- network
29+
- home

0 commit comments

Comments
 (0)