From d5d6d737698c331ac37b88f4e24361de7fbf1b6b Mon Sep 17 00:00:00 2001 From: joneshf Date: Fri, 27 Jul 2018 05:03:47 -0700 Subject: [PATCH] Add rules for uploading to hackage While it would be really nice to run this from CI, The only way to upload a package involves using account-wide credentials. We can either use a username/password, or an API token. Both of these credentials have the same privileges, and that's too much power to give to CI. For now, we run this from the local machine. Maybe we can think of another way that's a bit safer. --- .circleci/config.yml | 11 +++++++++++ Makefile | 38 ++++++++++++++++++++++++++++++++++---- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d78feee..38111f6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,5 +1,14 @@ version: 2 jobs: + sdist: + docker: + - image: haskell:8.2.2 + steps: + - checkout + - run: + name: Build sdist + command: make sdist + test: docker: - image: haskell:8.2.2 @@ -20,8 +29,10 @@ jobs: paths: - .stack-work - /root/.stack + workflows: version: 2 base: jobs: + - sdist - test diff --git a/Makefile b/Makefile index 0012009..735722d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,9 @@ +PROJECT_NAME := rollbar-hs + BIN := bin +CABAL := cabal +CABAL_FILE := $(PROJECT_NAME).cabal +DIST := dist EMPTY := .make GHCID := $(BIN)/ghcid STACK := stack @@ -6,30 +11,55 @@ STACK_WORK := .stack-work .DEFAULT_GOAL := build +$(BIN): + mkdir -p $@ + +$(DIST): + mkdir -p $@ + $(EMPTY): - mkdir $@ + mkdir -p $@ $(EMPTY)/stack-setup: | $(EMPTY) $(STACK) setup touch $@ -$(GHCID): $(EMPTY)/stack-setup +$(GHCID): $(EMPTY)/stack-setup | $(BIN) $(STACK) install ghcid --local-bin-path $(BIN) +$(CABAL_FILE): + # `stack` has no way to run `hpack` directly. + # We can run `hpack` indirectly with little overhead. + $(STACK) build --dry-run + .PHONY: build build: $(EMPTY)/stack-setup $(STACK) build --no-run-tests --test +.PHONY: cabal-check +cabal-check: $(CABAL_FILE) + $(CABAL) check + .PHONY: clean clean: - rm -f $(BIN)/* - rm -f $(EMPTY)/* + rm -f $(CABAL_FILE) + rm -fr $(BIN) + rm -fr $(DIST) + rm -fr $(EMPTY) rm -fr $(STACK_WORK) +.PHONY: sdist +sdist: cabal-check | $(DIST) + $(CABAL) sdist + .PHONY: test test: build $(STACK) test +.PHONY: upload-hackage +upload-hackage: sdist + @ $(CABAL) upload $(DIST)/$(PROJECT_NAME)-*.tar.gz + .PHONY: watch watch: $(GHCID) $(GHCID)