diff --git a/.github/workflows/ripunzip.yml b/.github/workflows/ripunzip.yml new file mode 100644 index 000000000..03d1b805a --- /dev/null +++ b/.github/workflows/ripunzip.yml @@ -0,0 +1,46 @@ +name: ripunzip +# version_tests: skip_readme + +on: [pull_request, workflow_dispatch] + +jobs: + alpine-musl: + if: ${{ vars.CURRENT_TOOL == github.workflow }} + uses: ./.github/workflows/build-alpine.yml + with: + workflow: ${{ github.workflow }} + + alpine-mingw: + if: ${{ vars.CURRENT_TOOL == github.workflow }} + uses: ./.github/workflows/build-alpine.yml + with: + workflow: ${{ github.workflow }} + toolset: mingw + + test-ubuntu: + needs: alpine-musl + uses: ./.github/workflows/test-ubuntu.yml + with: + workflow: ${{ github.workflow }} + artifact: build-musl + + test-windows: + needs: alpine-mingw + uses: ./.github/workflows/test-windows.yml + with: + workflow: ${{ github.workflow }} + artifact: build-mingw + + release: + needs: [test-ubuntu, + test-windows] + uses: ./.github/workflows/release.yml + with: + workflow: ${{ github.workflow }} + tool_version: '0.4.0' + prepare_body: | + bsdtar -Oxf ./build-musl/build-musl.tar.gz build-musl.md >> body.md + bsdtar -Oxf ./build-mingw/build-mingw.tar.gz build-mingw.md >> body.md + artifacts: ./build-musl/build-musl.tar.gz,./build-mingw/build-mingw.tar.gz + secrets: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/ripunzip/build_mingw.sh b/ripunzip/build_mingw.sh new file mode 100755 index 000000000..f9d3aace6 --- /dev/null +++ b/ripunzip/build_mingw.sh @@ -0,0 +1,51 @@ +#!/bin/bash +dp0="$(realpath "$(dirname "$0")")" +set -e + +echo "::group::install deps" + +apk update +apk add --no-cache alpine-sdk musl-dev gcc curl wget rustup pkgconfig openssl-dev mingw-w64-gcc + +rustup-init -y +. "$HOME/.cargo/env" +rustup target add x86_64-pc-windows-gnu + +echo "::endgroup::" + +tool_name="ripunzip" +tool_version="0.4.0" +self_name="$tool_name-$tool_version" +self_toolset_name="build-mingw" +release_version_dirpath="$dp0/release/$self_name" + +mkdir -p "$release_version_dirpath" && cd "$dp0/release" + +download_url="https://github.com/google/ripunzip/archive/refs/heads/main.tar.gz" +echo "::group::prepare sources $download_url" + +"$dp0/../.tools/download_bsdtar.sh" +bsdtar="$dp0/release/bsdtar" + +wget "$download_url" -O "tool-$tool_version.tar.gz" +"$bsdtar" -xf "tool-$tool_version.tar.gz" && cd "$tool_name-main" + +cargo build --target x86_64-pc-windows-gnu --release + +cp -f "./target/x86_64-pc-windows-gnu/release/$tool_name.exe" "$release_version_dirpath/" + +echo "::endgroup::" + +cd "$release_version_dirpath" + +strip "$tool_name.exe" + +{ printf '### %s +SHA-256: %s + +' "$self_toolset_name.tar.gz" "$(sha256sum $tool_name.exe)" +} > "$self_toolset_name.md" + +cat "$self_toolset_name.md" + +tar -czvf "../$self_toolset_name.tar.gz" . diff --git a/ripunzip/build_musl.sh b/ripunzip/build_musl.sh new file mode 100755 index 000000000..2a7dd1e42 --- /dev/null +++ b/ripunzip/build_musl.sh @@ -0,0 +1,52 @@ +#!/bin/bash +dp0="$(realpath "$(dirname "$0")")" +set -e + +echo "::group::install deps" + +apk update +apk add --no-cache alpine-sdk musl-dev gcc curl wget rustup pkgconfig openssl-dev + +rustup-init -y +. "$HOME/.cargo/env" + +echo "::endgroup::" + +tool_name="ripunzip" +tool_version="0.4.0" +self_name="$tool_name-$tool_version" +self_toolset_name="build-musl" +release_version_dirpath="$dp0/release/$self_name" + +mkdir -p "$release_version_dirpath" && cd "$dp0/release" + +download_url="https://github.com/google/ripunzip/archive/refs/heads/main.tar.gz" +echo "::group::prepare sources $download_url" + +"$dp0/../.tools/download_bsdtar.sh" +bsdtar="$dp0/release/bsdtar" + +wget "$download_url" -O "tool-$tool_version.tar.gz" +"$bsdtar" -xf "tool-$tool_version.tar.gz" && cd "$tool_name-main" + +cargo build --target x86_64-unknown-linux-musl --release + +cp -f "./target/x86_64-unknown-linux-musl/release/$tool_name" "$release_version_dirpath/" + +echo "::endgroup::" + +cd "$release_version_dirpath" +strip "$tool_name" +chmod +x "$tool_name" + +{ printf '%s + +### %s +SHA-256: %s + +' "$("./$tool_name" --version)" "$self_toolset_name.tar.gz" "$(sha256sum $tool_name)" +} > "$self_toolset_name.md" + +cat "$self_toolset_name.md" + +tar -czvf "../$self_toolset_name.tar.gz" . diff --git a/ripunzip/test_linux.sh b/ripunzip/test_linux.sh new file mode 100755 index 000000000..e488910a0 --- /dev/null +++ b/ripunzip/test_linux.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +testVersion() { + assertEquals "ripunzip 0.4.0" "$(../bin/ripunzip --version)" +} + +# Load and run shUnit2. +source "../.tests/shunit2/shunit2" diff --git a/ripunzip/test_windows.sh b/ripunzip/test_windows.sh new file mode 100755 index 000000000..1dac186a7 --- /dev/null +++ b/ripunzip/test_windows.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +testVersion() { + assertEquals "ripunzip 0.4.0" "$(../bin/ripunzip.exe --version)" +} + +# Load and run shUnit2. +source "../.tests/shunit2/shunit2"