Deploy to hackage from CircleCI

Enviroment

  • stack 0.1.10.1

Preparation

install stack

dependencies:  
  pre:
    - wget -q -O- https://s3.amazonaws.com/download.fpcomplete.com/ubuntu/fpco.key | sudo apt-key add - # add fpcomplate key
    - echo 'deb http://download.fpcomplete.com/ubuntu/precise stable main'|sudo tee /etc/apt/sources.list.d/fpco.list
    -  sudo apt-get update && sudo apt-get install stack -y # install stack

Deployment

Hackage doesn't support API token for upload, so I directly use password.

In CircleCI, You need to put Sensitive data into Environment variables.

I set HACKAGE_USERNAME and HACKAGE_PASSWD.

Exporting environment variable to .stack/upload/credentials.json in order to use this information to authenticate with the stack.

cred=~/.stack/upload/credentials.json  
if [ ! -f "${cred}" ]; then  
    if [ ! -e ~/.stack/upload ]; then
    mkdir -p ~/.stack/upload
    fi
    echo "{\"username\":\"${HACKAGE_USERNAME}\",\"password\":\"${HACKAGE_PASSWD}\"}" > ${cred}
fi  

To Deployment

deployment:  
  master:
    branch: master
    commands:
      - ./etc/setup-stack-credentials.sh
      - stack sdist
      - stack upload .

refarences