Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
ciiqr committed Oct 26, 2024
1 parent a79ddc2 commit 7a9bffc
Show file tree
Hide file tree
Showing 8 changed files with 781 additions and 37 deletions.
10 changes: 9 additions & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
[target.'cfg(all(windows, target_env = "msvc"))']
[target.'cfg(target_env = "msvc")']
rustflags = ["-C", "target-feature=+crt-static"]

[target.'cfg(target_env = "musl")']
rustflags = [
"-C",
"target-feature=+crt-static",
"-L",
"-Wl,--copy-dt-needed-entries",
]
81 changes: 46 additions & 35 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,58 @@
name: release
on:
push:
branches:
- main
# TODO:
# branches:
# - main
jobs:
build:
name: Build
strategy:
matrix:
build:
- target: x86_64-apple-darwin
- artifact: nk-macos-x86_64
target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
# TODO:
# - target: aarch64-apple-darwin
# os: macos-latest
# - target: x86_64-unknown-linux-musl
# os: ubuntu-latest
# - target: x86_64-pc-windows-msvc
# os: windows-latest
runs-on: ${{ matrix.build.os }}
steps:
- uses: actions/checkout@v4
- name: Install target
run: rustup target add ${{ matrix.build.target }}
- name: Setup musl
run: |
rustup target add x86_64-unknown-linux-musl
sudo apt-get install -y musl-tools
echo 'LDFLAGS=-Wl,--copy-dt-needed-entries' >> $GITHUB_ENV
echo 'RUSTFLAGS=-C target-feature=+crt-static' >> $GITHUB_ENV
if: matrix.build.target == 'x86_64-unknown-linux-musl'
- name: Setup Apple Silicon
run: rustup target add aarch64-apple-darwin
if: matrix.build.target == 'aarch64-apple-darwin'
run: sudo apt-get install -y musl-tools
if: endsWith(matrix.build.target, '-musl')
- uses: Swatinem/rust-cache@v2
- name: Build
env:
TARGET: ${{ matrix.build.target }}
shell: bash
run: |
declare output
output="$(
cargo build \
--workspace \
--release \
--target "$TARGET" \
--message-format=json \
| jq -r '.message.rendered // .executable // empty'
)"
echo "ARTIFACT_PATH=$output" >> $GITHUB_ENV
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.build.target }}
path: ${{ env.ARTIFACT_PATH }}
run: cargo build --workspace --release --target ${{ matrix.build.target }}
# TODO:
# run: |
# declare output
# output="$(
# cargo build \
# --workspace \
# --release \
# --target "$TARGET" \
# --message-format=json \
# | jq -r '.message.rendered // .executable // empty'
# )"
# echo "ARTIFACT_PATH=$output" >> $GITHUB_ENV
- run: find target
# TODO:
# - name: Upload binary
# uses: actions/upload-artifact@v4
# with:
# name: ${{ matrix.build.target }}
# path: ${{ env.ARTIFACT_PATH }}
release:
name: Release
needs: build
Expand Down Expand Up @@ -81,6 +83,8 @@ jobs:
path: artifacts
- name: Move executables
run: |
# TODO: no echo
echo artifacts/*/*
for file in artifacts/*/*; do
exe="$(basename "$file")"
plugin="${exe%\.exe}"
Expand All @@ -95,6 +99,12 @@ jobs:
env:
REPOSITORY_NAME: ${{ github.event.repository.name }}
run: |
# TODO: no
echo nk plugin pack \
--owner "$GITHUB_REPOSITORY_OWNER" \
--repo "$REPOSITORY_NAME" \
--version "$TAG" \
./*/plugin.yml
nk plugin pack \
--owner "$GITHUB_REPOSITORY_OWNER" \
--repo "$REPOSITORY_NAME" \
Expand All @@ -105,7 +115,8 @@ jobs:
GITHUB_USER: ${{ github.repository_owner }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create \
# TODO: no echo
echo gh release create \
--title "$TAG" \
--notes '' \
"$TAG" \
Expand Down
17 changes: 17 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[workspace]
resolver = "2"
members = ["files"]
members = ["files", "meepis"]
24 changes: 24 additions & 0 deletions meepis/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "meepis"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[target.'cfg(windows)'.dependencies]
windows = { version = "0.51.1", features = [
"Win32_Foundation",
"Win32_Storage_FileSystem",
] }

[dependencies]
anyhow = "1.0.75"
camino = { version = "1.1.6", features = ["serde1"] }
clap = { version = "4.4.6", features = ["derive"] }
dirs = "5.0.1"
faccess = "0.2.4"
file-id = "0.2.1"
serde = { version = "1.0.189", features = ["derive"] }
serde_json = "1.0.107"
shellexpand = "3.1.0"
walkdir = "2.4.0"
45 changes: 45 additions & 0 deletions meepis/plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: files

provision:
when: declaration in ["files", "directories"]

schema:
$schema: https://json-schema.org/draft/2020-12/schema
# TODO: fix this, schemas need to be associated with their relevant declarations...
anyOf:
- type: string
- type: object
properties:
source:
type: string
destination:
type: string
link_files:
type: boolean
required:
- source
- destination

---
when:
- os == "macos"
- arch == "x86_64"
executable: assets/x86_64-apple-darwin/files

---
when:
- os == "macos"
- arch == "aarch64"
executable: assets/aarch64-apple-darwin/files

---
when:
- os == "linux"
- arch == "x86_64"
executable: assets/x86_64-unknown-linux-musl/files

---
when:
- family == "windows"
- arch == "x86_64"
executable: assets/x86_64-pc-windows-msvc/files.exe
35 changes: 35 additions & 0 deletions meepis/src/args.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use anyhow::Error;
use camino::Utf8PathBuf;
use clap::{arg, Args, Parser, Subcommand};
use serde::Deserialize;

#[derive(Debug, Parser)]
#[command(about, version)]
pub struct Arguments {
#[command(subcommand)]
pub command: Commands,
}

#[derive(Debug, Subcommand)]
pub enum Commands {
Provision(Provision),
}

#[derive(Debug, Args)]
pub struct Provision {
/// Provision info as json
#[arg(value_name = "info", value_parser = ProvisionInfo::value_parser)]
pub info: ProvisionInfo,
}

#[derive(Debug, Deserialize, Clone)]
pub struct ProvisionInfo {
pub sources: Vec<Utf8PathBuf>,
// pub vars: serde_json::Map<String, serde_json::Value>,
}

impl ProvisionInfo {
fn value_parser(value: &str) -> Result<Self, Error> {
Ok(serde_json::from_str(value)?)
}
}
Loading

0 comments on commit 7a9bffc

Please sign in to comment.