From c424f0f19127b5d4f2ebd531b9be2a98d9f76a5a Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Sun, 24 Aug 2025 14:12:49 +0200 Subject: [PATCH] build: add Makefile and GitHub workflows --- .github/workflows/release.yml | 46 ++++++++++++++++++++++++++++++ .github/workflows/tests.yml | 22 +++++++++++++++ Makefile | 53 +++++++++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/tests.yml create mode 100644 Makefile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..dc692cf --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,46 @@ +name: Create release and upload assets + +on: + push: + tags: + - 'v*' + +jobs: + linuxbuild: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + - name: Run tests + run: cargo test --verbose + - run: make linux-package + - name: Release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: 'true' + make_latest: 'true' + generate_release_notes: 'true' + files: | + *linux.tar.gz + windowsbuild: + runs-on: windows-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + - name: Run tests + run: cargo test --verbose + - run: make win-package + - name: Release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: 'true' + make_latest: 'true' + generate_release_notes: 'true' + files: | + *win64.zip \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..1b0e059 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,22 @@ +name: "Run Tests" + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Build + run: cargo build --verbose + - name: Run tests + run: cargo test --verbose diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2a8f981 --- /dev/null +++ b/Makefile @@ -0,0 +1,53 @@ +ifndef VERBOSE +.SILENT: +endif + +GITTAG = $(shell git describe --tag --abbrev=0 2>/dev/null | sed -En 's/v(.*)$$/\1/p') +ifeq ($(findstring -, $(GITTAG)), -) + GITDEV = $(shell git describe --tag 2>/dev/null | sed -En 's/v(.*)-([0-9]+)-g([0-9a-f]+)$$/.dev.\2+\3/p') +else + GITDEV = $(shell git describe --tag 2>/dev/null | sed -En 's/v(.*)-([0-9]+)-g([0-9a-f]+)$$/-dev.\2+\3/p') +endif +VERSION := "$(GITTAG)$(GITDEV)" + +package-all: win-package linux-package + +.PHONY: win-package +win-package: win-binary-x86_64 + mkdir fastq-tools || true + cp target/x86_64-pc-windows-gnu/release/fastq-tools.exe fastq-tools/ + cp README.md fastq-tools/ + cp LICENSE fastq-tools/ + # first try (linux) zip command, then powershell sub command to create ZIP file + zip fastq-tools-$(VERSION)_win64.zip fastq-tools/* || powershell Compress-ARCHIVE fastq-tools fastq-tools-$(VERSION)_win64.zip + rm -rf fastq-tools || true + +.PHONY: linux-package +linux-package: linux-binary-x86_64 + mkdir fastq-tools || true + cp target/x86_64-unknown-linux-gnu/release/fastq-tools fastq-tools/ + cp README.md fastq-tools/ + cp LICENSE fastq-tools/ + tar -czvf fastq-tools-$(VERSION)_linux.tar.gz fastq-tools/ + rm -rf fastq-tools || true + +binary-all: win-binary-x86_64 linux-binary-x86_64 + +.PHONY: win-binary-x86_64 +win-binary-x86_64: + cargo build --release --target=x86_64-pc-windows-gnu + +.PHONY: linux-binary-x86_64 +linux-binary-x86_64: + cargo build --release --target=x86_64-unknown-linux-gnu + +.PHONY: install +install: + cargo install --path . + +.PHONY: clean +clean: + cargo clean + rm -rf fastq-tools 2>/dev/null || true + rm *_win64.zip 2>/dev/null || true + rm *_linux.tar.gz 2>/dev/null || true \ No newline at end of file