Skip to content

Commit

Permalink
compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Dec 6, 2023
1 parent 019fe14 commit 672f447
Show file tree
Hide file tree
Showing 13 changed files with 200 additions and 179 deletions.
11 changes: 8 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
[*.sh]
indent_style = tab
[*.toml]
indent_style = space
indent_size = 2

[Cargo.toml]
[*.sh]
indent_style = space
indent_size = 2

# shfmt
switch_case_indent = true
simplify = true
10 changes: 10 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,18 @@ jobs:
name: macos-arm64
target: aarch64-apple-darwin
runs-on: macos-12
- os: macos
name: macos
target: universal2-apple-darwin
runs-on: macos-12
steps:
- uses: actions/checkout@v4
- run: |
brew install zig
rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin
cargo install cargo-zigbuild
if: matrix.target == 'universal2-apple-darwin'
- run: sudo apt-get update; sudo apt-get install musl-tools
if: matrix.runs-on == 'buildjet-4vcpu-ubuntu-2204-arm'
- run: rustup target add ${{matrix.target}}
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/rtx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ jobs:
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- uses: Swatinem/rust-cache@v2
with:
shared-key: test
Expand Down
40 changes: 20 additions & 20 deletions scripts/build-deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@ touch rtx/lib/.disable-self-update

tar -xvJf "dist/rtx-$RTX_VERSION-linux-x64.tar.xz"
fpm -s dir -t deb \
--name rtx \
--license MIT \
--version "${RTX_VERSION#v*}" \
--architecture amd64 \
--description "Polyglot runtime manager" \
--url "https://github.com/jdx/rtx" \
--maintainer "Jeff Dickey @jdx" \
rtx/bin/rtx=/usr/bin/rtx \
rtx/lib/.disable-self-update=/usr/lib/rtx/.disable-self-update \
rtx/man/man1/rtx.1=/usr/share/man/man1/rtx.1
--name rtx \
--license MIT \
--version "${RTX_VERSION#v*}" \
--architecture amd64 \
--description "Polyglot runtime manager" \
--url "https://github.com/jdx/rtx" \
--maintainer "Jeff Dickey @jdx" \
rtx/bin/rtx=/usr/bin/rtx \
rtx/lib/.disable-self-update=/usr/lib/rtx/.disable-self-update \
rtx/man/man1/rtx.1=/usr/share/man/man1/rtx.1

tar -xvJf "dist/rtx-$RTX_VERSION-linux-arm64.tar.xz"
fpm -s dir -t deb \
--name rtx \
--license MIT \
--version "${RTX_VERSION#v*}" \
--architecture arm64 \
--description "Polyglot runtime manager" \
--url "https://github.com/jdx/rtx" \
--maintainer "Jeff Dickey @jdx" \
rtx/bin/rtx=/usr/bin/rtx \
rtx/lib/.disable-self-update=/usr/lib/rtx/.disable-self-update \
rtx/man/man1/rtx.1=/usr/share/man/man1/rtx.1
--name rtx \
--license MIT \
--version "${RTX_VERSION#v*}" \
--architecture arm64 \
--description "Polyglot runtime manager" \
--url "https://github.com/jdx/rtx" \
--maintainer "Jeff Dickey @jdx" \
rtx/bin/rtx=/usr/bin/rtx \
rtx/lib/.disable-self-update=/usr/lib/rtx/.disable-self-update \
rtx/man/man1/rtx.1=/usr/share/man/man1/rtx.1

