diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7b492ec..a479829 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,9 +16,9 @@ jobs: uses: actions/checkout@v2 - name: Install Nix - uses: cachix/install-nix-action@v20 + uses: cachix/install-nix-action@v22 with: - nix_path: nixpkgs=channel:nixos-22.11 + nix_path: nixpkgs=channel:nixos-23.05 - name: Cargo cache uses: actions/cache@v3 @@ -41,15 +41,23 @@ jobs: needs: tests runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/v') + strategy: + matrix: + target: + - aarch64-unknown-linux-musl + - armv5te-unknown-linux-musleabi + - armv7-unknown-linux-musleabihf + - mips-unknown-linux-musl + - mipsel-unknown-linux-musl steps: - name: Checkout uses: actions/checkout@v2 - name: Install Nix - uses: cachix/install-nix-action@v20 + uses: cachix/install-nix-action@v22 with: - nix_path: nixpkgs=channel:nixos-22.11 + nix_path: nixpkgs=channel:nixos-23.05 - name: Cargo cache uses: actions/cache@v3 @@ -60,10 +68,10 @@ jobs: ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ - key: ${{ runner.os }}-cargo-dist-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-cargo-dist-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} - name: Build distributables - run: nix-shell --command "make dist" + run: nix-shell --command "make dist-${{ matrix.target }}" - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 diff --git a/Makefile b/Makefile index 620a412..7c58a8e 100644 --- a/Makefile +++ b/Makefile @@ -1,69 +1,74 @@ .PHONY: dist # Compile the binaries for all targets. -build: +build: build-aarch64-unknown-linux-musl \ + build-armv5te-unknown-linux-musleabi \ + build-armv7-unknown-linux-musleabihf \ + build-mips-unknown-linux-musl \ + build-mipsel-unknown-linux-musl + +build-aarch64-unknown-linux-musl: cross build --target aarch64-unknown-linux-musl --release + +build-armv5te-unknown-linux-musleabi: cross build --target armv5te-unknown-linux-musleabi --release + +build-armv7-unknown-linux-musleabihf: cross build --target armv7-unknown-linux-musleabihf --release + +build-mips-unknown-linux-musl: cross build --target mips-unknown-linux-musl --release --no-default-features --features semtech_udp + +build-mipsel-unknown-linux-musl: cross build --target mipsel-unknown-linux-musl --release --no-default-features --features semtech_udp -# Build distributable binaries. -dist: build package +# Build distributable binaries for all targets. +dist: dist-aarch64-unknown-linux-musl \ + dist-armv5te-unknown-linux-musleabi \ + dist-armv7-unknown-linux-musleabihf \ + dist-mips-unknown-linux-musl \ + dist-mipsel-unknown-linux-musl -# Update the version. -version: - test -n "$(VERSION)" - sed -i 's/^version.*/version = "$(VERSION)"/g' ./Cargo.toml - make test - git add . - git commit -v -m "Bump version to $(VERSION)" - git tag -a v$(VERSION) -m "v$(VERSION)" +dist-aarch64-unknown-linux-musl: build-aarch64-unknown-linux-musl package-aarch64-unknown-linux-musl -# Cleanup dist. -clean: - cargo clean - rm -rf dist +dist-armv5te-unknown-linux-musleabi: build-armv5te-unknown-linux-musleabi package-armv5te-unknown-linux-musleabi -# Run tests -test: - cargo clippy --no-deps - cargo test +dist-armv7-unknown-linux-musleabihf: build-armv7-unknown-linux-musleabihf package-armv7-unknown-linux-musleabihf -# Enter the devshell. -devshell: - nix-shell +dist-mips-unknown-linux-musl: build-mips-unknown-linux-musl package-mips-unknown-linux-musl -# Enter the Docker based devshell. -docker-devshell: - docker-compose run --rm chirpstack-mqtt-forwarder +dist-mipsel-unknown-linux-musl: build-mipsel-unknown-linux-musl package-mipsel-unknown-linux-musl -# Package the compiled binaries. -package: package-targz-armv7hf package-targz-arm64 package-deb \ - package-dragino \ - package-multitech-conduit \ - package-multitech-conduit-ap \ - package-tektelic-kona \ - package-kerlink-klkgw \ - package-rak-ramips-24kec - -package-targz-armv7hf: +# Package the compiled binaries +package-aarch64-unknown-linux-musl: $(eval PKG_VERSION := $(shell cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')) mkdir -p dist - tar -czvf dist/chirpstack-mqtt-forwarder_$(PKG_VERSION)_armv7hf.tar.gz -C target/armv7-unknown-linux-musleabihf/release chirpstack-mqtt-forwarder -package-targz-arm64: - $(eval PKG_VERSION := $(shell cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')) - mkdir -p dist + # .tar.gz tar -czvf dist/chirpstack-mqtt-forwarder_$(PKG_VERSION)_arm64.tar.gz -C target/aarch64-unknown-linux-musl/release chirpstack-mqtt-forwarder -package-deb: + # .deb cargo deb --target aarch64-unknown-linux-musl --no-build --no-strip - cargo deb --target armv7-unknown-linux-musleabihf --no-build --no-strip + cp target/aarch64-unknown-linux-musl/debian/*.deb ../dist + +package-armv7-unknown-linux-musleabihf: package-tektelic-kona package-kerlink-klkgw + $(eval PKG_VERSION := $(shell cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')) mkdir -p dist + + # .tar.gz + tar -czvf dist/chirpstack-mqtt-forwarder_$(PKG_VERSION)_armv7hf.tar.gz -C target/armv7-unknown-linux-musleabihf/release chirpstack-mqtt-forwarder + + # .deb + cargo deb --target armv7-unknown-linux-musleabihf --no-build --no-strip cp target/armv7-unknown-linux-musleabihf/debian/*.deb ../dist - cp target/aarch64-unknown-linux-musl/debian/*.deb ../dist +package-armv5te-unknown-linux-musleabi: package-multitech-conduit package-multitech-conduit-ap + +package-mips-unknown-linux-musl: package-dragino + +package-mipsel-unknown-linux-musl: package-rak-ramips-24kec + +# Gateway specific packaging. package-dragino: cd packaging/vendor/dragino/mips_24kc && ./package.sh mkdir -p dist/vendor/dragino/mips_24kc @@ -93,3 +98,30 @@ package-kerlink-klkgw: cd packaging/vendor/kerlink/klkgw && ./package.sh mkdir -p dist/vendor/kerlink/klkgw cp packaging/vendor/kerlink/klkgw/*.ipk dist/vendor/kerlink/klkgw + +# Update the version. +version: + test -n "$(VERSION)" + sed -i 's/^version.*/version = "$(VERSION)"/g' ./Cargo.toml + make test + git add . + git commit -v -m "Bump version to $(VERSION)" + git tag -a v$(VERSION) -m "v$(VERSION)" + +# Cleanup dist. +clean: + cargo clean + rm -rf dist + +# Run tests +test: + cargo clippy --no-deps + cargo test + +# Enter the devshell. +devshell: + nix-shell + +# Enter the Docker based devshell. +docker-devshell: + docker-compose run --rm chirpstack-mqtt-forwarder