Skip to content

Commit 40ddf57

Browse files
committed
kinda working install
1 parent 4cf70cc commit 40ddf57

6 files changed

Lines changed: 190 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
create_release:
10+
name: Create Release
11+
runs-on: ubuntu-latest
12+
outputs:
13+
upload_url: ${{ steps.create_release.outputs.upload_url }}
14+
steps:
15+
- name: Create Release
16+
id: create_release
17+
uses: actions/create-release@v1
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
with:
21+
tag_name: ${{ github.ref }}
22+
release_name: Release ${{ github.ref }}
23+
draft: true
24+
prerelease: false
25+
26+
build_and_upload:
27+
name: Build and Upload
28+
needs: create_release
29+
runs-on: ${{ matrix.os }}
30+
strategy:
31+
matrix:
32+
include:
33+
- os: ubuntu-latest
34+
target: x86_64-unknown-linux-gnu
35+
binary_name: cli
36+
asset_name: cli-x86_64-unknown-linux-gnu.tar.gz
37+
- os: macos-latest
38+
target: x86_64-apple-darwin
39+
binary_name: cli
40+
asset_name: cli-x86_64-apple-darwin.tar.gz
41+
- os: macos-latest
42+
target: aarch64-apple-darwin
43+
binary_name: cli
44+
asset_name: cli-aarch64-apple-darwin.tar.gz
45+
steps:
46+
- uses: actions/checkout@v4
47+
- name: Install Rust toolchain
48+
uses: actions-rs/toolchain@v1
49+
with:
50+
toolchain: stable
51+
target: ${{ matrix.target }}
52+
override: true
53+
- name: Build binary
54+
run: cargo build --release --target ${{ matrix.target }}
55+
- name: Prepare artifact
56+
run: |
57+
cd target/${{ matrix.target }}/release
58+
tar -czf ${{ matrix.asset_name }} ${{ matrix.binary_name }}
59+
cd -
60+
- name: Upload Release Asset
61+
uses: actions/upload-release-asset@v1
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
with:
65+
upload_url: ${{ needs.create_release.outputs.upload_url }}
66+
asset_path: ./target/${{ matrix.target }}/release/${{ matrix.asset_name }}
67+
asset_name: ${{ matrix.asset_name }}
68+
asset_content_type: application/gzip
69+
70+
publish_release:
71+
name: Publish Release
72+
needs: build_and_upload
73+
runs-on: ubuntu-latest
74+
steps:
75+
- name: Get Release
76+
id: get_release
77+
uses: bruceadams/get-release@v1
78+
env:
79+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
with:
81+
tag_name: ${{ github.ref_name }}
82+
- name: Publish Release
83+
uses: actions/github-script@v6
84+
with:
85+
github-token: ${{ secrets.GITHUB_TOKEN }}
86+
script: |
87+
await github.rest.repos.updateRelease({
88+
owner: context.repo.owner,
89+
repo: context.repo.repo,
90+
release_id: ${{ steps.get_release.outputs.id }},
91+
draft: false
92+
})

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ target/
1717
# and can be added to the global gitignore or merged into this file. For a more nuclear
1818
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
1919
#.idea/
20+
21+
.opencode

CONTEXT.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# FiveM Package Manager CLI Context
2+
3+
## Build & Test Commands
4+
- Build: `cargo build`
5+
- Run: `cargo run`
6+
- Test all: `cargo test`
7+
- Test single: `cargo test test_name`
8+
- Format: `cargo fmt`
9+
- Lint: `cargo clippy`
10+
11+
## Code Style Guidelines
12+
- **Imports**: Group by standard lib, external crates, then internal modules
13+
- **Error Handling**: Use Result<T, ()> with match patterns for error handling
14+
- **Naming**: Use snake_case for functions/variables, CamelCase for types/structs
15+
- **Types**: Explicit type annotations for function signatures
16+
- **Constants**: Use SCREAMING_SNAKE_CASE for constants
17+
- **Comments**: Use /// for doc comments, // for implementation notes
18+
- **Formatting**: Follow rustfmt conventions (4-space indentation)
19+
- **Functions**: Keep functions small and focused on a single responsibility
20+
- **Error Messages**: Use println! for info, eprintln! for errors

