Skip to content

Commit

Permalink
ripunzip.yml (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
hemnstill authored Jul 25, 2023
1 parent 4630e70 commit 096bac3
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/ripunzip.yml
Original file line number Diff line number Diff line change
@@ -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 }}
51 changes: 51 additions & 0 deletions ripunzip/build_mingw.sh
Original file line number Diff line number Diff line change
@@ -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" .
52 changes: 52 additions & 0 deletions ripunzip/build_musl.sh
Original file line number Diff line number Diff line change
@@ -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" .
8 changes: 8 additions & 0 deletions ripunzip/test_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

testVersion() {
assertEquals "ripunzip 0.4.0" "$(../bin/ripunzip --version)"
}

# Load and run shUnit2.
source "../.tests/shunit2/shunit2"
8 changes: 8 additions & 0 deletions ripunzip/test_windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

testVersion() {
assertEquals "ripunzip 0.4.0" "$(../bin/ripunzip.exe --version)"
}

# Load and run shUnit2.
source "../.tests/shunit2/shunit2"

0 comments on commit 096bac3

Please sign in to comment.