Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: jd
base: core24
adopt-info: jd
summary: Utility to diff and patch json and yaml files
description: |
jd is a commandline utility and Go library for diffing and patching JSON
and YAML values. It supports a native jd format (similar to unified format)
as well as JSON Merge Patch (RFC 7386) and a subset of JSON Patch (RFC 6902).
Try it out at http://play.jd-tool.io/.

grade: stable # must be 'stable' to release into candidate/stable channels
confinement: strict # use 'strict' once you have the right plugs and slots

apps:
jd:
command: jd
plugs: &standard [home, network-bind]

parts:
jd:
plugin: dump
build-snaps:
- go
source: .
override-build: |
craftctl default
export GOROOT="$(go env GOROOT)"
make build
ls
mv release/jd $CRAFT_PART_INSTALL/
# extract the version from main.go and set it as the snap version
VERSION=`grep "const version" main.go | grep -oP '"[\w\.-]+"' | grep -oP "[\w\.-]+"`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more stable to rely on the -version flag. E.g. go run . -version. Output looks like jd version HEAD and I will keep it stable, even if I change the way the version number works (e.g. if I provide it as a build parameter).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, sorry I kinda abandoned this here. The point of that line is to extract an actual version from jd (as it doesn't seem to return the semver version from the -version flag if you run it from source, can't recall if this was intended). Regardless, the version is not a valid snap version as it can't contain spaces, and it is pretty useless (imagne downloading version HEAD from the store!).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code at HEAD doesn't have a version (it just returns HEAD). But the release binaries and associated tagged sources do. So you should be packaging a released version, not one built from head. You can still build from source, but you should should build from a released source.

craftctl set version=${VERSION:-unknown}
stage:
- jd