mkdir -p dist/deb/pool/main
cp -v ./*.deb dist/deb/pool/main
Expand Down
40 changes: 20 additions & 20 deletions scripts/build-rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@ touch rtx/lib/.disable-self-update

tar -xvJf "dist/rtx-$RTX_VERSION-linux-x64.tar.xz"
fpm -s dir -t rpm \
--name rtx \
--license MIT \
--version "${RTX_VERSION#v*}" \
--architecture x86_64 \
--description "Polyglot runtime manager" \
--url "https://github.com/jdx/rtx" \
--maintainer "Jeff Dickey @jdx" \
rtx/bin/rtx=/usr/bin/rtx \
rtx/lib/.disable-self-update=/usr/lib/rtx/.disable-self-update \
rtx/man/man1/rtx.1=/usr/share/man/man1/rtx.1
--name rtx \
--license MIT \
--version "${RTX_VERSION#v*}" \
--architecture x86_64 \
--description "Polyglot runtime manager" \
--url "https://github.com/jdx/rtx" \
--maintainer "Jeff Dickey @jdx" \
rtx/bin/rtx=/usr/bin/rtx \
rtx/lib/.disable-self-update=/usr/lib/rtx/.disable-self-update \
rtx/man/man1/rtx.1=/usr/share/man/man1/rtx.1

tar -xvJf "dist/rtx-$RTX_VERSION-linux-arm64.tar.xz"
fpm -s dir -t rpm \
--name rtx \
--license MIT \
--version "${RTX_VERSION#v*}" \
--architecture aarch64 \
--description "Polyglot runtime manager" \
--url "https://github.com/jdx/rtx" \
--maintainer "Jeff Dickey @jdx" \
rtx/bin/rtx=/usr/bin/rtx \
rtx/lib/.disable-self-update=/usr/lib/rtx/.disable-self-update \
rtx/man/man1/rtx.1=/usr/share/man/man1/rtx.1
--name rtx \
--license MIT \
--version "${RTX_VERSION#v*}" \
--architecture aarch64 \
--description "Polyglot runtime manager" \
--url "https://github.com/jdx/rtx" \
--maintainer "Jeff Dickey @jdx" \
rtx/bin/rtx=/usr/bin/rtx \
rtx/lib/.disable-self-update=/usr/lib/rtx/.disable-self-update \
rtx/man/man1/rtx.1=/usr/share/man/man1/rtx.1

cat <<EOF >~/.rpmmacros
%_signature gpg
Expand Down
108 changes: 55 additions & 53 deletions scripts/build-tarball.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,72 @@
set -euo pipefail

error() {
echo "$@" >&2
exit 1
echo "$@" >&2
exit 1
}

NAME="$1"
shift

for arg in "$@"; do
if [ "${next_target:-}" = 1 ]; then
next_target=
TARGET="$arg"
continue
fi
case "$arg" in
--target)
next_target=1
;;
*) ;;
if [ "${next_target:-}" = 1 ]; then
next_target=
TARGET="$arg"
continue
fi
case "$arg" in
--target)
next_target=1
;;
*) ;;

esac
esac
done

RUST_TRIPLE=${TARGET:-$(rustc -vV | grep ^host: | cut -d ' ' -f2)}
#region os/arch
get_os() {
case "$RUST_TRIPLE" in
*-apple-darwin*)
echo "macos"
;;
*-linux-*)
echo "linux"
;;
*)
error "unsupported OS: $RUST_TRIPLE"
;;
esac
case "$RUST_TRIPLE" in
*-apple-darwin*)
echo "macos"
;;
*-linux-*)
echo "linux"
;;
*)
error "unsupported OS: $RUST_TRIPLE"
;;
esac
}

get_arch() {
case "$RUST_TRIPLE" in
aarch64-*)
echo "arm64"
;;
arm-*)
echo "armv6"
;;
armv7-*)
echo "armv7"
;;
x86_64-*)
echo "x64"
;;
*)
error "unsupported arch: $RUST_TRIPLE"
;;
esac
case "$RUST_TRIPLE" in
aarch64-*)
echo "arm64"
;;
arm-*)
echo "armv6"
;;
armv7-*)
echo "armv7"
;;
x86_64-*)
echo "x64"
;;
*)
error "unsupported arch: $RUST_TRIPLE"
;;
esac
}
get_suffix() {
case "$RUST_TRIPLE" in
*-musl | *-musleabi | *-musleabihf)
echo "-musl"
;;
*)
echo ""
;;
esac
case "$RUST_TRIPLE" in
*-musl | *-musleabi | *-musleabihf)
echo "-musl"
;;
*)
echo ""
;;
esac
}
#endregion

Expand All @@ -76,9 +76,11 @@ VERSION=$(./scripts/get-version.sh)
BASENAME=$NAME-$VERSION-$(get_os)-$(get_arch)$(get_suffix)

if command -v cross >/dev/null; then
cross build "$@"
cross build "$@"
elif command -v zig >/dev/null; then
cargo zigbuild "$@"
else
cargo build "$@"
cargo build "$@"
fi
mkdir -p dist/rtx/bin
mkdir -p dist/rtx/man/man1
Expand All @@ -94,8 +96,8 @@ tar -cJf "$BASENAME.tar.xz" rtx
tar -czf "$BASENAME.tar.gz" rtx

if [ -f ~/.zipsign/rtx.priv ]; then
zipsign sign tar "$BASENAME.tar.gz" ~/.zipsign/rtx.priv
zipsign verify tar "$BASENAME.tar.gz" ../zipsign.pub
zipsign sign tar "$BASENAME.tar.gz" ~/.zipsign/rtx.priv
zipsign verify tar "$BASENAME.tar.gz" ../zipsign.pub
fi

ls -oh "$BASENAME.tar.xz"
4 changes: 2 additions & 2 deletions scripts/pre-release-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
set -euxo pipefail

if [[ "${NO_UPDATE:-}" == "1" ]]; then
echo "NO_UPDATE is set, skipping update"
echo "NO_UPDATE is set, skipping update"
else
cargo update && git add Cargo.lock
cargo update && git add Cargo.lock
fi

just render-mangen render-help
Expand Down
6 changes: 3 additions & 3 deletions scripts/publish-s3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ aws s3 cp artifacts/deb/dists/ "s3://$AWS_S3_BUCKET/deb/dists/" --cache-control
export CLOUDFLARE_ACCOUNT_ID=6e243906ff257b965bcae8025c2fc344
export CLOUDFLARE_ZONE_ID=80d977fd09f01db52bec165778088891
curl --fail-with-body -X POST "https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE_ID/purge_cache" \
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
-H "Content-Type: application/json" \
--data '{ "purge_everything": true }'
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
-H "Content-Type: application/json" \
--data '{ "purge_everything": true }'
Loading

0 comments on commit 672f447

Please sign in to comment.