Skip to content

Commit

Permalink
Merge pull request #7 from IGBB/windows
Browse files Browse the repository at this point in the history
Build Releases with GitHub Actions
  • Loading branch information
adamthrash authored Apr 12, 2024
2 parents 15cf058 + 86545c6 commit 72ba37d
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 16 deletions.
22 changes: 14 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: Create Draft Release
name: Create Release

on:
workflow_dispatch:
#push:
# branches: [ "main" ]
#pull_request:
# branches: [ "main" ]
schedule:
- cron: "0 0 1 */6 *"

jobs:
create_release:
Expand All @@ -17,7 +15,7 @@ jobs:
- name: Create
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release create -d "draft"
run: gh release create "v$(date '+%Y.%m')" -t "v$(date '+%Y.%m')"
release:
name: Build and Upload
needs: create_release
Expand All @@ -37,9 +35,17 @@ jobs:
"C:\msys64\usr\bin\" | Out-File -FilePath $env:GITHUB_PATH -Append
- name: Makefile
run: make -C src
- name: Release
- name: Release (Windows)
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: startsWith(runner.os, 'Windows')
run: |
mv egads.exe egads_${{ runner.os }}.exe
gh release upload "v$(date '+%Y.%m')" egads_${{ runner.os }}.exe
- name: Release (Not Windows)
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ ! startsWith(runner.os, 'Windows') }}
run: |
mv egads egads_${{ runner.os }}
gh release upload "draft" egads_${{ runner.os }}
gh release upload "v$(date '+%Y.%m')" egads_${{ runner.os }}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ Electronically Guided Digestion Selection - A ddRAD-seq enzyme selection aid

## Installation

Install `egads` from this repository with the following command.

``` sh
git clone --recursive https://github.com/IGBB/egads
make -C egads/src
```

Binary releases for Windows, macOS, and Linux are available
[on the Releases page](https://github.com/igbb/egads/releases) and are released
every six months to account for potential updates to the enzyme database.

## Running

`egads` requires three arguments: 1) `--rare`: a comma-delimited list of rare
Expand Down
19 changes: 12 additions & 7 deletions src/enzyme.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
#include <string.h>
#include <stdlib.h>

#ifdef _WIN32
FILE *fmemopen(void *buf, size_t len, const char *type);
#include "fmemopen.c"
#endif

#include "klib/kstring.h"

#define INCBIN_PREFIX incbin_
#define INCBIN_STYLE INCBIN_STYLE_SNAKE
#define INCBIN_SILENCE_BITCODE_WARNING
Expand Down Expand Up @@ -68,9 +75,7 @@ char* strtok2(char* string, char token){

enzyme_list_t* load_enzymes(char* input, char** names, int len){
int i;
char *s = NULL;
size_t slen = 0;
ssize_t rlen;
kstring_t s = { 0, 0, NULL };

/* Open enzyme file. If file isn't provided, open mem stream to saved
* restriction enzymes */
Expand All @@ -93,13 +98,13 @@ enzyme_list_t* load_enzymes(char* input, char** names, int len){
enzyme_list_t * list = enzyme_list_init();

/* read each line in enzyme database */
while((rlen = getline(&s, &slen, file)) != -1 ){
for (s.l = 0; kgetline(&s, (kgets_func *)fgets, file) == 0; s.l = 0){

/* skip lines that begin with space */
if(s[0] == ' ') continue;
if(ks_str(&s)[0] == ' ') continue;

/* get name (first column) */
char * name = strtok2(s, ';');
char * name = strtok2(ks_str(&s), ';');

enzyme_t * e;

Expand Down Expand Up @@ -187,7 +192,7 @@ enzyme_list_t* load_enzymes(char* input, char** names, int len){

}

free(s);
free(s.s);

fclose(file);

Expand Down
56 changes: 56 additions & 0 deletions src/fmemopen.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2017 Joachim Nilsson <[email protected]>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdlib.h>
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <windows.h>
FILE *fmemopen(void *buf, size_t len, const char *type)
{
int fd;
FILE *fp;
char tp[MAX_PATH - 13];
char fn[MAX_PATH + 1];
HANDLE h;

if (!GetTempPath(sizeof(tp), tp))
return NULL;

if (!GetTempFileName(tp, "confuse", 0, fn))
return NULL;

h = CreateFile(fn, GENERIC_READ | GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL);
if (INVALID_HANDLE_VALUE == h)
return NULL;

fd = _open_osfhandle((intptr_t)h, _O_APPEND);
if (fd < 0) {
CloseHandle(h);
return NULL;
}

fp = fdopen(fd, "w+");
if (!fp) {
CloseHandle(h);
return NULL;
}

fwrite(buf, len, 1, fp);
rewind(fp);

return fp;
}
2 changes: 1 addition & 1 deletion src/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ html.o : html/d3.v5.min.js html/draw.d3.css html/draw.gel.js html/draw.html html
main.o : restrict.o enzyme.o sequence.o html.o


$(PROG): main.o restrict.o enzyme.o sequence.o counts.o html.o args.o
$(PROG): main.o restrict.o enzyme.o sequence.o counts.o html.o args.o klib/kstring.o
$(CC) -o $@ $^ $(CFLAGS) -lz
# end

0 comments on commit 72ba37d

Please sign in to comment.