Skip to content

Commit 8df5e49

Browse files
authored
Build and publish Nushell deb, rpm and apk packages (#5)
1 parent fd06ad1 commit 8df5e49

20 files changed

+662
-214
lines changed

.github/workflows/apt.yaml

-41
This file was deleted.

.github/workflows/cr.yml

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Description:
2+
# - DeepSeek code review with GitHub Actions
3+
4+
name: Code Review
5+
on:
6+
pull_request_target:
7+
types:
8+
- opened # Triggers when a PR is opened
9+
- reopened # Triggers when a PR is reopened
10+
- synchronize # Triggers when a commit is pushed to the PR
11+
# - labeled # Triggers when a label is added to the PR
12+
13+
# fix: GraphQL: Resource not accessible by integration (addComment) error
14+
permissions:
15+
pull-requests: write
16+
17+
jobs:
18+
setup-deepseek-review:
19+
runs-on: ubuntu-latest
20+
name: Code Review
21+
# Make sure the code review happens only when the PR has the label 'ai review'
22+
# if: contains(github.event.pull_request.labels.*.name, 'ai review')
23+
steps:
24+
- name: DeepSeek Code Review
25+
uses: hustcer/deepseek-review@v1
26+
with:
27+
max-length: 50000
28+
# model: 'deepseek-v3' # Infinigence's DeepSeek V3 model
29+
model: 'deepseek-r1' # Infinigence's DeepSeek R1 model
30+
base-url: 'https://cloud.infini-ai.com/maas/v1' # Infinigence's API base URL
31+
# model: 'deepseek-ai/DeepSeek-V3' # SiliconFlow's DeepSeek V3 model
32+
# model: 'deepseek-ai/DeepSeek-R1' # SiliconFlow's DeepSeek R1 model
33+
# base-url: 'https://api.siliconflow.cn/v1' # SiliconFlow's API base URL
34+
# Store the chat token in GitHub Secrets, don't expose it in the workflow file
35+
chat-token: ${{ secrets.CHAT_TOKEN }}
36+
sys-prompt: >
37+
As a senior Nushell engineer, perform comprehensive script review with focus on:
38+
39+
### 1. Core Requirements:
40+
- Validate Nu 0.90+ compatibility
41+
- Check structured data handling
42+
- Verify pipeline efficiency
43+
- Assess module organization
44+
45+
### 2. Security Analysis:
46+
- Command injection prevention
47+
- Data leakage prevention
48+
- Safe external command usage
49+
- Proper permission validation
50+
51+
### 3. Performance Optimization:
52+
- Pipeline optimization
53+
- Memory usage patterns
54+
- Builtin vs external command usage
55+
- Parallel execution opportunities
56+
57+
**Rules:**
58+
- Target Nu 0.90+ features
59+
- Highlight data flow vulnerabilities
60+
- Suggest structured data optimizations
61+
- Keep feedback Nu-specific
62+
- Use modern shell terminology
63+
64+
**Required output structure:**
65+
#### Script Analysis
66+
- Key observations
67+
68+
#### Security Review
69+
- Vulnerability findings
70+
71+
#### Optimization Suggestions
72+
- Performance improvements
73+
74+
**Overall Quality:** Rating (1-5)
75+
76+
```yaml
77+
checklist:
78+
- Compatibility: ["Nu version", "Cross-platform support", "Plugin dependencies"]
79+
- Security: ["Input sanitization", "Temporary file handling", "Env exposure"]
80+
- Reliability: ["Error propagation", "Null handling", "Type validation"]
81+
- Performance: ["Lazy evaluation", "Batch processing", "Stream handling"]
82+
83+
examples:
84+
- issue: "❗ Unfiltered external command arguments in line 15 (command injection risk)"
85+
- issue: "⚠️ Plaintext credentials in environment variables"
86+
- suggestion: "Replace `each { }` with `par-each` for parallel processing"
87+
- suggestion: "Use builtin `from json` instead of jq for better performance"
88+
89+
response_template: |
90+
#### Script Analysis
91+
- {{observations}}
92+
93+
{{#security_issues}}
94+
#### Security Review
95+
- {{security_issues}}
96+
{{/security_issues}}
97+
98+
{{#optimizations}}
99+
#### Optimization Suggestions
100+
- {{optimizations}}
101+
{{/optimizations}}
102+
103+
**Overall Quality:** {{rating}}
104+
```

.github/workflows/release.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Description:
2+
# - Release Nu Pkgs
3+
# REF:
4+
# - https://github.com/marketplace/actions/checkout
5+
# - https://github.com/chawyehsu/moonbit-binaries/releases
6+
7+
name: Publish Nu Pkgs
8+
on:
9+
workflow_dispatch:
10+
push:
11+
tags:
12+
- '[0-9]+.[0-9]+.[0-9]+*'
13+
- '!*nightly*' # Don't trigger release for nightly tags
14+
15+
paths-ignore:
16+
- '**.md'
17+
18+
jobs:
19+
publish-pkgs:
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
os: [ubuntu-22.04, ubuntu-22.04-arm]
24+
runs-on: ${{ matrix.os }}
25+
name: Build Nu Pkgs@${{ matrix.os }}
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Setup Nushell
31+
uses: hustcer/setup-nu@v3
32+
33+
- name: Install nfpm & Gemfury CLI
34+
run: |
35+
echo "deb [trusted=yes] https://apt.fury.io/cli/ * *" | sudo tee /etc/apt/sources.list.d/fury-cli.list
36+
echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | sudo tee /etc/apt/sources.list.d/goreleaser.list
37+
sudo apt update
38+
sudo apt install nfpm fury-cli
39+
nfpm --version
40+
fury --version
41+
42+
- name: Build and Publish Nu Pkgs
43+
shell: nu {0}
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
GEMFURY_TOKEN: ${{ secrets.GEMFURY_TOKEN }}
47+
run: |
48+
use ${{ github.workspace }}/nu/release.nu *
49+
version | print
50+
# $env | print
51+
let arch = match $env.RUNNER_ARCH {
52+
'X64' => 'amd64',
53+
'ARM64' => 'arm64',
54+
_ => 'amd64'
55+
}
56+
fetch release $arch
57+
publish pkg $arch
58+

.github/workflows/test.yml

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Description:
2+
# - Release Nu Pkgs
3+
# REF:
4+
# - https://github.com/marketplace/actions/checkout
5+
# - https://gemfury.com/guide/alpine/configure-apk/
6+
7+
name: Test Install Nu Pkgs
8+
on:
9+
workflow_dispatch:
10+
push:
11+
branches:
12+
- main
13+
- develop
14+
15+
paths-ignore:
16+
- '**.md'
17+
18+
jobs:
19+
install-apk:
20+
name: Install Nu apk
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
os: [ubuntu-24.04, ubuntu-24.04-arm]
25+
runs-on: ${{ matrix.os }}
26+
container:
27+
image: alpine:latest
28+
steps:
29+
- name: Install Nushell APK
30+
run: |
31+
# Append Gemfury Nushell apk repository
32+
echo "https://alpine.fury.io/nushell/" | tee -a /etc/apk/repositories
33+
apk update || true
34+
# Use --allow-untrusted since the apk package is not signed currently
35+
apk add --allow-untrusted nushell
36+
which nu
37+
nu -c 'version'
38+
39+
install-rpm:
40+
name: Install Nu rpm
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
os: [ubuntu-24.04, ubuntu-24.04-arm]
45+
image:
46+
- fedora:latest
47+
- fedora:40
48+
- fedora:39
49+
- rockylinux:9
50+
- rockylinux:8
51+
- redhat/ubi9:latest
52+
- redhat/ubi8:latest
53+
runs-on: ${{ matrix.os }}
54+
container:
55+
image: ${{ matrix.image }}
56+
steps:
57+
- name: Test Install Nushell
58+
run: |
59+
# Create repo config file pointing to Gemfury
60+
echo "[gemfury-nushell]
61+
name=Gemfury Nushell Repo
62+
baseurl=https://yum.fury.io/nushell/
63+
enabled=1
64+
gpgcheck=0
65+
gpgkey=https://yum.fury.io/nushell/gpg.key" | tee /etc/yum.repos.d/fury-nushell.repo
66+
# Install Nushell via dnf
67+
dnf install -y nushell
68+
# Print nushell version to verify installation
69+
nu -c 'version'
70+
71+
install-deb:
72+
strategy:
73+
fail-fast: false
74+
matrix:
75+
os: [ubuntu-22.04, ubuntu-22.04-arm, ubuntu-24.04, ubuntu-24.04-arm]
76+
runs-on: ${{ matrix.os }}
77+
name: Install Nu deb@${{ matrix.os }}
78+
steps:
79+
- name: Test Install Nushell from Gemfury
80+
run: |
81+
curl -fsSL https://apt.fury.io/nushell/gpg.key | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/fury-nushell.gpg
82+
echo "deb https://apt.fury.io/nushell/ /" | sudo tee /etc/apt/sources.list.d/fury.list
83+
sudo apt update
84+
sudo apt install nushell
85+
which nu
86+
nu -c 'version'
87+
88+
install-on-debian:
89+
name: Install Nu deb
90+
strategy:
91+
fail-fast: false
92+
matrix:
93+
os: [ubuntu-24.04, ubuntu-24.04-arm]
94+
image:
95+
- debian:trixie
96+
- debian:bookworm
97+
- debian:bullseye
98+
runs-on: ${{ matrix.os }}
99+
container:
100+
image: ${{ matrix.image }}
101+
steps:
102+
- name: Test Install Nushell
103+
run: |
104+
# Disable SSL certificate checking for apt (not recommended for production!)
105+
echo 'Acquire::https::Verify-Peer "false";' | tee /etc/apt/apt.conf.d/99insecure
106+
echo 'Acquire::https::Verify-Host "false";' | tee -a /etc/apt/apt.conf.d/99insecure
107+
# curl & gpg are not available in debian images, so we install without verifying the gpg key
108+
# Add the repository with trusted=yes so that apt does not verify package signatures
109+
echo "deb [trusted=yes] https://apt.fury.io/nushell/ /" | tee /etc/apt/sources.list.d/fury.list
110+
apt update
111+
apt install nushell
112+
which nu
113+
nu -c 'version'

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
.vscode
2+
release/
23
.env
34
*.deb
5+
*.rpm
6+
*.apk

Justfile

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Author: hustcer
2+
# Created: 2025/03/21 19:15:20
3+
# Description:
4+
# Some helper task for making Nushell packages for various Linux distributions.
5+
# Ref:
6+
# 1. https://github.com/casey/just
7+
# 2. https://www.nushell.sh/book/
8+
9+
set shell := ['nu', '-c']
10+
11+
# The export setting causes all just variables
12+
# to be exported as environment variables.
13+
14+
set export := true
15+
set dotenv-load := true
16+
17+
# If positional-arguments is true, recipe arguments will be
18+
# passed as positional arguments to commands. For linewise
19+
# recipes, argument $0 will be the name of the recipe.
20+
21+
set positional-arguments := true
22+
23+
# Use `just --evaluate` to show env vars
24+
25+
# Used to handle the path separator issue
26+
NU_DISTRO_PATH := parent_directory(justfile())
27+
NU_DIR := parent_directory(`(which nu).path.0`)
28+
_query_plugin := if os_family() == 'windows' { 'nu_plugin_query.exe' } else { 'nu_plugin_query' }
29+
30+
# To pass arguments to a dependency, put the dependency
31+
# in parentheses along with the arguments, just like:
32+
# default: (sh-cmd "main")
33+
34+
# List available commands by default
35+
default:
36+
@just --list --list-prefix "··· "
37+
38+
# Release a new version for Nushell
39+
release *OPTIONS:
40+
@overlay use {{ join(NU_DISTRO_PATH, 'nu', 'release.nu') }}; \
41+
fetch release {{OPTIONS}}; publish pkg {{OPTIONS}}
42+
43+
# Plugins need to be registered only once after nu v0.61
44+
_setup:
45+
@register -e json {{ join(NU_DIR, _query_plugin) }}

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Nushell Project
3+
Copyright (c) 2025 Nushell Project
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)