Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add prql-compiler to snapcraft #762

Closed
wants to merge 3 commits into from
Closed

Add prql-compiler to snapcraft #762

wants to merge 3 commits into from

Conversation

paulomach
Copy link

@paulomach paulomach commented Jul 5, 2022

This PR is:

  • A snapcraft.yaml: metadata for publishing on snapcraft - it uses the semver tags on branch main to choose latest release
  • M .github/workflows/release.yml: job for auto-publishing to snapcraft. As per documentation, requires a repo secret to be added. This will require coordination over the discord channel.

The snap is already published under version 0.2.0, available at https://snapcraft.io/prql-compiler

@max-sixty max-sixty changed the title Add prql-compiler to snapcract Add prql-compiler to snapcraft Jul 5, 2022
Copy link
Member

@max-sixty max-sixty left a comment

Choose a reason for hiding this comment

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

As much as I understand, this looks great, happy to see how this goes unless there's feedback from anyone else?

Thanks @paulomach!

@max-sixty
Copy link
Member

@paulomach I'm sorry this didn't get another review. There was one very small issue that pre-commit caught (but didn't seem to fix automatically...)

I've resolved the conflicts and included a new diff here. Would you be up for resetting to the current main, applying this diff, and then force-pushing? That way the changes will come from you.

Should we set up a STORE_LOGIN for prql, for the token? Is there anything else we need to do?

diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index aa9ca7a5..501f95fc 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -101,6 +101,18 @@ jobs:
         env:
           CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
 
+  publish-snapcraft:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - uses: snapcore/action-build@v1
+        id: build
+      - uses: snapcore/action-publish@v1
+        env:
+          SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }}
+        with:
+          snap: ${{ steps.build.outputs.snap }}
+          release: stable
   # Requires another pass: https://github.com/prql/prql/issues/850
   # publish-prql-java:
   #   runs-on: ubuntu-latest
diff --git a/snapcraft.yaml b/snapcraft.yaml
new file mode 100644
index 00000000..125dafe0
--- /dev/null
+++ b/snapcraft.yaml
@@ -0,0 +1,46 @@
+name: prql-compiler
+adopt-info: prql-compiler
+base: core20
+summary: Pipelined Relational Query Language, pronounced "Prequel"
+description: |
+  PRQL is a modern language for transforming data — a simple, powerful,
+  pipelined SQL replacement. Like SQL, it's readable, explicit and
+  declarative. Unlike SQL, it forms a logical pipeline of transformations,
+  and supports abstractions such as variables and functions. It can be
+  used with any database that uses SQL, since it transpiles to SQL. *NOTE*:
+  this snap packs only the `prql-compiler`, and not the bindings.
+license: Apache-2.0
+grade: stable
+confinement: strict
+issues: https://github.com/prql/prql/issues
+source-code: https://github.com/prql/prql.git
+website: https://prql-lang.org/
+icon: website/static/img/icon.svg
+
+apps:
+  prql-compiler:
+    command: bin/prql-compiler
+    plugs:
+      - home
+      - removable-media
+
+parts:
+  prql-compiler:
+    plugin: rust
+    source: https://github.com/prql/prql.git
+    build-packages:
+      - rust-all
+    override-build: |
+      last_committed_tag="$(git describe --tags --abbrev=0)"
+      last_committed_tag_ver="$(echo ${last_committed_tag} | sed 's/v//')"
+      last_released_tag="$(snap info $SNAPCRAFT_PROJECT_NAME | awk '$1 == "beta:" { print $2 }' || echo '0.0.0')"
+      # If the latest tag from the upstream project has not been released to
+      # beta, build that tag instead of master.
+      if [ "${last_committed_tag_ver}" != "${last_released_tag}" ]; then
+        git fetch
+        git checkout "${last_committed_tag}"
+        cd ../src
+        git checkout "${last_committed_tag}"
+      fi
+      cargo install --locked --path prql-compiler --root /root/parts/prql-compiler/install --force
+      snapcraftctl set-version $(git -C ../src describe --tags  | sed 's/v//')

@max-sixty
Copy link
Member

Closing as stale unfortunately. Much of that is my fault for not seeing a follow up commit for a while and so it not receiving a timely review.

Feel free to reopen or create a new PR, either @paulomach or a new contributor.

@paulomach thanks for starting this off! We appreciate it.

@vanillajonathan
Copy link
Collaborator

@paulomach We have now merged a PR that adds Snap support. #1881

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants