prepare release of version 0.1.0
This commit is contained in:
parent
84c348782a
commit
0dae705a20
|
@ -0,0 +1,20 @@
|
|||
name: Publish
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
name: Publish to crates.io
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
env:
|
||||
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
key: publish
|
||||
- run: cargo publish --token ${CRATES_TOKEN}
|
|
@ -0,0 +1,83 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Building ${{ matrix.platform.os_name }}
|
||||
runs-on: ${{ matrix.platform.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform:
|
||||
- os_name: Linux-x86_64
|
||||
os: ubuntu-latest
|
||||
target: x86_64-unknown-linux-musl
|
||||
- os_name: Linux-aarch64
|
||||
os: ubuntu-latest
|
||||
target: aarch64-unknown-linux-musl
|
||||
- os_name: Linux-arm
|
||||
os: ubuntu-latest
|
||||
target: arm-unknown-linux-musleabi
|
||||
- os_name: Linux-i686
|
||||
os: ubuntu-latest
|
||||
target: i686-unknown-linux-musl
|
||||
- os_name: Windows-aarch64
|
||||
os: windows-latest
|
||||
target: aarch64-pc-windows-msvc
|
||||
- os_name: Windows-i686
|
||||
os: windows-latest
|
||||
target: i686-pc-windows-msvc
|
||||
- os_name: Windows-x86_64
|
||||
os: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
- os_name: macOS-x86_64
|
||||
os: macOS-latest
|
||||
target: x86_64-apple-darwin
|
||||
- os_name: macOS-aarch64
|
||||
os: macOS-latest
|
||||
target: aarch64-apple-darwin
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Cache cargo & target directories
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
key: "release"
|
||||
- name: Build binary
|
||||
uses: houseabsolute/actions-rust-cross@v0
|
||||
with:
|
||||
command: "build"
|
||||
target: ${{ matrix.platform.target }}
|
||||
toolchain: stable
|
||||
args:
|
||||
"--locked --release"
|
||||
strip: true
|
||||
- name: Package as .tar.gz (Linux)
|
||||
if: ${{ contains(matrix.platform.os, 'ubuntu') }}
|
||||
run: |
|
||||
mv target/${{ matrix.platform.target }}/release/shulkerscript ./shulkerscript
|
||||
tar -czvf shulkerscript-${{ matrix.platform.target }}.tar.gz shulkerscript
|
||||
echo UPLOAD_FILE=shulkerscript-${{ matrix.platform.target }}.tar.gz >> $GITHUB_ENV
|
||||
- name: Package as .zip (Windows)
|
||||
if: ${{ contains(matrix.platform.os, 'windows') }}
|
||||
shell: bash
|
||||
run: |
|
||||
mv target/${{ matrix.platform.target }}/release/shulkerscript.exe ./shulkerscript.exe
|
||||
pwsh -command ". 'Compress-Archive' shulkerscript.exe shulkerscript-${{ matrix.platform.target }}.zip"
|
||||
echo UPLOAD_FILE=shulkerscript-${{ matrix.platform.target }}.zip >> $GITHUB_ENV
|
||||
- name: Package as .zip (macOS)
|
||||
if: ${{ contains(matrix.platform.os, 'macOS') }}
|
||||
run: |
|
||||
mv target/${{ matrix.platform.target }}/release/shulkerscript ./shulkerscript
|
||||
zip shulkerscript-${{ matrix.platform.target }}.zip shulkerscript
|
||||
echo UPLOAD_FILE=shulkerscript-${{ matrix.platform.target }}.zip >> $GITHUB_ENV
|
||||
- name: Upload artifact to release
|
||||
shell: bash
|
||||
run: gh release upload ${{ github.event.release.tag_name }} $UPLOAD_FILE
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@ -0,0 +1,19 @@
|
|||
name: Cargo test
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- development
|
||||
- 'releases/**'
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Cargo test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: cargo test --verbose
|
14
CHANGELOG.md
14
CHANGELOG.md
|
@ -9,6 +9,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
### Added
|
||||
|
||||
### Changed
|
||||
|
||||
### Removed
|
||||
|
||||
## [0.1.0] - 2024-10-01
|
||||
|
||||
### Added
|
||||
|
||||
- Subcommand `init` to initialize a new project
|
||||
- Creates a new project directory with default files
|
||||
- Subcommand `build` to build a project
|
||||
|
@ -16,9 +24,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Allows changing the output directory and setting a assets directory
|
||||
- Subcommand `clean` to clean the output directory
|
||||
- Subcommand `watch` to watch for changes and run a command
|
||||
- Subcommand `migrate` to migrate a datapack to a shulkerscript project
|
||||
- Subcommand `lang-debug` to debug the language parser
|
||||
- Allows to print the parsed tokens, AST and shulkerbox datapack representation
|
||||
|
||||
### Changed
|
||||
|
||||
### Removed
|
||||
[unreleased]: https://github.com/moritz-hoelting/shulkerscript-cli/compare/v0.1.0...HEAD
|
||||
[0.1.0]: https://github.com/moritz-hoelting/shulkerscript-cli/releases/tag/v0.1.0
|
|
@ -1171,7 +1171,8 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
|||
[[package]]
|
||||
name = "shulkerbox"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/moritz-hoelting/shulkerbox?rev=6e956fbe7438158c6a29c1a92d057f0f3093405a#6e956fbe7438158c6a29c1a92d057f0f3093405a"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18704338e25effa7d02ab8d83c453814a54163b66464693bb4aac0012f05db8b"
|
||||
dependencies = [
|
||||
"chksum-md5",
|
||||
"getset",
|
||||
|
@ -1183,7 +1184,8 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "shulkerscript"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/moritz-hoelting/shulkerscript-lang.git?rev=a9a8aff13b0ad0986ee1bdf3d44b74676385dfcd#a9a8aff13b0ad0986ee1bdf3d44b74676385dfcd"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1546b5164f154cb0ecb5b676d0f1beeb46b9417b785b2bc43b8e2d07caab01eb"
|
||||
dependencies = [
|
||||
"chksum-md5",
|
||||
"colored",
|
||||
|
|
|
@ -43,7 +43,7 @@ path-absolutize = "3.1.1"
|
|||
pathdiff = "0.2.1"
|
||||
serde = { version = "1.0.210", features = ["derive"] }
|
||||
serde_json = { version = "1.0.128", optional = true }
|
||||
shulkerscript = { git = "https://github.com/moritz-hoelting/shulkerscript-lang.git", features = ["fs_access", "shulkerbox", "zip"], default-features = false, rev = "a9a8aff13b0ad0986ee1bdf3d44b74676385dfcd" }
|
||||
shulkerscript = { version = "0.1.0", features = ["fs_access", "shulkerbox", "zip"], default-features = false }
|
||||
thiserror = "1.0.63"
|
||||
toml = "0.8.19"
|
||||
tracing = "0.1.40"
|
||||
|
|
22
README.md
22
README.md
|
@ -3,12 +3,30 @@
|
|||
This is a cli tool for the shulkerscript language. It can be used to initialize a new project, and to compile and package a project.
|
||||
|
||||
## Installation
|
||||
```bash
|
||||
cargo install --git https://github.com/moritz-hoelting/shulkerscript-cli.git
|
||||
|
||||
### From release (Windows)
|
||||
```powershell
|
||||
iex (iwr "https://raw.githubusercontent.com/moritz-hoelting/shulkerscript-cli/main/install.ps1").Content
|
||||
```
|
||||
|
||||
### From release (Linux / macOS)
|
||||
```bash
|
||||
curl -sfSL https://raw.githubusercontent.com/moritz-hoelting/shulkerscript-cli/main/install.sh | bash
|
||||
```
|
||||
|
||||
### From source
|
||||
```bash
|
||||
cargo install shulkerscript-cli
|
||||
```
|
||||
|
||||
## VS Code Extension
|
||||
|
||||
A VS Code extension is available [here](https://marketplace.visualstudio.com/items?itemName=moritz-hoelting.shulkerscript-lang) to provide syntax highlighting and snippets for Shulkerscript files.
|
||||
|
||||
## Usage
|
||||
|
||||
Read the [documentation](https://shulkerscript.hoelting.dev) for more information on the language and cli.
|
||||
|
||||
### Initialize a new project
|
||||
```bash
|
||||
shulkerscript init [OPTIONS] [PATH]
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
# Error setup
|
||||
$ErrorActionPreference = "Stop"
|
||||
Set-StrictMode -Version 3.0
|
||||
Set-PSDebug -Strict
|
||||
|
||||
# Variables
|
||||
$REPO = "moritz-hoelting/shulkerscript-cli"
|
||||
$PROGRAM_DISPLAY_NAME = "Shulkerscript CLI"
|
||||
$LATEST_RELEASE_URL = "https://api.github.com/repos/$REPO/releases/latest"
|
||||
$BIN_NAME = "shulkerscript"
|
||||
$INSTALL_PATH = Join-Path $env:USERPROFILE "AppData\Local\Programs\$BIN_NAME"
|
||||
$PATH_REGISTRY = "Registry::HKEY_CURRENT_USER\Environment"
|
||||
|
||||
function Remove-Old-Version {
|
||||
if ( (Test-Path variable:INSTALLED_VERSION) -and ($INSTALL_PATH -notlike "*\.cargo\bin*") ) {
|
||||
Write-Host Removing old version at $INSTALL_PATH
|
||||
Remove-Item -Path "$INSTALL_PATH" -Force -Recurse
|
||||
}
|
||||
}
|
||||
|
||||
# Determine the OS and architecture
|
||||
$OS = 'windows'
|
||||
$ARCH = $env:PROCESSOR_ARCHITECTURE
|
||||
|
||||
if ($ARCH -eq 'AMD64') {
|
||||
$ARCH = 'x86_64'
|
||||
} elseif ($ARCH -eq 'x86') {
|
||||
$ARCH = 'i686'
|
||||
} else {
|
||||
Write-Host "Unsupported architecture: $ARCH" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Fetch the latest release data from GitHub
|
||||
try {
|
||||
$LATEST_RELEASE_DATA = Invoke-RestMethod -Uri $LATEST_RELEASE_URL -Method Get
|
||||
}
|
||||
catch {
|
||||
Write-Host "Failed to fetch latest release data." -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Get the latest version number
|
||||
$LATEST_VERSION = $LATEST_RELEASE_DATA.tag_name
|
||||
|
||||
# Check if the CLI is already installed and get the current version
|
||||
if (Get-Command $BIN_NAME -ErrorAction Ignore) {
|
||||
$INSTALLED_VERSION = (& $BIN_NAME --version | Select-String -Pattern '\d+\.\d+\.\d+(-(rc|beta|alpha)(\.\d+)?)?' | Select-Object -First 1).Matches.Value
|
||||
$CLEAN_LATEST_VERSION = (Write-Output $LATEST_VERSION | Select-String -Pattern '\d+\.\d+\.\d+(-(rc|beta|alpha)(\.\d+)?)?').Matches.Value
|
||||
Write-Host "Installed version: v$INSTALLED_VERSION"
|
||||
Write-Host "Latest version: v$CLEAN_LATEST_VERSION"
|
||||
|
||||
if ($INSTALLED_VERSION -eq $CLEAN_LATEST_VERSION) {
|
||||
Write-Host "$PROGRAM_DISPLAY_NAME is already up to date."
|
||||
exit 0
|
||||
}
|
||||
else {
|
||||
Write-Host "A new version is available. Upgrading..."
|
||||
$INSTALL_PATH = Split-Path -Parent (Get-Command $BIN_NAME).Path
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-Host "$PROGRAM_DISPLAY_NAME is not installed. Installing version $LATEST_VERSION..."
|
||||
}
|
||||
|
||||
# Use cargo-binstall if available
|
||||
if (Get-Command cargo-binstall -ErrorAction SilentlyContinue) {
|
||||
Write-Host "cargo-binstall is available. Installing/upgrading using cargo-binstall..."
|
||||
cargo-binstall --git "https://github.com/$REPO" --force --locked --no-confirm $BIN_NAME
|
||||
Remove-Old-Version
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Get the download url of the latest release
|
||||
$DOWNLOAD_URL = ($LATEST_RELEASE_DATA.assets | Where-Object {$_.browser_download_url -match "$OS" -and $_.browser_download_url -match "$ARCH"} | Select-Object -First 1).browser_download_url
|
||||
|
||||
if ([string]::IsNullOrEmpty($DOWNLOAD_URL)) {
|
||||
# if there is no prebuilt binary, try to build from source
|
||||
if (Get-Command cargo -ErrorAction SilentlyContinue) {
|
||||
Write-Host "No prebuilt binary available for your platform. Building from source..."
|
||||
cargo install --git "https://github.com/$REPO" --force --locked
|
||||
Remove-Old-Version
|
||||
exit 0
|
||||
}
|
||||
else {
|
||||
Write-Host "No prebuilt binary available for your platform. Please install Rust and Cargo using https://rustup.rs and try again."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Create a temporary directory
|
||||
$TEMP = [System.IO.Path]::GetTempPath()
|
||||
$TEMP_DIR = Join-Path $TEMP (New-Guid).ToString("N")
|
||||
Remove-Item -Path "$TEMP_DIR" -Recurse -Force -ErrorAction Ignore | Out-Null
|
||||
New-Item -ItemType Directory -Path $TEMP_DIR | Out-Null
|
||||
|
||||
# Download and extract the binary
|
||||
Invoke-WebRequest -Uri $DOWNLOAD_URL -OutFile "$TEMP_DIR\$BIN_NAME.zip"
|
||||
Expand-Archive -Path "$TEMP_DIR\$BIN_NAME.zip" -DestinationPath $TEMP_DIR -Force
|
||||
|
||||
# Create install location and move binary
|
||||
New-Item -ItemType Directory -Path $INSTALL_PATH -Force | Out-Null
|
||||
Move-Item -Path "$TEMP_DIR\$BIN_NAME.exe" -Destination "$INSTALL_PATH\$BIN_NAME.exe" -Force
|
||||
|
||||
# Remove temp dir
|
||||
Remove-Item -Path "$TEMP_DIR" -Recurse -Force -ErrorAction Ignore | Out-Null
|
||||
|
||||
# Add binary to PATH
|
||||
$REGEX_INSTALL_PATH = [regex]::Escape($INSTALL_PATH)
|
||||
$ARR_PATH = $env:Path -split ';' | Where-Object {$_ -match "^$REGEX_INSTALL_PATH\\?"}
|
||||
if (-not $ARR_PATH) {
|
||||
Write-Host "Not found in current PATH, adding..."
|
||||
$OLD_PATH = (Get-ItemProperty -Path "$PATH_REGISTRY" -Name PATH).path
|
||||
$NEW_PATH = "$OLD_PATH;$INSTALL_PATH"
|
||||
Set-ItemProperty -Path "$PATH_REGISTRY" -Name PATH -Value $NEW_PATH
|
||||
$env:PATH="$NEW_PATH"
|
||||
}
|
||||
|
||||
Write-Host "$PROGRAM_DISPLAY_NAME has been successfully installed/upgraded to version $LATEST_VERSION."
|
|
@ -0,0 +1,97 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Error setup
|
||||
set -euo pipefail
|
||||
|
||||
# Variables
|
||||
REPO="moritz-hoelting/shulkerscript-cli"
|
||||
PROGRAM_DISPLAY_NAME="Shulkerscript CLI"
|
||||
LATEST_RELEASE_URL="https://api.github.com/repos/$REPO/releases/latest"
|
||||
BIN_NAME="shulkerscript"
|
||||
INSTALL_PATH="$HOME/bin/$BIN_NAME"
|
||||
|
||||
function removeOldVersion() {
|
||||
if [ ! -z ${INSTALLED_VERSION+x} ] && [[ $INSTALL_PATH != *"/.cargo/bin/"* ]]; then
|
||||
rm -f $INSTALL_PATH
|
||||
hash -d $BIN_NAME &> /dev/null || true
|
||||
fi
|
||||
}
|
||||
|
||||
# Determine the OS and architecture
|
||||
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||
ARCH=$(uname -m)
|
||||
|
||||
# Fetch the latest release data from GitHub
|
||||
LATEST_RELEASE_DATA=$(curl -s $LATEST_RELEASE_URL)
|
||||
|
||||
# Get the latest version number
|
||||
LATEST_VERSION=$(echo "$LATEST_RELEASE_DATA" | grep 'tag_name' | cut -d '"' -f 4)
|
||||
|
||||
# Check if the CLI is already installed and get the current version
|
||||
if which $BIN_NAME &> /dev/null; then
|
||||
INSTALLED_VERSION=$($BIN_NAME --version | grep -m 1 -oE '[0-9]+\.[0-9]+\.[0-9]+(-(rc|beta|alpha)(\.\d+)?)?')
|
||||
CLEAN_LATEST_VERSION=$(echo $LATEST_VERSION | grep -oE '[0-9]+\.[0-9]+\.[0-9]+(-(rc|beta|alpha)(\.\d+)?)?')
|
||||
echo "Installed version: v$INSTALLED_VERSION"
|
||||
echo "Latest version: v$CLEAN_LATEST_VERSION"
|
||||
|
||||
if [ "$INSTALLED_VERSION" == "$CLEAN_LATEST_VERSION" ]; then
|
||||
echo "$PROGRAM_DISPLAY_NAME is already up to date."
|
||||
exit 0
|
||||
else
|
||||
echo "A new version is available. Upgrading..."
|
||||
INSTALL_PATH=$(which $BIN_NAME)
|
||||
fi
|
||||
else
|
||||
echo "$PROGRAM_DISPLAY_NAME is not installed. Installing version $LATEST_VERSION..."
|
||||
fi
|
||||
|
||||
# Use cargo-binstall if available
|
||||
if which cargo-binstall &> /dev/null; then
|
||||
echo "Found cargo-binstall. Installing/upgrading using cargo-binstall..."
|
||||
cargo-binstall --git "https://github.com/$REPO" --force --locked --no-confirm $BIN_NAME
|
||||
|
||||
# Remove old version
|
||||
removeOldVersion
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Get the download url of the latest release
|
||||
DOWNLOAD_URL=$(echo "$LATEST_RELEASE_DATA" | awk "/browser_download_url/ && /$OS/ && /$ARCH/" | cut -d '"' -f 4)
|
||||
|
||||
if [ -z "$DOWNLOAD_URL" ]; then
|
||||
# if there is no prebuilt binary, try to build from source
|
||||
if which cargo &> /dev/null; then
|
||||
echo "No prebuilt binary available for your platform. Building from source..."
|
||||
cargo install --git "https://github.com/$REPO" --force --locked
|
||||
removeOldVersion
|
||||
exit 0
|
||||
else
|
||||
echo "No prebuilt binary available for your platform. Please install Rust and Cargo using https://rustup.rs and try again."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$DOWNLOAD_URL" == *"tar.gz" ]]; then
|
||||
ARCHIVE_TYPE="tar.gz"
|
||||
elif [[ "$DOWNLOAD_URL" == *"zip" ]]; then
|
||||
ARCHIVE_TYPE="zip"
|
||||
else
|
||||
echo "Unsupported archive type."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create a temporary directory
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
|
||||
# Download and extract the binary
|
||||
curl -L -s $DOWNLOAD_URL -o $TEMP_DIR/$BIN_NAME.$ARCHIVE_TYPE
|
||||
if [[ "$ARCHIVE_TYPE" == "tar.gz" ]]; then
|
||||
tar -xzf $TEMP_DIR/$BIN_NAME.$ARCHIVE_TYPE -C $TEMP_DIR
|
||||
else
|
||||
unzip $TEMP_DIR/$BIN_NAME.$ARCHIVE_TYPE -d $TEMP_DIR
|
||||
fi
|
||||
|
||||
chmod +x "$TEMP_DIR/$BIN_NAME"
|
||||
mv "$TEMP_DIR/$BIN_NAME" "$INSTALL_PATH"
|
||||
|
||||
echo "$PROGRAM_DISPLAY_NAME has been successfully installed/upgraded to version $LATEST_VERSION."
|
Loading…
Reference in New Issue