aksakalli / gtop

System monitoring dashboard for terminal
MIT License
9.74k stars 326 forks source link

Upload new snap for v1.1.5 #134

Open mitchdz opened 1 year ago

mitchdz commented 1 year ago

Thanks for merging the snapcraft update! (https://github.com/aksakalli/gtop/pull/132)

Could the latest version be uploaded to snapcraft?

aksakalli commented 1 year ago

thanks for contributing. Do I need to create a release or do I need to manually trigger a build?

mitchdz commented 1 year ago

You'd need to manually trigger a build. You can change the release tag manually in snap/snapcraft.yaml like so:

diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
index be8c5f2..dd81d97 100644
--- a/snap/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -2,7 +2,7 @@ name: gtop
 summary: System monitoring dashboard for terminal
 description: |
   System monitoring dashboard for terminal
-version: git
+version: 1.1.5
 base: core22
 grade: stable

And after running snapcraft you should see gtop_1.1.5_amd64.snap. You can follow https://snapcraft.io/docs/releasing-your-app to upload the snap.

On a side-note, this is a little error prone because it assumes you set the right version manually which is a little tedious (in my opinion). An alternative is we can set snapcraft to pull the git source at a specific tag and build that. I personally prefer this because it also means you can't build a dirty source.

If you'd prefer the version control that I just mentioned above, I can make a PR for that, the diff is pretty simple:

diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
index be8c5f2..dd81d97 100644
--- a/snap/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -2,7 +2,7 @@ name: gtop
 summary: System monitoring dashboard for terminal
 description: |
   System monitoring dashboard for terminal
-version: git
+version: 1.1.5
 base: core22
 grade: stable

@@ -14,7 +14,9 @@ apps:

 parts:
   gtop:
-    source: .
+    source: https://github.com/aksakalli/gtop
+    source-type: git
+    source-tag: v1.1.5
     plugin: npm
     npm-include-node: true
     npm-node-version: "17.3.0"

This of course means that when you create a new release tag and want to publish the snap, the version and source-tag should be updated for the build.

aksakalli commented 1 year ago

Is there a way to automate this with Github Actions or something, if not please feel free to send a PR.

If the version is set as version: git, is it building the latest HEAD? So I need to add this tag change after creating a release?

mitchdz commented 1 year ago

I honestly haven't messed around with github actions too much, but I would imagine it could be done. I would say it depends how often you plan on updating package to see if it's worth setting that up.

The version: git string is an attribute that allows snapcraft to extract the version using git describe. For example, if you built HEAD without any changes right now it would be gtop_0+git.0406441_amd64.snap which just doesn't look great. It's pretty common to hardcode the version and upload the snap whenever you're ready manually.

mitchdz commented 1 year ago

PR to pin 1.1.5 - https://github.com/aksakalli/gtop/pull/135

Also found a handy variable during the snap build ${SNAPCRAFT_PROJECT_VERSION} which is the value of version: X so to change the build, you only need to change a single value :tada: