Skip to content

Commit

Permalink
Merge branch 'release/1.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
coord-e committed Jun 19, 2022
2 parents 93f4461 + 55cc974 commit 9fa27eb
Show file tree
Hide file tree
Showing 17 changed files with 394 additions and 259 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-gnu-gcc"
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
50 changes: 37 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,77 @@ jobs:
test:
name: Test
runs-on: ubuntu-20.04
strategy:
matrix:
target:
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
steps:
- uses: actions/checkout@v2
- run: sudo apt-get install -y musl-tools busybox-static
- run: sudo apt-get install -y gcc-aarch64-linux-gnu
if: matrix.target == 'aarch64-unknown-linux-musl'
- run: rustup target add ${{ matrix.target }}
- uses: actions/cache@v2
with:
path: |
target/
~/.cargo/git/db/
~/.cargo/registry/cache/
~/.cargo/registry/index/
key: "${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}"
key: "${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}"
- uses: actions-rs/cargo@v1
with:
command: build
args: --release --all-features --target=x86_64-unknown-linux-musl
args: --release --all-features --target=${{ matrix.target }}
- uses: actions/upload-artifact@v2
with:
name: musl-executable-${{ matrix.target }}
path: ./target/${{ matrix.target }}/release/magicpak
- uses: actions-rs/cargo@v1
with:
command: test
args: --release --all-features --target=x86_64-unknown-linux-musl
- uses: actions/upload-artifact@v2
with:
name: musl-executable
path: ./target/x86_64-unknown-linux-musl/release/magicpak
args: --release --all-features --target=${{ matrix.target }}
if: matrix.target == 'x86_64-unknown-linux-musl' # TODO: test aarch64
build_docker_images:
name: Build and push docker images
runs-on: ubuntu-20.04
needs: test
steps:
- name: Free up disk space
run: sudo rm -rf /usr/share/dotnet /usr/local/lib/android
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: musl-executable
name: musl-executable-x86_64-unknown-linux-musl
- run: mkdir -p dist/amd64 && mv ./magicpak ./dist/amd64/magicpak
- uses: actions/download-artifact@v2
with:
name: musl-executable-aarch64-unknown-linux-musl
- run: mkdir -p dist/arm64 && mv ./magicpak ./dist/arm64/magicpak
- uses: docker/setup-qemu-action@v2
with:
platforms: arm64
- run: docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} -p ${{ secrets.DOCKER_HUB_PASSWORD }}
- uses: docker/setup-buildx-action@v1
- run: ./dockerfile/build.sh ./magicpak
- run: docker buildx bake --push --set '*.cache-from=type=gha' --set '*.cache-to=type=gha,mode=max'
env:
PUSH_IMAGES: true
DOCKER_BUILD: "docker buildx build --load --cache-from type=gha --cache-to type=gha,mode=max"
BIN_DIR: "./dist"
VERSION: "1.3.1"
release:
name: Release
runs-on: ubuntu-20.04
needs: build_docker_images
strategy:
matrix:
target:
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
steps:
- uses: actions/download-artifact@v2
with:
name: musl-executable
- run: mv magicpak magicpak-x86_64-unknown-linux-musl
name: musl-executable-${{ matrix.target }}
- run: mv magicpak magicpak-${{ matrix.target }}
- uses: softprops/action-gh-release@v1
with:
files: magicpak-*
Expand Down
35 changes: 16 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,36 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
target: [x86_64-unknown-linux-musl]
target:
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
steps:
- uses: actions/checkout@v2
- run: sudo apt-get install -y musl-tools busybox-static
- run: sudo apt-get install -y gcc-aarch64-linux-gnu
if: matrix.target == 'aarch64-unknown-linux-musl'
- run: rustup target add ${{ matrix.target }}
- uses: actions/cache@v2
with:
path: |
target/
~/.cargo/git/db/
~/.cargo/registry/cache/
~/.cargo/registry/index/
key: "${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}"
key: "${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}"
- uses: actions-rs/cargo@v1
with:
command: build
args: --release --all-features --target=${{ matrix.target }}
- uses: actions/upload-artifact@v2
with:
name: musl-executable
path: ./target/x86_64-unknown-linux-musl/release/magicpak
if: matrix.target == 'x86_64-unknown-linux-musl'
name: musl-executable-${{ matrix.target }}
path: ./target/${{ matrix.target }}/release/magicpak
- uses: actions-rs/cargo@v1
with:
command: test
args: --release --all-features --target=${{ matrix.target }}
if: matrix.target == 'x86_64-unknown-linux-musl' # TODO: test aarch64
fmt:
name: Rustfmt
runs-on: ubuntu-20.04
Expand All @@ -59,19 +64,11 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: musl-executable
name: musl-executable-x86_64-unknown-linux-musl
- run: mkdir -p dist/amd64 && mv ./magicpak ./dist/amd64/magicpak
- uses: docker/setup-buildx-action@v1
- name: Build docker images
env:
IMAGE_PREFIX: test-magicpak/
PUSH_IMAGES: false
DOCKER_BUILD: "docker buildx build --load --cache-from type=gha --cache-to type=gha,mode=max"
run: |
for example in ./example/*; do
sed -e 's/FROM magicpak/FROM test-magicpak/' -i "$example/Dockerfile"
grep 'FROM magicpak' "$example/Dockerfile" && exit 1 || true
IMAGE=$(head -1 "$example/Dockerfile" | sed -e 's/FROM \(.*\)/\1/')
IMAGE_FILTER=$IMAGE ./dockerfile/build.sh ./magicpak
done
- name: Build examples
run: for example in ./example/*; do docker build "$example"; done
run: docker buildx bake --set '*.cache-from=type=gha' --set '*.cache-to=type=gha,mode=max' --set 'base.platform=linux/amd64' example
env:
BIN_DIR: ./dist
VERSION: 1.3.1
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/target
**/*.rs.bk

docker-bake.override.hcl
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to this project will be documented in this file.

## [1.3.1] - 2022-06-19

- AArch64 support ([#14](https://github.com/coord-e/magicpak/pull/14))
- Use docker buildx bake to build container images ([#15](https://github.com/coord-e/magicpak/pull/15))

## [1.3.0] - 2022-01-11

- Fix busybox_jail_path file permissions ([#6](https://github.com/coord-e/magicpak/pull/6))
Expand Down
2 changes: 1 addition & 1 deletion 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,6 +1,6 @@
[package]
name = "magicpak"
version = "1.3.0"
version = "1.3.1"
authors = ["coord_e <me@coord-e.com>"]
edition = "2021"
license = "MIT OR Apache-2.0"
Expand Down
9 changes: 5 additions & 4 deletions dockerfile/debian/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
ARG BASE_IMAGE
FROM ${BASE_IMAGE}

ARG DEBIAN_PACKAGES
ARG APT_PACKAGES
RUN DEBIAN_FRONTEND=noninteractive \
apt-get update -y \
&& apt-get install -y --no-install-recommends gcc libc-dev xz-utils busybox-static ${DEBIAN_PACKAGES} \
&& apt-get install -y --no-install-recommends gcc libc-dev xz-utils busybox-static ${APT_PACKAGES} \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

ARG UPX_VERSION
ARG MAGICPAK_PATH
ARG MAGICPAK_DIR
ARG TARGETARCH

ADD https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-amd64_linux.tar.xz /tmp/upx.tar.xz
RUN cd /tmp \
&& tar --strip-components=1 -xf upx.tar.xz \
&& mv upx /bin/ \
&& rm upx.tar.xz

COPY ${MAGICPAK_PATH} /bin/magicpak
COPY $MAGICPAK_DIR/$TARGETARCH/magicpak /bin/magicpak
RUN chmod +x /bin/magicpak
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
```dockerfile
# You prepare /bin/your_executable here...

ADD https://github.com/coord-e/magicpak/releases/download/v1.3.0/magicpak-x86_64-unknown-linux-musl /usr/bin/magicpak
ADD https://github.com/coord-e/magicpak/releases/download/v1.3.1/magicpak-x86_64-unknown-linux-musl /usr/bin/magicpak
RUN chmod +x /usr/bin/magicpak

RUN /usr/bin/magicpak -v /bin/your_executable /bundle
Expand Down Expand Up @@ -94,7 +94,7 @@ We provide some base images that contain `magicpak` and its optional dependencie
The following is a dockerfile using `magicpak` for a docker image of [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html), a formatter for C/C++/etc. ([example/clang-format](/example/clang-format))

```dockerfile
FROM magicpak/debian:buster-magicpak1.3.0
FROM magicpak/debian:buster-magicpak1.3.1

RUN apt-get -y update
RUN apt-get -y --no-install-recommends install clang-format
Expand Down
Loading

0 comments on commit 9fa27eb

Please sign in to comment.