diff --git a/sbnf/sbnf-linux-universal.sh b/package_control/sbnf-linux-universal.sh similarity index 100% rename from sbnf/sbnf-linux-universal.sh rename to package_control/sbnf-linux-universal.sh diff --git a/sbnf/sbnf-windows-universal.bat b/package_control/sbnf-windows-universal.bat similarity index 100% rename from sbnf/sbnf-windows-universal.bat rename to package_control/sbnf-windows-universal.bat diff --git a/sbnf/sbnf.sublime-build-release b/package_control/sbnf.sublime-build similarity index 100% rename from sbnf/sbnf.sublime-build-release rename to package_control/sbnf.sublime-build diff --git a/release.sh b/release.sh index 3fb535b..e39d2f0 100755 --- a/release.sh +++ b/release.sh @@ -31,6 +31,11 @@ if ! type cross >/dev/null 2>&1; then exit 1 fi +if ! type gh >/dev/null 2>&1; then + echo "'gh' not installed" + exit 1 +fi + # Make sure we've got git setup right CURRENT_BRANCH=$(git branch --show-current) if [ "$CURRENT_BRANCH" != 'master' ]; then @@ -45,13 +50,6 @@ if [[ -z "$WEB_PATH" ]]; then WEB_PATH="gh-pages" fi -RELEASE_PATH=$(git worktree list | grep -F "package" | awk '{print $1}') -if [[ -z "$RELEASE_PATH" ]]; then - echo "Creating package worktree" - git worktree add package package - RELEASE_PATH="package" -fi - echo "All checks passed" cargo set-version "$VERSION" @@ -60,6 +58,8 @@ if [[ $PART == 'all' || $PART == 'package' ]]; then rm -rf target/sublime-package mkdir target/sublime-package + ARTIFACTS=() + # Compile CLI for all platforms TARGETS=( "x86_64-unknown-linux-gnu" @@ -74,33 +74,76 @@ if [[ $PART == 'all' || $PART == 'package' ]]; then if [[ "$TARGET" == *windows* ]]; then cp target/$TARGET/release/sbnf.exe target/sublime-package/sbnf-$TARGET.exe + + zip -FS -Dj "target/sbnf-$TARGET.zip" target/$TARGET/release/sbnf.exe + ARTIFACTS+=("target/sbnf-$TARGET.zip") elif [[ "$TARGET" == *linux* ]]; then cp target/$TARGET/release/sbnf target/sublime-package/sbnf-$TARGET + + tar -cJf "target/sbnf-$TARGET.tar.xz" -C target/$TARGET/release sbnf + ARTIFACTS+=("target/sbnf-$TARGET.tar.xz") + elif [[ "$TARGET" == *apple* ]]; then + zip -FS -Dj "target/sbnf-$TARGET.zip" target/$TARGET/release/sbnf + ARTIFACTS+=("target/sbnf-$TARGET.zip") fi done # Make universal binary for macOS - llvm-lipo-14 -create -output target/sublime-package/sbnf-universal-apple-darwin \ + mkdir -p target/universal-apple-darwin + llvm-lipo-14 -create -output target/universal-apple-darwin/sbnf \ target/x86_64-apple-darwin/release/sbnf target/aarch64-apple-darwin/release/sbnf + cp target/universal-apple-darwin/sbnf target/sublime-package/sbnf-universal-apple-darwin + + zip -FS -Dj "target/sbnf-universal-apple-darwin.zip" target/universal-apple-darwin/sbnf + ARTIFACTS+=("target/sbnf-universal-apple-darwin.zip") + # Compile SBNF syntax cargo run --release -- sbnf/sbnf.sbnf -o target/sublime-package/sbnf.sublime-syntax # Copy other files SYNTAX_SOURCES=( - "Comments.tmPreferences" - "sbnf.sublime-completions" - "sbnf.sublime-settings" - "sbnf-linux-universal.sh" - "sbnf-windows-universal.bat" - "sbnf.sublime-settings" - "Symbol Index.tmPreferences" + "package_control/sbnf-linux-universal.sh" + "package_control/sbnf-windows-universal.bat" + "package_control/sbnf.sublime-build" + "sbnf/Comments.tmPreferences" + "sbnf/sbnf.sublime-completions" + "sbnf/sbnf.sublime-settings" + "sbnf/sbnf.sublime-settings" + "sbnf/Symbol Index.tmPreferences" ) for F in "${SYNTAX_SOURCES[@]}"; do - cp "sbnf/$F" target/sublime-package/ + cp "$F" target/sublime-package/ done - cp sbnf/sbnf.sublime-build-release target/sublime-package/sbnf.sublime-build touch target/sublime-package/.no-sublime-package + + cd target/sublime-package + zip -FS -r ../SBNF.sublime-package * + cd - + ARTIFACTS+=("target/SBNF.sublime-package") + + cat >package_control/packages.json <4077", + "version": "$VERSION", + "url": "https://github.com/BenjaminSchaaf/sbnf/releases/download/$VERSION/SBNF.sublime-package", + "date": "$(date -u "+%Y-%m-%d %H:%M:%S")" + } + ] + }, + ] +} +EOF fi if [[ $PART == 'all' || $PART == 'website' ]]; then @@ -108,28 +151,16 @@ if [[ $PART == 'all' || $PART == 'website' ]]; then python3 wasm/build-playground.py --release "$WEB_PATH" fi -if [[ $PART == 'all' || $PART == 'package' ]]; then - # Copy package to release worktree - rsync -a --delete --exclude=.git target/sublime-package/ "$RELEASE_PATH" -fi - # Prepare Release -if [[ $PART == 'all' || $PART == 'crate' ]]; then - git status +if [[ $PART == 'all' || $PART == 'crate' || $PART == 'package' ]]; then + git add package_control/packages.json git add Cargo.toml git add Cargo.lock git add cli/Cargo.toml git add wasm/Cargo.toml - git commit -m "Release $VERSION" -fi - -if [[ $PART == 'all' || $PART == 'package' ]]; then - cd "$RELEASE_PATH" - git add -A git status git commit -m "Release $VERSION" git tag "$VERSION" - cd - fi if [[ $PART == 'all' || $PART == 'website' ]]; then @@ -145,19 +176,20 @@ echo "Release Prepared" read -p "Do you want to continue? (y/Y): " CONFIRMATION if [[ $CONFIRMATION == 'y' || $CONFIRMATION == 'Y' ]]; then + if [[ $PART == 'all' || $PART == 'package' ]]; then + git push origin "$VERSION" + + gh release create "$VERSION" "${ARTIFACTS[@]}" + + # Push master after release to make sure packages.json is always valid + git push origin master + fi + if [[ $PART == 'all' || $PART == 'crate' ]]; then - git push cargo publish -p sbnf cargo publish -p sbnfc fi - if [[ $PART == 'all' || $PART == 'package' ]]; then - cd "$RELEASE_PATH" - git push - git push origin "$VERSION" - cd - - fi - if [[ $PART == 'all' || $PART == 'website' ]]; then cd "$WEB_PATH" git push