Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: CI/CD

on:
push:
tags: [ '*.*.*' ]
branches: [ '*' ]
pull_request:
branches: [ master ]
release:
types: [ published ]

permissions:
contents: write
id-token: write
packages: write

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Setup environment
run: |
git submodule init
git submodule update

- name: Build
run: |
mkdir ./public-build
docker build --target mpq-extractor-debian -t mpq-extractor-debian .
docker cp $(docker create mpq-extractor-debian):/usr/local/bin/MPQExtractor ./public-build/MPQExtractor

- name: '"Test"'
run: |
{
echo '```'
# todo replace with `docker run --rm --entrypoint 'bash -c "cmake /src && make tests"' mpq-extractor-builder-debian` in future,
# now just "print help" to prove this thing working.
docker run --rm mpq-extractor-debian -h
echo '```'
} > "$GITHUB_STEP_SUMMARY"

- name: Save Docker Image to File
run: docker save -o mpq-extractor-debian.tar mpq-extractor-debian

- name: Upload Image Artifact
uses: actions/upload-artifact@v4
with:
name: docker-image
path: mpq-extractor-debian.tar

- name: Upload Binary Artifact
uses: actions/upload-artifact@v4
with:
name: public-build-artifact
path: ./public-build/

publish:
name: Publish
runs-on: ubuntu-latest
needs: [build]
if: startsWith(github.ref, 'refs/tags/')

steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Download Image Artifact (Docker Image)
uses: actions/download-artifact@v4
with:
name: docker-image

- name: Load Image and Push to GHCR
run: |
docker load -i mpq-extractor-debian.tar

docker tag mpq-extractor-debian ghcr.io/${{ github.repository_owner }}/mpq-extractor-debian:${{ github.ref_name }}
docker tag mpq-extractor-debian ghcr.io/${{ github.repository_owner }}/mpq-extractor-debian:latest
docker push ghcr.io/${{ github.repository_owner }}/mpq-extractor-debian:${{ github.ref_name }}
docker push ghcr.io/${{ github.repository_owner }}/mpq-extractor-debian:latest

- name: Download Binary Artifact (MPQExtractor)
uses: actions/download-artifact@v4
with:
name: public-build-artifact

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: MPQExtractor
generate_release_notes: true
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM debian:trixie-slim AS mpq-extractor-builder-debian
RUN <<EOF
set -eux
apt-get update
apt-get install -y --no-install-recommends --no-install-suggests build-essential zlib1g-dev libbz2-dev cmake
rm -rf /var/lib/apt/lists/*
EOF

COPY . /src

RUN <<EOF
set -eux
mkdir /build
cd /build
cmake /src
cmake --build .
EOF

WORKDIR /build

ENTRYPOINT ["/bin/bash"]

ENV PATH=/build/bin:$PATH

FROM debian:trixie-slim AS mpq-extractor-debian

COPY --from=mpq-extractor-builder-debian /build/bin/MPQExtractor /usr/local/bin

WORKDIR /opt/data

ENTRYPOINT ["/usr/local/bin/MPQExtractor"]
75 changes: 73 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A command-line tool to extract files from MPQ archives (used by Blizzard games).

Works on MacOS X, Linux and Windows.
Works on macOS, Linux and Windows.


## IN CASE OF ERROR (COMPILATION PROBLEMS / EXTRACTION ISSUES)
Expand Down Expand Up @@ -177,10 +177,81 @@ inside the MPQ archive:**
$ ls out/
world/

## Usage with Docker

1\. Initialize submodule dependencies

```sh
git submodule init
git submodule update
```

2\. Build docker image

```sh
docker build --target mpq-extractor-debian -t mpq-extractor-debian .
```

> [!NOTE]
> Typically, building `mpq-extractor-debian` image is required only once.
> This image will contain only the built `MPQExtractor` binary,
> without build tools like `gcc` or `make`.
> Compilation process itself occurs inside the `mpq-extractor-builder-debian` container.
> Such design is used to get optimal image.

> [!TIP]
> When it's required to play with compilation interactively, such command may be used:
>
> ```sh
> docker build --target mpq-extractor-builder-debian -t mpq-extractor-builder-debian .
> docker run -it --rm --volume "$PWD:/src" --entrypoint '/bin/bash' mpq-extractor-builder-debian
> # ... do something inside the container, for example `cmake /src`
> ```

3\. Run binary from container

Synopsis:
```
docker run --rm -it mpq-extractor-debian [MPQExtractor ARGUMENTS ...]
```

Print help:

```sh
docker run --rm -it mpq-extractor-debian -h
```

> [!NOTE]
> Container filesystem is isolated from host filesystem, to make host directories accessible from the container,
> it's required to mount it on `docker run` command invocation, for example:
>
> ```sh
> export MPQ_DATA_DIR="/home/user/Documents/World of Warcraft 3.3.5a/Data" # directory on host
> export OUT_DATA_DIR="/home/user/Documents/MPQExtractor-output" # directory on host
>
> docker run -it --rm \
> --volume "$MPQ_DATA_DIR:/opt/data" \
> --volume "$OUT_DATA_DIR:/opt/data/out" \
> mpq-extractor-debian \
> -l /opt/data/out/list.txt /opt/data/patch-4.MPQ
>
> cat "$OUT_DATA_DIR/list.txt" # Print file on host (which created in container)
> ```

> [!TIP]
> Like in example from previous step, when it's required to play with container (containing
> the only `MPQExtractor`) interactively, such command may be used:
>
> ```sh
> docker run -it --rm --volume "$PWD:/opt/data" --entrypoint '/bin/bash' mpq-extractor-debian
> # ... do something inside the container, for example `MPQExtractor -h`
> ```

See [Usage](#usage) section for more usage examples.

## License

MPQExtractor is is made available under the MIT License. The text of the license is in the file 'LICENSE'.
MPQExtractor is made available under the MIT License. The text of the license is in the file 'LICENSE'.

Under the MIT License you may use MPQExtractor for any purpose you wish, without warranty, and modify it if you require, subject to one condition:

Expand Down