install.sh

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
set -e
3+
4+
REPO="citizenpkg/cli"
5+
BINARY_NAME="cli"
6+
INSTALL_DIR="/usr/local/bin"
7+
8+
OS=$(uname -s)
9+
ARCH=$(uname -m)
10+
11+
case "$OS" in
12+
Linux)
13+
TARGET_OS="unknown-linux-gnu"
14+
;;
15+
Darwin)
16+
TARGET_OS="apple-darwin"
17+
;;
18+
*)
19+
echo "Unsupported OS: $OS"
20+
exit 1
21+
;;
22+
esac
23+
24+
case "$ARCH" in
25+
x86_64)
26+
TARGET_ARCH="x86_64"
27+
;;
28+
arm64 | aarch64)
29+
TARGET_ARCH="aarch64"
30+
;;
31+
*)
32+
echo "Unsupported architecture: $ARCH"
33+
exit 1
34+
;;
35+
esac
36+
37+
ASSET_NAME="${BINARY_NAME}-${TARGET_ARCH}-${TARGET_OS}.tar.gz"
38+
LATEST_RELEASE_URL="https://api.github.com/repos/${REPO}/releases/latest"
39+
40+
echo "Fetching latest release information..."
41+
DOWNLOAD_URL=$(curl -sSL "$LATEST_RELEASE_URL" | grep "browser_download_url.*${ASSET_NAME}" | cut -d '"' -f 4)
42+
43+
if [ -z "$DOWNLOAD_URL" ]; then
44+
echo "Could not find a download URL for the latest release for your system ($OS/$ARCH)."
45+
echo "Please check the releases page: https://github.com/${REPO}/releases"
46+
exit 1
47+
fi
48+
49+
TMP_DIR=$(mktemp -d)
50+
echo "Downloading $DOWNLOAD_URL to $TMP_DIR..."
51+
curl -sSL "$DOWNLOAD_URL" -o "$TMP_DIR/$ASSET_NAME"
52+
53+
echo "Unpacking archive..."
54+
tar -xzf "$TMP_DIR/$ASSET_NAME" -C "$TMP_DIR"
55+
56+
BINARY_PATH="$TMP_DIR/$BINARY_NAME"
57+
58+
if [ ! -f "$BINARY_PATH" ]; then
59+
echo >&2 "Binary not found after unpacking. Aborting."
60+
exit 1
61+
fi
62+
63+
echo "Installing binary to $INSTALL_DIR..."
64+
if [ -w "$INSTALL_DIR" ]; then
65+
mv "$BINARY_PATH" "$INSTALL_DIR/"
66+
else
67+
echo "Write permission to $INSTALL_DIR is required. You may be prompted for your password."
68+
sudo mv "$BINARY_PATH" "$INSTALL_DIR/"
69+
fi
70+
71+
echo "Cleaning up..."
72+
rm -rf "$TMP_DIR"
73+
74+
echo "Installation successful! You can now use the '$BINARY_NAME' command."

src/installer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::io::{Read, Write};
22

33
use crate::registry::Registry;
44

5-
const PACKAGE_DIRECTORY: &str = "fx_modules";
5+
const PACKAGE_DIRECTORY: &str = "[fx_modules]";
66
const MODULES_FILE: &str = "modules.json";
77

88
pub struct PackageInstall {

src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* [fx_modules]/pure_lua_resource
1010
* metadata.json
1111
* - contains version number
12-
* fx_manifest.lua
12+
* fxmanifest.lua
1313
* main.lua
1414
*
1515
* ----- [some_resource/fxmanifest.lua]
@@ -40,7 +40,6 @@ enum Commands {
4040

4141
#[derive(Debug, Args)]
4242
struct InstallArgs {
43-
/// The package to install
4443
name: String,
4544
}
4645

0 commit comments

Comments
 (0)