diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..d5ea1d8 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,69 @@ +version: 2 + +jobs: + + build: + machine: true + + environment: + PROJNAME: github.com/billziss-gh/cgofuse + + working_directory: ~/.go_workspace/src/github.com/billziss-gh/cgofuse + + steps: + - checkout + + - run: + name: Build cgofuse image + command: docker build -t cgofuse . + + - run: + name: Cross-compile cgofuse + command: | + go get -v github.com/karalabe/xgo + xgo \ + --image=cgofuse \ + --targets=darwin/386,darwin/amd64,linux/386,linux/amd64,windows/386,windows/amd64 \ + --buildmode=archive \ + ./fuse + + - run: + name: Prepare artifacts + command: | + mkdir -p /tmp/cgofuse.work/src/$PROJNAME/fuse + echo //go:binary-only-package >/tmp/cgofuse.work/src/$PROJNAME/fuse/host.go + echo package fuse >>/tmp/cgofuse.work/src/$PROJNAME/fuse/host.go + echo //go:binary-only-package >/tmp/cgofuse.work/src/$PROJNAME/fuse/fsop.go + echo package fuse >>/tmp/cgofuse.work/src/$PROJNAME/fuse/fsop.go + for f in fuse-*.[al]*; do + d=$(echo "$f" | sed 's/fuse-\([^-.]*\).*-\([^-.]*\)\..*/\1_\2/g') + mkdir -p /tmp/cgofuse.work/pkg/$d/$PROJNAME + cp "$f" /tmp/cgofuse.work/pkg/$d/$PROJNAME/fuse.a + done + mkdir -p /tmp/cgofuse.dist + GIT_DSC=$(git describe --long) + (cd /tmp/cgofuse.work && zip -rv - *) >/tmp/cgofuse.dist/cgofuse-$GIT_DSC.zip + + - store_artifacts: + path: /tmp/cgofuse.dist + + - deploy: + name: Make github release + command: | + if git describe --exact-match >/dev/null 2>&1; then + GIT_TAG=$(git describe --exact-match) + GIT_DSC=$(git describe --long) + go get -v github.com/aktau/github-release + github-release release \ + --user "$CIRCLE_PROJECT_USERNAME" \ + --repo "$CIRCLE_PROJECT_REPONAME" \ + --tag $GIT_TAG \ + --pre-release || true + github-release upload \ + --user "$CIRCLE_PROJECT_USERNAME" \ + --repo "$CIRCLE_PROJECT_REPONAME" \ + --tag $GIT_TAG \ + --file /tmp/cgofuse.dist/cgofuse-$GIT_DSC.zip \ + --name cgofuse-${GIT_TAG:1}.zip \ + --replace + fi