diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 88f7c3a..a485bb6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,44 +6,47 @@ on: jobs: release: - runs-on: ${{ matrix.platform == 'linux' && 'ubuntu-latest' || matrix.platform == 'windows' && 'ubuntu-latest' || matrix.platform == 'osx' && 'macos-latest' }} + runs-on: ${{ matrix.platform == 'linux' && 'ubuntu-latest' || matrix.platform == 'windows' && 'ubuntu-latest' || matrix.platform == 'macos' && 'macos-latest' }} strategy: matrix: - platform: [linux, windows, osx] + platform: [linux, windows, macos] fail-fast: false steps: - name: Checkout code uses: actions/checkout@v4 - # Linux + + # Linux (for linux and windows we can use the default make commands to build the binary) - name: Build binary (linux/windows) if: matrix.platform == 'linux' || matrix.platform == 'windows' - run: docker run --rm -v "${PWD}:/src/" --env SPECFILE=./schwifty.spec batonogov/pyinstaller-${{ matrix.platform }} + run: make dist-${{ matrix.platform }} + - # Macos + # Macos (for macos we need to use cachix to install nix and devenv and then use devenv to build the binary) - uses: cachix/install-nix-action@v26 - if: matrix.platform == 'osx' + if: matrix.platform == 'macos' - uses: cachix/cachix-action@v14 - if: matrix.platform == 'osx' + if: matrix.platform == 'macos' with: name: devenv - name: Install devenv.sh - if: matrix.platform == 'osx' + if: matrix.platform == 'macos' run: nix profile install nixpkgs#devenv - name: Build binary (macos) - if: matrix.platform == 'osx' - run: devenv test + if: matrix.platform == 'macos' + run: devenv shell make dist-macos + # Finalize - name: Test binary - run: dist/schwifty "DE89370400440532013000" + run: dist/${{ matrix.platform }}/schwifty "DE89370400440532013000" - name: Compress binary - run: tar -czvf schwifty-${{ matrix.platform }}.tar.gz -C dist/ schwifty + run: tar -czvf schwifty-${{ matrix.platform }}.tar.gz -C dist/${{ matrix.platform }}/ schwifty - uses: shogo82148/actions-upload-release-asset@v1 with: diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c7856e2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM debian:bookworm-slim + +WORKDIR /app + +RUN apt-get update && \ + apt-get install -y --no-install-recommends curl tar && \ + rm -rf /var/lib/apt/lists/* + +# COPY ./schwifty-linux.tar.gz . + +# RUN tar -xzf schwifty-linux.tar.gz && rm schwifty-linux.tar.gz + +COPY ./dist/schwifty . + +ENTRYPOINT ["./schwifty"] \ No newline at end of file diff --git a/Makefile b/Makefile index c51f022..43c3f54 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build test +.PHONY: build test test-binary dist-linux dist-macos dist-windows build: pyinstaller --clean --noconfirm schwifty.spec @@ -7,4 +7,21 @@ test: @$(DEVENV_ROOT)/.venv/bin/python $(DEVENV_ROOT)/schwifty-cli/__main__.py "DE89370400440532013000" | jq '.' test-binary: - @$(DEVENV_ROOT)/dist/schwifty "DE89370400440532013000" | jq '.' \ No newline at end of file + @$(DEVENV_ROOT)/dist/schwifty "DE89370400440532013000" | jq '.' + +# Targets for building the binary distributions for different platforms. +dist-linux: + docker run --rm -v "${PWD}:/src/" --env SPECFILE=./schwifty.spec batonogov/pyinstaller-linux + mkdir dist/linux + mv dist/schwifty dist/linux/schwifty + +dist-macos: + # docker run --rm -v "${PWD}:/src/" --env SPECFILE=./schwifty.spec batonogov/pyinstaller-osx + pyinstaller --clean --noconfirm schwifty.spec + mkdir dist/macos + mv dist/schwifty dist/macos/schwifty + +dist-windows: + docker run --rm -v "${PWD}:/src/" --env SPECFILE=./schwifty.spec batonogov/pyinstaller-windows + mkdir dist/windows + mv dist/schwifty dist/windows/schwifty \ No newline at end of file